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 { ...@@ -102,6 +102,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
102 private static final String UPDATE_META = "updateMeta"; 102 private static final String UPDATE_META = "updateMeta";
103 private static final String ADD_HOST_INTENT = "addHostIntent"; 103 private static final String ADD_HOST_INTENT = "addHostIntent";
104 private static final String REMOVE_INTENT = "removeIntent"; 104 private static final String REMOVE_INTENT = "removeIntent";
105 + private static final String RESUBMIT_INTENT = "resubmitIntent";
105 private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent"; 106 private static final String ADD_MULTI_SRC_INTENT = "addMultiSourceIntent";
106 private static final String REQ_RELATED_INTENTS = "requestRelatedIntents"; 107 private static final String REQ_RELATED_INTENTS = "requestRelatedIntents";
107 private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent"; 108 private static final String REQ_NEXT_INTENT = "requestNextRelatedIntent";
...@@ -224,6 +225,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { ...@@ -224,6 +225,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
224 new AddHostIntent(), 225 new AddHostIntent(),
225 new AddMultiSourceIntent(), 226 new AddMultiSourceIntent(),
226 new RemoveIntent(), 227 new RemoveIntent(),
228 + new ResubmitIntent(),
227 229
228 new ReqAllFlowTraffic(), 230 new ReqAllFlowTraffic(),
229 new ReqAllPortTraffic(), 231 new ReqAllPortTraffic(),
...@@ -467,6 +469,23 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { ...@@ -467,6 +469,23 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase {
467 } 469 }
468 } 470 }
469 471
472 + private final class ResubmitIntent extends RequestHandler {
473 + private ResubmitIntent() {
474 + super(RESUBMIT_INTENT);
475 + }
476 +
477 + @Override
478 + public void process(long sid, ObjectNode payload) {
479 + Intent intent = findIntentByPayload(payload);
480 + if (intent == null) {
481 + log.warn("Unable to find intent from payload {}", payload);
482 + } else {
483 + log.debug("Resubmitting intent {}", intent.key());
484 + intentService.submit(intent);
485 + }
486 + }
487 + }
488 +
470 private final class AddMultiSourceIntent extends RequestHandler { 489 private final class AddMultiSourceIntent extends RequestHandler {
471 private AddMultiSourceIntent() { 490 private AddMultiSourceIntent() {
472 super(ADD_MULTI_SRC_INTENT); 491 super(ADD_MULTI_SRC_INTENT);
......
...@@ -32,6 +32,11 @@ ...@@ -32,6 +32,11 @@
32 tooltip tt-msg="topoTip" 32 tooltip tt-msg="topoTip"
33 ng-click="showIntent()"></div> 33 ng-click="showIntent()"></div>
34 34
35 + <div ng-class="{'active': !!selId && isIntentWithdrawn()}"
36 + icon icon-id="play" icon-size="42"
37 + tooltip tt-msg="resubmitTip"
38 + ng-click="(!!selId && isIntentWithdrawn()) ? resubmitIntent():''"></div>
39 +
35 <div ng-class="{'active': !!selId && isIntentInstalled()}" 40 <div ng-class="{'active': !!selId && isIntentInstalled()}"
36 icon icon-id="stop" icon-size="42" 41 icon icon-id="stop" icon-size="42"
37 tooltip tt-msg="deactivateTip" 42 tooltip tt-msg="deactivateTip"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
71 }); 71 });
72 72
73 $scope.topoTip = 'Show selected intent on topology view'; 73 $scope.topoTip = 'Show selected intent on topology view';
74 + $scope.resubmitTip = 'Resubmit selected intent';
74 $scope.deactivateTip = 'Remove selected intent'; 75 $scope.deactivateTip = 'Remove selected intent';
75 $scope.purgeTip = 'Purge selected intent'; 76 $scope.purgeTip = 'Purge selected intent';
76 77
...@@ -87,20 +88,22 @@ ...@@ -87,20 +88,22 @@
87 return $scope.intentState === 'Withdrawn'; 88 return $scope.intentState === 'Withdrawn';
88 }; 89 };
89 90
90 - function executeAction(bPurge) { 91 + function executeAction(action) {
91 var content = ds.createDiv(), 92 var content = ds.createDiv(),
92 - txt = bPurge ? 'purge' : 'withdraw' ; 93 + txt,
94 + bPurge = action === 'purge';
93 95
94 $scope.intentData.intentPurge = bPurge; 96 $scope.intentData.intentPurge = bPurge;
95 97
96 content.append('p'). 98 content.append('p').
97 - text('Are you sure you want to '+ txt + 99 + text('Are you sure you want to '+ action +
98 ' the selected intent?'); 100 ' the selected intent?');
99 101
100 function dOk() { 102 function dOk() {
101 var d = $scope.intentData; 103 var d = $scope.intentData;
102 $log.debug(d); 104 $log.debug(d);
103 - d && tts.removeIntent(d); 105 + d && (action === 'resubmit' ? tts.resubmitIntent(d) :
106 + tts.removeIntent(d));
104 $scope.fired = true; 107 $scope.fired = true;
105 } 108 }
106 109
...@@ -118,11 +121,15 @@ ...@@ -118,11 +121,15 @@
118 } 121 }
119 122
120 $scope.deactivateIntent = function () { 123 $scope.deactivateIntent = function () {
121 - executeAction(false); 124 + executeAction("withdraw");
125 + };
126 +
127 + $scope.resubmitIntent = function () {
128 + executeAction("resubmit");
122 }; 129 };
123 130
124 $scope.purgeIntent = function () { 131 $scope.purgeIntent = function () {
125 - executeAction(true); 132 + executeAction("purge");
126 }; 133 };
127 134
128 $scope.briefToggle = function () { 135 $scope.briefToggle = function () {
......
...@@ -192,6 +192,19 @@ ...@@ -192,6 +192,19 @@
192 flash.flash('Intent ' + txt); 192 flash.flash('Intent ' + txt);
193 } 193 }
194 194
195 + function resubmitIntent (d) {
196 + $log.debug('Entering resubmitIntent');
197 + wss.sendEvent('resubmitIntent', {
198 + appId: d.appId,
199 + appName: d.appName,
200 + key: d.key,
201 + purge: d.intentPurge
202 + });
203 + trafficMode = 'intents';
204 + hoverMode = null;
205 + flash.flash('Intent resubmitted');
206 + }
207 +
195 function addMultiSourceIntent () { 208 function addMultiSourceIntent () {
196 var so = api.selectOrder(); 209 var so = api.selectOrder();
197 wss.sendEvent('addMultiSourceIntent', { 210 wss.sendEvent('addMultiSourceIntent', {
...@@ -240,7 +253,8 @@ ...@@ -240,7 +253,8 @@
240 // invoked from buttons on detail (multi-select) panel 253 // invoked from buttons on detail (multi-select) panel
241 addHostIntent: addHostIntent, 254 addHostIntent: addHostIntent,
242 addMultiSourceIntent: addMultiSourceIntent, 255 addMultiSourceIntent: addMultiSourceIntent,
243 - removeIntent: removeIntent 256 + removeIntent: removeIntent,
257 + resubmitIntent: resubmitIntent
244 }; 258 };
245 }]); 259 }]);
246 }()); 260 }());
......
...@@ -50,6 +50,7 @@ describe('factory: view/topo/topoTraffic.js', function() { ...@@ -50,6 +50,7 @@ describe('factory: view/topo/topoTraffic.js', function() {
50 'addHostIntent', 50 'addHostIntent',
51 'addMultiSourceIntent', 51 'addMultiSourceIntent',
52 'removeIntent', 52 'removeIntent',
53 + 'resubmitIntent',
53 ])).toBeTruthy(); 54 ])).toBeTruthy();
54 }); 55 });
55 56
......