Skip to content
Snippets Groups Projects
Commit 94604e31 authored by Erik Reid's avatar Erik Reid
Browse files

Finished feature DBOARD3-244-add-task-status-to-update-gui.

parents 4ecc9abc 2db51071
No related branches found
No related tags found
No related merge requests found
......@@ -23,9 +23,10 @@ def update():
force = False
config = current_app.config['INVENTORY_PROVIDER_CONFIG']
r = get_current_redis(config)
if not force:
latch = get_latch(get_current_redis(config))
latch = get_latch(r)
if latch and latch['pending']:
return Response(
response='an update is already in progress',
......@@ -34,7 +35,6 @@ def update():
phase2_task_id = worker.launch_refresh_cache_all(config)
r = common.get_current_redis()
r.set('classifier-cache:update-task-id', phase2_task_id.encode('utf-8'))
return jsonify({'task id': phase2_task_id})
......
......@@ -29,6 +29,25 @@
{{ update_request_status }}
</div>
<span class="grid-item" ng-show="latch_error||latch_pending">
<table class="table table-striped">
<tr>
<th colspan="4" scope="col">update tasks</th>
<tr>
<th scope="col">name</th>
<th scope="col">status</th>
<th scope="col">success</th>
<th scope="col">message</th>
</tr>
<tr ng-repeat="t in tasks">
<td>{{ t.name }}</td>
<td>{{ t.status }}</td>
<td>{{ t.success }}</td>
<td>{{ t.message }}</td>
</tr>
</table>
</span>
</div>
</div>
</body>
......
......@@ -9,6 +9,8 @@ myApp.controller('update', function($scope, $http, $timeout) {
$scope.update_request_status = "";
$scope.update_request_error = false;
$scope.tasks = [];
$scope.check_status = function() {
$http({
......@@ -25,6 +27,9 @@ myApp.controller('update', function($scope, $http, $timeout) {
$scope.update_request_status = "";
}
$timeout($scope.check_status, 5000);
if ($scope.latch_pending || $scope.latch_error) {
$scope.refresh_update_status();
}
},
/* error response */
function(rsp) {
......@@ -32,11 +37,39 @@ myApp.controller('update', function($scope, $http, $timeout) {
$scope.latch_info = "communication error";
$scope.latch_pending = false;
$scope.latch_error = true;
$timeout($scope.check_status(), 5000);
$timeout($scope.check_status, 5000);
}
);
}
$scope.refresh_update_status = function() {
$http({
method: 'GET',
// url: window.location.origin + "/jobs/check-task-status/9d1cbcd2-c377-4b7a-b969-04ce17f03f20"
url: window.location.origin + "/jobs/check-update-status"
}).then(
/* ok response */
function(rsp) {
console.log('got update status rsp: ' + JSON.stringify(rsp.data).substring(0,30));
$scope.tasks = rsp.data.map(t => ({
id: t.id,
parent: t.parent,
status: t.status,
success: t.ready ? (t.success ? "OK" : "NO") : "-",
message: (t.result && t.result.message) ? t.result.message.substring(0,100) : "",
name: t.result ? t.result.task : "",
}));
},
/* error response */
function(rsp) {
// assume this is 404 ...
$scope.tasks = [];
}
);
}
$scope.launch_update = function() {
$scope.update_request_status = "sending update request";
$scope.update_request_error = false;
......
......@@ -471,7 +471,7 @@ def reload_router_config(self, hostname):
state=states.STARTED,
meta={
'hostname': hostname,
'message': 'loading router netconf data'
'message': f'loading netconf data for {hostname}'
})
# get the timestamp for the current netconf data
......@@ -495,8 +495,9 @@ def reload_router_config(self, hostname):
assert new_netconf_timestamp, \
'no timestamp available for new netconf data'
if new_netconf_timestamp == current_netconf_timestamp:
logger.debug('no netconf change timestamp change, aborting')
return self.success(f'no change (timestamp not updated)')
msg = f'no timestamp change for {hostname} netconf data'
logger.debug(msg)
return self.success(msg)
# clear cached classifier responses for this router, and
# refresh peering data
......@@ -504,7 +505,7 @@ def reload_router_config(self, hostname):
state=states.STARTED,
meta={
'hostname': hostname,
'message': 'refreshing peers & clearing cache'
'message': f'refreshing peers & clearing cache for {hostname}'
})
refresh_ix_public_peers(hostname, netconf_doc)
refresh_vpn_rr_peers(hostname, netconf_doc)
......@@ -516,19 +517,20 @@ def reload_router_config(self, hostname):
community = juniper.snmp_community_string(netconf_doc)
if not community:
raise InventoryTaskError(
'error extracting community string for %r' % hostname)
f'error extracting community string for {hostname}')
else:
self.update_state(
state=states.STARTED,
meta={
'hostname': hostname,
'message': 'refreshing snmp interface indexes'
'message': f'refreshing snmp interface indexes for {hostname}'
})
# load snmp data, in this thread
snmp_refresh_interfaces.apply(args=[hostname, community])
clear_cached_classifier_responses(None)
return self.success(f'updated config for {hostname}')
return self.success(f'updated configuration for {hostname}')
def _erase_next_db(config):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment