GUI -- ONOS-1172 - Added 'dash' keystroke to report on bad links.
Change-Id: Ie4226b25d4219001be17add8b501e1a77585334a
Showing
4 changed files
with
52 additions
and
11 deletions
... | @@ -50,7 +50,6 @@ | ... | @@ -50,7 +50,6 @@ |
50 | // key-logical-name to key-display lookup.. | 50 | // key-logical-name to key-display lookup.. |
51 | var keyDisp = { | 51 | var keyDisp = { |
52 | equals: '=', | 52 | equals: '=', |
53 | - dash: '-', | ||
54 | slash: '/', | 53 | slash: '/', |
55 | backSlash: '\\', | 54 | backSlash: '\\', |
56 | backQuote: '`', | 55 | backQuote: '`', | ... | ... |
... | @@ -49,8 +49,9 @@ | ... | @@ -49,8 +49,9 @@ |
49 | 49 | ||
50 | H: [tfs.toggleHosts, 'Toggle host visibility'], | 50 | H: [tfs.toggleHosts, 'Toggle host visibility'], |
51 | M: [tfs.toggleOffline, 'Toggle offline visibility'], | 51 | M: [tfs.toggleOffline, 'Toggle offline visibility'], |
52 | - B: [toggleMap, 'Toggle background map'], | ||
53 | P: [tfs.togglePorts, 'Toggle Port Highlighting'], | 52 | P: [tfs.togglePorts, 'Toggle Port Highlighting'], |
53 | + dash: [tfs.showBadLinks, 'Show bad links'], | ||
54 | + B: [toggleMap, 'Toggle background map'], | ||
54 | 55 | ||
55 | //X: [toggleNodeLock, 'Lock / unlock node positions'], | 56 | //X: [toggleNodeLock, 'Lock / unlock node positions'], |
56 | Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'], | 57 | Z: [tos.toggleOblique, 'Toggle oblique view (Experimental)'], |
... | @@ -73,7 +74,7 @@ | ... | @@ -73,7 +74,7 @@ |
73 | _keyListener: ttbs.keyListener, | 74 | _keyListener: ttbs.keyListener, |
74 | 75 | ||
75 | _helpFormat: [ | 76 | _helpFormat: [ |
76 | - ['I', 'O', 'D', '-', 'H', 'M', 'P', 'B' ], | 77 | + ['I', 'O', 'D', '-', 'H', 'M', 'P', 'dash', 'B' ], |
77 | ['X', 'Z', 'L', 'U', 'R', '-', 'dot'], | 78 | ['X', 'Z', 'L', 'U', 'R', '-', 'dot'], |
78 | ['V', 'rightArrow', 'leftArrow', 'W', 'A', 'F', '-', 'E' ] | 79 | ['V', 'rightArrow', 'leftArrow', 'W', 'A', 'F', '-', 'E' ] |
79 | ] | 80 | ] | ... | ... |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | 'use strict'; | 23 | 'use strict'; |
24 | 24 | ||
25 | // injected refs | 25 | // injected refs |
26 | - var $log, fs, sus, is, ts, flash, wss, | 26 | + var $log, $timeout, fs, sus, is, ts, flash, wss, |
27 | tis, tms, td3, tss, tts, tos, fltr, tls, | 27 | tis, tms, td3, tss, tts, tos, fltr, tls, |
28 | icfg, uplink, svg; | 28 | icfg, uplink, svg; |
29 | 29 | ||
... | @@ -263,6 +263,7 @@ | ... | @@ -263,6 +263,7 @@ |
263 | online = ldata.online(), | 263 | online = ldata.online(), |
264 | delay = immediate ? 0 : 1000; | 264 | delay = immediate ? 0 : 1000; |
265 | 265 | ||
266 | + // TODO: understand why el is sometimes undefined on addLink events... | ||
266 | el.classed('link', true); | 267 | el.classed('link', true); |
267 | el.classed('inactive', !online); | 268 | el.classed('inactive', !online); |
268 | el.classed(allLinkTypes, false); | 269 | el.classed(allLinkTypes, false); |
... | @@ -450,6 +451,21 @@ | ... | @@ -450,6 +451,21 @@ |
450 | // d3.selectAll('svg .portText').classed('inactive', b); | 451 | // d3.selectAll('svg .portText').classed('inactive', b); |
451 | } | 452 | } |
452 | 453 | ||
454 | + function showBadLinks() { | ||
455 | + var badLinks = tms.findBadLinks(); | ||
456 | + flash.flash('Bad Links: ' + badLinks.length); | ||
457 | + $log.debug('Bad Link List (' + badLinks.length + '):'); | ||
458 | + badLinks.forEach(function (d) { | ||
459 | + $log.debug('bad link: (' + d.bad + ') ' + d.key, d); | ||
460 | + if (d.el) { | ||
461 | + d.el.attr('stroke-width', linkScale(2.8)) | ||
462 | + .attr('stroke', 'red'); | ||
463 | + } | ||
464 | + }); | ||
465 | + // back to normal after 2 seconds... | ||
466 | + $timeout(updateLinks, 2000); | ||
467 | + } | ||
468 | + | ||
453 | // ========================================== | 469 | // ========================================== |
454 | 470 | ||
455 | function updateNodes() { | 471 | function updateNodes() { |
... | @@ -749,15 +765,16 @@ | ... | @@ -749,15 +765,16 @@ |
749 | 765 | ||
750 | angular.module('ovTopo') | 766 | angular.module('ovTopo') |
751 | .factory('TopoForceService', | 767 | .factory('TopoForceService', |
752 | - ['$log', 'FnService', 'SvgUtilService', 'IconService', 'ThemeService', | 768 | + ['$log', '$timeout', 'FnService', 'SvgUtilService', 'IconService', |
753 | - 'FlashService', 'WebSocketService', | 769 | + 'ThemeService', 'FlashService', 'WebSocketService', |
754 | 'TopoInstService', 'TopoModelService', | 770 | 'TopoInstService', 'TopoModelService', |
755 | 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService', | 771 | 'TopoD3Service', 'TopoSelectService', 'TopoTrafficService', |
756 | 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService', | 772 | 'TopoObliqueService', 'TopoFilterService', 'TopoLinkService', |
757 | 773 | ||
758 | - function (_$log_, _fs_, _sus_, _is_, _ts_, _flash_, _wss_, | 774 | + function (_$log_, _$timeout_, _fs_, _sus_, _is_, _ts_, _flash_, _wss_, |
759 | _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_) { | 775 | _tis_, _tms_, _td3_, _tss_, _tts_, _tos_, _fltr_, _tls_) { |
760 | $log = _$log_; | 776 | $log = _$log_; |
777 | + $timeout = _$timeout_; | ||
761 | fs = _fs_; | 778 | fs = _fs_; |
762 | sus = _sus_; | 779 | sus = _sus_; |
763 | is = _is_; | 780 | is = _is_; |
... | @@ -874,6 +891,7 @@ | ... | @@ -874,6 +891,7 @@ |
874 | cycleDeviceLabels: cycleDeviceLabels, | 891 | cycleDeviceLabels: cycleDeviceLabels, |
875 | unpin: unpin, | 892 | unpin: unpin, |
876 | showMastership: showMastership, | 893 | showMastership: showMastership, |
894 | + showBadLinks: showBadLinks, | ||
877 | 895 | ||
878 | addDevice: addDevice, | 896 | addDevice: addDevice, |
879 | updateDevice: updateDevice, | 897 | updateDevice: updateDevice, | ... | ... |
... | @@ -341,15 +341,37 @@ | ... | @@ -341,15 +341,37 @@ |
341 | } | 341 | } |
342 | 342 | ||
343 | function findAttachedLinks(devId) { | 343 | function findAttachedLinks(devId) { |
344 | - var links = []; | 344 | + var lnks = []; |
345 | links.forEach(function (d) { | 345 | links.forEach(function (d) { |
346 | if (d.source.id === devId || d.target.id === devId) { | 346 | if (d.source.id === devId || d.target.id === devId) { |
347 | - links.push(d); | 347 | + lnks.push(d); |
348 | } | 348 | } |
349 | }); | 349 | }); |
350 | - return links; | 350 | + return lnks; |
351 | } | 351 | } |
352 | 352 | ||
353 | + // returns one-way links or where the internal link types differ | ||
354 | + function findBadLinks() { | ||
355 | + var lnks = [], | ||
356 | + src, tgt; | ||
357 | + links.forEach(function (d) { | ||
358 | + // NOTE: skip edge links, which are synthesized | ||
359 | + if (d.type() !== 'hostLink') { | ||
360 | + delete d.bad; | ||
361 | + src = d.fromSource; | ||
362 | + tgt = d.fromTarget; | ||
363 | + if (src && !tgt) { | ||
364 | + d.bad = 'missing link'; | ||
365 | + } else if (src.type !== tgt.type) { | ||
366 | + d.bad = 'type mismatch'; | ||
367 | + } | ||
368 | + if (d.bad) { | ||
369 | + lnks.push(d); | ||
370 | + } | ||
371 | + } | ||
372 | + }); | ||
373 | + return lnks; | ||
374 | + } | ||
353 | 375 | ||
354 | // ========================== | 376 | // ========================== |
355 | // Module definition | 377 | // Module definition |
... | @@ -394,7 +416,8 @@ | ... | @@ -394,7 +416,8 @@ |
394 | findLinkById: findLinkById, | 416 | findLinkById: findLinkById, |
395 | findDevices: findDevices, | 417 | findDevices: findDevices, |
396 | findAttachedHosts: findAttachedHosts, | 418 | findAttachedHosts: findAttachedHosts, |
397 | - findAttachedLinks: findAttachedLinks | 419 | + findAttachedLinks: findAttachedLinks, |
420 | + findBadLinks: findBadLinks | ||
398 | } | 421 | } |
399 | }]); | 422 | }]); |
400 | }()); | 423 | }()); | ... | ... |
-
Please register or login to post a comment