Viswanath KSP
Committed by Gerrit Code Review

[onos-5262] Adding patchset 1

[onos-5262] Adding patchset 2

Change-Id: I43cb43deca16bcfe1874699bccdb94b0301d30d1
......@@ -102,6 +102,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
private static final String UPDATE_META = "updateMeta";
private static final String ADD_HOST_INTENT = "addHostIntent";
private static final String REMOVE_INTENT = "removeIntent";
private static final String RESUBMIT_INTENT = "resubmitIntent";
private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent";
private static final String REQ_RELATED_INTENTS = "requestRelatedIntents";
private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent";
......@@ -224,6 +225,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
new AddHostIntent(),
new AddMultiSourceIntent(),
new RemoveIntent(),
new ResubmitIntent(),
new ReqAllFlowTraffic(),
new ReqAllPortTraffic(),
......@@ -467,6 +469,23 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
}
}
private final class ResubmitIntent extends RequestHandler {
private ResubmitIntent() {
super(RESUBMIT_INTENT);
}
@Override
public void process(long sid, ObjectNode payload) {
Intent intent = findIntentByPayload(payload);
if (intent == null) {
log.warn("Unable to find intent from payload {}", payload);
} else {
log.debug("Resubmitting intent {}", intent.key());
intentService.submit(intent);
}
}
}
private final class AddMultiSourceIntent extends RequestHandler {
private AddMultiSourceIntent() {
super(ADD_MULTI_SRC_INTENT);
......
......@@ -32,6 +32,11 @@
tooltip tt-msg="topoTip"
ng-click="showIntent()"></div>
<div ng-class="{'active': !!selId && isIntentWithdrawn()}"
icon icon-id="play" icon-size="42"
tooltip tt-msg="resubmitTip"
ng-click="(!!selId && isIntentWithdrawn()) ? resubmitIntent():''"></div>
<div ng-class="{'active': !!selId && isIntentInstalled()}"
icon icon-id="stop" icon-size="42"
tooltip tt-msg="deactivateTip"
......
......@@ -71,6 +71,7 @@
});
$scope.topoTip = 'Show selected intent on topology view';
$scope.resubmitTip = 'Resubmit selected intent';
$scope.deactivateTip = 'Remove selected intent';
$scope.purgeTip = 'Purge selected intent';
......@@ -87,20 +88,22 @@
return $scope.intentState === 'Withdrawn';
};
function executeAction(bPurge) {
function executeAction(action) {
var content = ds.createDiv(),
txt = bPurge ? 'purge' : 'withdraw' ;
txt,
bPurge = action === 'purge';
$scope.intentData.intentPurge = bPurge;
content.append('p').
text('Are you sure you want to '+ txt +
text('Are you sure you want to '+ action +
' the selected intent?');
function dOk() {
var d = $scope.intentData;
$log.debug(d);
d && tts.removeIntent(d);
d && (action === 'resubmit' ? tts.resubmitIntent(d) :
tts.removeIntent(d));
$scope.fired = true;
}
......@@ -118,11 +121,15 @@
}
$scope.deactivateIntent = function () {
executeAction(false);
executeAction("withdraw");
};
$scope.resubmitIntent = function () {
executeAction("resubmit");
};
$scope.purgeIntent = function () {
executeAction(true);
executeAction("purge");
};
$scope.briefToggle = function () {
......
......@@ -192,6 +192,19 @@
flash.flash('Intent ' + txt);
}
function resubmitIntent (d) {
$log.debug('Entering resubmitIntent');
wss.sendEvent('resubmitIntent', {
appId: d.appId,
appName: d.appName,
key: d.key,
purge: d.intentPurge
});
trafficMode = 'intents';
hoverMode = null;
flash.flash('Intent resubmitted');
}
function addMultiSourceIntent () {
var so = api.selectOrder();
wss.sendEvent('addMultiSourceIntent', {
......@@ -240,7 +253,8 @@
// invoked from buttons on detail (multi-select) panel
addHostIntent: addHostIntent,
addMultiSourceIntent: addMultiSourceIntent,
removeIntent: removeIntent
removeIntent: removeIntent,
resubmitIntent: resubmitIntent
};
}]);
}());
......
......@@ -50,6 +50,7 @@ describe('factory: view/topo/topoTraffic.js', function() {
'addHostIntent',
'addMultiSourceIntent',
'removeIntent',
'resubmitIntent',
])).toBeTruthy();
});
......