MaheshRaju-Huawei
Committed by Gerrit Code Review

PCE WEB GUI defect fixes

Change-Id: I6da200db4c946708df97d1fa35ae198ea68f0451
...@@ -28,8 +28,6 @@ import org.onosproject.net.ElementId; ...@@ -28,8 +28,6 @@ import org.onosproject.net.ElementId;
28 import org.onosproject.net.HostId; 28 import org.onosproject.net.HostId;
29 import org.onosproject.net.Link; 29 import org.onosproject.net.Link;
30 import org.onosproject.net.Path; 30 import org.onosproject.net.Path;
31 -import org.onosproject.net.topology.TopologyEvent;
32 -import org.onosproject.net.topology.TopologyListener;
33 import org.onosproject.net.topology.TopologyService; 31 import org.onosproject.net.topology.TopologyService;
34 import org.onosproject.ui.RequestHandler; 32 import org.onosproject.ui.RequestHandler;
35 import org.onosproject.ui.UiConnection; 33 import org.onosproject.ui.UiConnection;
...@@ -51,6 +49,7 @@ import org.slf4j.Logger; ...@@ -51,6 +49,7 @@ import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory; 49 import org.slf4j.LoggerFactory;
52 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; 50 import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
53 import org.onosproject.incubator.net.tunnel.Tunnel; 51 import org.onosproject.incubator.net.tunnel.Tunnel;
52 +import static org.onosproject.incubator.net.tunnel.Tunnel.State.ACTIVE;
54 import org.onosproject.incubator.net.tunnel.TunnelEndPoint; 53 import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
55 import org.onosproject.incubator.net.tunnel.TunnelEvent; 54 import org.onosproject.incubator.net.tunnel.TunnelEvent;
56 import org.onosproject.incubator.net.tunnel.TunnelId; 55 import org.onosproject.incubator.net.tunnel.TunnelId;
...@@ -82,6 +81,8 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -82,6 +81,8 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
82 private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem"; 81 private static final String PCEWEB_SHOW_TUNNEL_REMOVE = "pceTopovShowTunnelsRem";
83 private static final String PCEWEB_TUNNEL_UPDATE_INFO = "updatePathmsgInfo"; 82 private static final String PCEWEB_TUNNEL_UPDATE_INFO = "updatePathmsgInfo";
84 private static final String PCEWEB_TUNNEL_UPDATE_INFO_REPLY = "pceTopovShowTunnelsUpdate"; 83 private static final String PCEWEB_TUNNEL_UPDATE_INFO_REPLY = "pceTopovShowTunnelsUpdate";
84 + private static final String PCEWEB_TUNNEL_QUERY_INFO = "pceTopovShowTunnelsQuery";
85 + private static final String PCEWEB_TUNNEL_QUERY_INFO_SHOW = "pceTopovshowTunnelHighlightMsg";
85 private static final String DST = "DST"; 86 private static final String DST = "DST";
86 private static final String SRC = "SRC"; 87 private static final String SRC = "SRC";
87 private static final String BANDWIDTH = "bw"; 88 private static final String BANDWIDTH = "bw";
...@@ -117,7 +118,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -117,7 +118,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
117 private int pathIndex; 118 private int pathIndex;
118 119
119 private final Logger log = LoggerFactory.getLogger(getClass()); 120 private final Logger log = LoggerFactory.getLogger(getClass());
120 - private final TopologyListener topologyListener = new InternalTopologyListener();
121 private final TunnelListener tunnelListener = new InnerPceWebTunnelListener(); 121 private final TunnelListener tunnelListener = new InnerPceWebTunnelListener();
122 122
123 protected TopologyService topologyService; 123 protected TopologyService topologyService;
...@@ -128,11 +128,9 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -128,11 +128,9 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
128 public void init(UiConnection connection, ServiceDirectory directory) { 128 public void init(UiConnection connection, ServiceDirectory directory) {
129 129
130 super.init(connection, directory); 130 super.init(connection, directory);
131 - topologyService = directory.get(TopologyService.class);
132 tunnelService = directory.get(TunnelService.class); 131 tunnelService = directory.get(TunnelService.class);
133 pceService = directory.get(PceService.class); 132 pceService = directory.get(PceService.class);
134 deviceService = directory.get(DeviceService.class); 133 deviceService = directory.get(DeviceService.class);
135 - topologyService.addListener(topologyListener);
136 tunnelService.addListener(tunnelListener); 134 tunnelService.addListener(tunnelListener);
137 } 135 }
138 136
...@@ -146,12 +144,12 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -146,12 +144,12 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
146 new RemovePathQueryHandler(), 144 new RemovePathQueryHandler(),
147 new RemovePathHandler(), 145 new RemovePathHandler(),
148 new UpdatePathInfoHandler(), 146 new UpdatePathInfoHandler(),
149 - new ShowTunnelHandler()); 147 + new ShowTunnelHandler(),
148 + new ShowTunnelHighlight());
150 } 149 }
151 150
152 @Override 151 @Override
153 public void destroy() { 152 public void destroy() {
154 - topologyService.removeListener(topologyListener);
155 tunnelService.removeListener(tunnelListener); 153 tunnelService.removeListener(tunnelListener);
156 super.destroy(); 154 super.destroy();
157 } 155 }
...@@ -247,7 +245,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -247,7 +245,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
247 ArrayNode arrayNode = arrayNode(); 245 ArrayNode arrayNode = arrayNode();
248 for (Tunnel tunnel : tunnelSet) { 246 for (Tunnel tunnel : tunnelSet) {
249 if (tunnel.type() == MPLS) { 247 if (tunnel.type() == MPLS) {
250 - arrayNode.add(tunnel.tunnelId().toString()); 248 + if (tunnel.state().equals(ACTIVE)) {
249 + arrayNode.add(tunnel.tunnelId().toString());
250 + arrayNode.add(tunnel.tunnelName().toString());
251 + }
251 } 252 }
252 } 253 }
253 254
...@@ -295,6 +296,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -295,6 +296,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
295 296
296 if (tunnelIdStr == null) { 297 if (tunnelIdStr == null) {
297 log.error("PCE update path is failed."); 298 log.error("PCE update path is failed.");
299 + return;
298 } 300 }
299 301
300 if (tunnelIdStr.equals(STRING_NULL)) { 302 if (tunnelIdStr.equals(STRING_NULL)) {
...@@ -354,7 +356,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -354,7 +356,10 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
354 356
355 for (Tunnel tunnel : tunnelSet) { 357 for (Tunnel tunnel : tunnelSet) {
356 if (tunnel.type() == MPLS) { 358 if (tunnel.type() == MPLS) {
357 - arrayNode.add(tunnel.tunnelId().toString()); 359 + if (tunnel.state().equals(ACTIVE)) {
360 + arrayNode.add(tunnel.tunnelId().toString());
361 + arrayNode.add(tunnel.tunnelName().toString());
362 + }
358 } 363 }
359 } 364 }
360 365
...@@ -395,7 +400,56 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -395,7 +400,56 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
395 400
396 @Override 401 @Override
397 public void process(long sid, ObjectNode payload) { 402 public void process(long sid, ObjectNode payload) {
398 - findTunnelAndHighlights(); 403 + ObjectNode result = objectNode();
404 + ArrayNode arrayNode = arrayNode();
405 + Collection<Tunnel> tunnelSet = null;
406 +
407 + tunnelSet = tunnelService.queryTunnel(MPLS);
408 + for (Tunnel tunnel : tunnelSet) {
409 + if (tunnel.state().equals(ACTIVE)) {
410 + arrayNode.add(tunnel.tunnelId().toString());
411 + arrayNode.add(tunnel.tunnelName().toString());
412 + }
413 + }
414 +
415 + result.putArray(BUFFER_ARRAY).addAll(arrayNode);
416 + sendMessage(PCEWEB_TUNNEL_QUERY_INFO, sid, result);
417 + }
418 + }
419 +
420 + /**
421 + * Handles the 'show the existed tunnels' event received from the client.
422 + */
423 + private final class ShowTunnelHighlight extends RequestHandler {
424 +
425 + public ShowTunnelHighlight() {
426 + super(PCEWEB_TUNNEL_QUERY_INFO_SHOW);
427 + }
428 +
429 + @Override
430 + public void process(long sid, ObjectNode payload) {
431 + String tunnelIdStr = string(payload, TUNNEL_ID);
432 +
433 + if (tunnelIdStr == null) {
434 + log.error("Tunnel Id is NULL.");
435 + return;
436 + }
437 +
438 + if (tunnelIdStr.equals(STRING_NULL)) {
439 + log.error("Tunnel Id is NULL.");
440 + return;
441 + }
442 +
443 + if (pceService == null) {
444 + log.error("PCE service is not active");
445 + return;
446 + }
447 +
448 + TunnelId tunnelId = TunnelId.valueOf(tunnelIdStr);
449 + Tunnel tunnel = tunnelService.queryTunnel(tunnelId);
450 + if (tunnel != null) {
451 + highlightsForTunnel(tunnel);
452 + }
399 } 453 }
400 } 454 }
401 455
...@@ -458,7 +512,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -458,7 +512,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
458 * @param bandWidth bandWidth 512 * @param bandWidth bandWidth
459 * @param bandWidthType is the kbps or mbps 513 * @param bandWidthType is the kbps or mbps
460 * @param costType is igp or te 514 * @param costType is igp or te
461 - * @param tunnelName tunnel id 515 + * @param tunnelIdStr tunnel id
462 */ 516 */
463 private void findAndSendPathsUpdate(String bandWidth, String bandWidthType, String costType, String tunnelIdStr) { 517 private void findAndSendPathsUpdate(String bandWidth, String bandWidthType, String costType, String tunnelIdStr) {
464 if (tunnelIdStr != null) { 518 if (tunnelIdStr != null) {
...@@ -489,7 +543,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -489,7 +543,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
489 /** 543 /**
490 * Handles the remove path and highlights the paths if existed. 544 * Handles the remove path and highlights the paths if existed.
491 * 545 *
492 - * @param tunnelIdName tunnelId 546 + * @param tunnelIdStr tunnelId
493 */ 547 */
494 private void findAndSendPathsRemove(String tunnelIdStr) { 548 private void findAndSendPathsRemove(String tunnelIdStr) {
495 if (tunnelIdStr != null) { 549 if (tunnelIdStr != null) {
...@@ -519,7 +573,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -519,7 +573,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
519 * @param bandWidth bandWidth 573 * @param bandWidth bandWidth
520 * @param bandWidthType is the kbps or mbps 574 * @param bandWidthType is the kbps or mbps
521 * @param costType is igp or te 575 * @param costType is igp or te
522 - * @param listConstrnt list of constraints
523 * @return 576 * @return
524 */ 577 */
525 private List<Constraint> addBandwidthCostTypeConstraints(String bandWidth, 578 private List<Constraint> addBandwidthCostTypeConstraints(String bandWidth,
...@@ -622,16 +675,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -622,16 +675,6 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
622 } 675 }
623 676
624 /** 677 /**
625 - * Handles the event of topology listeners.
626 - */
627 - private class InternalTopologyListener implements TopologyListener {
628 - @Override
629 - public void event(TopologyEvent event) {
630 - findTunnelAndHighlights();
631 - }
632 - }
633 -
634 - /**
635 * Handles the event of tunnel listeners. 678 * Handles the event of tunnel listeners.
636 */ 679 */
637 private class InnerPceWebTunnelListener implements TunnelListener { 680 private class InnerPceWebTunnelListener implements TunnelListener {
...@@ -639,7 +682,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -639,7 +682,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
639 public void event(TunnelEvent event) { 682 public void event(TunnelEvent event) {
640 Tunnel tunnel = event.subject(); 683 Tunnel tunnel = event.subject();
641 if (tunnel.type() == MPLS) { 684 if (tunnel.type() == MPLS) {
642 - findTunnelAndHighlights(); 685 + highlightsForTunnel(tunnel);
643 } 686 }
644 } 687 }
645 } 688 }
...@@ -664,7 +707,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -664,7 +707,7 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
664 sendMessage(TopoJson.highlightsMessage(highlights)); 707 sendMessage(TopoJson.highlightsMessage(highlights));
665 return; 708 return;
666 } 709 }
667 - if (!tunnel.state().equals(Tunnel.State.ACTIVE)) { 710 + if (!tunnel.state().equals(ACTIVE)) {
668 log.debug("Tunnel state is not active"); 711 log.debug("Tunnel state is not active");
669 sendMessage(TopoJson.highlightsMessage(highlights)); 712 sendMessage(TopoJson.highlightsMessage(highlights));
670 return; 713 return;
...@@ -688,4 +731,40 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { ...@@ -688,4 +731,40 @@ public class PceWebTopovMessageHandler extends UiMessageHandler {
688 allPathLinks = buildPaths(builder).build(); 731 allPathLinks = buildPaths(builder).build();
689 hilightAndSendPaths(highlights); 732 hilightAndSendPaths(highlights);
690 } 733 }
734 +
735 + /**
736 + * Handles the event of topology listeners.
737 + */
738 + private void highlightsForTunnel(Tunnel tunnel) {
739 + Highlights highlights = new Highlights();
740 + paths.removeAll(paths);
741 + if (tunnel.path() == null) {
742 + log.error("path does not exist");
743 + sendMessage(TopoJson.highlightsMessage(highlights));
744 + return;
745 + }
746 + if (!tunnel.state().equals(ACTIVE)) {
747 + log.debug("Tunnel state is not active");
748 + sendMessage(TopoJson.highlightsMessage(highlights));
749 + return;
750 + }
751 +
752 + Link firstLink = tunnel.path().links().get(0);
753 + if (firstLink != null) {
754 + if (firstLink.src() != null) {
755 + highlights = addBadge(highlights, firstLink.src().deviceId().toString(), SRC);
756 + }
757 + }
758 + Link lastLink = tunnel.path().links().get(tunnel.path().links().size() - 1);
759 + if (lastLink != null) {
760 + if (lastLink.dst() != null) {
761 + highlights = addBadge(highlights, lastLink.dst().deviceId().toString(), DST);
762 + }
763 + }
764 + paths.add(tunnel.path());
765 +
766 + ImmutableSet.Builder<Link> builder = ImmutableSet.builder();
767 + allPathLinks = buildPaths(builder).build();
768 + hilightAndSendPaths(highlights);
769 + }
691 } 770 }
......
...@@ -21,24 +21,24 @@ import java.util.HashMap; ...@@ -21,24 +21,24 @@ import java.util.HashMap;
21 import java.util.Map; 21 import java.util.Map;
22 import java.util.Set; 22 import java.util.Set;
23 23
24 -import org.onlab.util.Bandwidth;
25 import org.onosproject.net.AnnotationKeys; 24 import org.onosproject.net.AnnotationKeys;
26 import org.onosproject.net.Annotations; 25 import org.onosproject.net.Annotations;
27 import org.onosproject.net.Device; 26 import org.onosproject.net.Device;
28 import org.onosproject.net.DeviceId; 27 import org.onosproject.net.DeviceId;
29 import org.onosproject.net.Link; 28 import org.onosproject.net.Link;
29 +import org.onosproject.net.resource.ContinuousResource;
30 +import org.onosproject.net.resource.ResourceService;
31 +import org.onosproject.net.resource.Resource;
32 +import org.onosproject.net.resource.DiscreteResource;
33 +import org.onosproject.net.resource.Resources;
30 import org.onosproject.ui.UiTopoOverlay; 34 import org.onosproject.ui.UiTopoOverlay;
31 import org.onosproject.ui.topo.PropertyPanel; 35 import org.onosproject.ui.topo.PropertyPanel;
32 import org.onosproject.net.device.DeviceService; 36 import org.onosproject.net.device.DeviceService;
33 import org.onosproject.net.link.LinkEvent; 37 import org.onosproject.net.link.LinkEvent;
34 -import org.onosproject.net.resource.ContinuousResource;
35 -import org.onosproject.net.resource.DiscreteResource;
36 -import org.onosproject.net.resource.Resource;
37 -import org.onosproject.net.resource.ResourceService;
38 -import org.onosproject.net.resource.Resources;
39 import org.onosproject.ui.topo.TopoConstants.CoreButtons; 38 import org.onosproject.ui.topo.TopoConstants.CoreButtons;
40 import org.onosproject.cli.AbstractShellCommand; 39 import org.onosproject.cli.AbstractShellCommand;
41 - 40 +import org.onlab.packet.Ip4Address;
41 +import org.onlab.packet.IpAddress;
42 /** 42 /**
43 * PCE WEB topology overlay. 43 * PCE WEB topology overlay.
44 */ 44 */
...@@ -49,11 +49,16 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -49,11 +49,16 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
49 private static final String MY_TITLE = "Device details"; 49 private static final String MY_TITLE = "Device details";
50 50
51 public static final String AS_NUMBER = "asNumber"; 51 public static final String AS_NUMBER = "asNumber";
52 - public static final String DOMAIN_IDENTIFIER = "domainIdentifier"; 52 + public static final String LSR_ID = "lsrId";
53 public static final String ABR_BIT = "abrBit"; 53 public static final String ABR_BIT = "abrBit";
54 public static final String ASBR_BIT = "externalBit"; 54 public static final String ASBR_BIT = "externalBit";
55 public static final String TE_METRIC = "teCost"; 55 public static final String TE_METRIC = "teCost";
56 - 56 + public static final String ABR = "ABR";
57 + public static final String ASBR = "ASBR";
58 + public static final String ABR_ASBR = "ABR/ASBR";
59 + public static final String INNER = "Inner";
60 + public static final long IDENTIFIER_SET = 0x100000000L;
61 + public static final long SET = 0xFFFFFFFFL;
57 /** 62 /**
58 * Initialize the overlay ID. 63 * Initialize the overlay ID.
59 */ 64 */
...@@ -71,11 +76,8 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -71,11 +76,8 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
71 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { 76 public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
72 77
73 pp.title(MY_TITLE); 78 pp.title(MY_TITLE);
74 -
75 DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); 79 DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
76 -
77 pp.removeAllProps(); 80 pp.removeAllProps();
78 -
79 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW) 81 pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
80 .removeButtons(CoreButtons.SHOW_GROUP_VIEW) 82 .removeButtons(CoreButtons.SHOW_GROUP_VIEW)
81 .removeButtons(CoreButtons.SHOW_METER_VIEW); 83 .removeButtons(CoreButtons.SHOW_METER_VIEW);
...@@ -85,10 +87,9 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -85,10 +87,9 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
85 Device device = deviceService.getDevice(deviceId); 87 Device device = deviceService.getDevice(deviceId);
86 Annotations annots = device.annotations(); 88 Annotations annots = device.annotations();
87 89
88 - String routerId = annots.value(AnnotationKeys.ROUTER_ID);
89 String type = annots.value(AnnotationKeys.TYPE); 90 String type = annots.value(AnnotationKeys.TYPE);
90 String asNumber = annots.value(AS_NUMBER); 91 String asNumber = annots.value(AS_NUMBER);
91 - String domain = annots.value(DOMAIN_IDENTIFIER); 92 + String lsrId = annots.value(LSR_ID);
92 String abrStatus = annots.value(ABR_BIT); 93 String abrStatus = annots.value(ABR_BIT);
93 String asbrStatus = annots.value(ASBR_BIT); 94 String asbrStatus = annots.value(ASBR_BIT);
94 95
...@@ -96,24 +97,22 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -96,24 +97,22 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
96 pp.addProp("Type", type); 97 pp.addProp("Type", type);
97 } 98 }
98 99
99 - if (routerId != null) {
100 - pp.addProp("Router-ID", routerId);
101 - }
102 -
103 if (asNumber != null) { 100 if (asNumber != null) {
104 pp.addProp("AS Number", asNumber); 101 pp.addProp("AS Number", asNumber);
105 } 102 }
106 103
107 - if (domain != null) { 104 + if (lsrId != null) {
108 - pp.addProp("Domain ID", domain); 105 + pp.addProp("LSR ID", lsrId);
109 - }
110 -
111 - if (abrStatus != null) {
112 - pp.addProp("ABR Role", abrStatus);
113 } 106 }
114 107
115 - if (asbrStatus != null) { 108 + if (abrStatus.equals(true) && asbrStatus.equals(true)) {
116 - pp.addProp("ASBR Role", asbrStatus); 109 + pp.addProp("Position", ABR_ASBR);
110 + } else if (abrStatus.equals(true)) {
111 + pp.addProp("Position", ABR);
112 + } else if (asbrStatus.equals(true)) {
113 + pp.addProp("Position", ASBR);
114 + } else {
115 + pp.addProp("Position", INNER);
117 } 116 }
118 } 117 }
119 } 118 }
...@@ -122,30 +121,62 @@ public class PceWebTopovOverlay extends UiTopoOverlay { ...@@ -122,30 +121,62 @@ public class PceWebTopovOverlay extends UiTopoOverlay {
122 public Map<String, String> additionalLinkData(LinkEvent event) { 121 public Map<String, String> additionalLinkData(LinkEvent event) {
123 Map<String, String> map = new HashMap<>(); 122 Map<String, String> map = new HashMap<>();
124 Link link = event.subject(); 123 Link link = event.subject();
124 + long srcPortNo;
125 + long dstPortNo;
126 + IpAddress ipDstAddress = null;
127 + IpAddress ipSrcAddress = null;
128 + String srcPort;
129 + String dstPort;
130 + String bandWidth;
131 +
132 + srcPortNo = link.src().port().toLong();
133 + if (((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET)) {
134 + srcPort = String.valueOf(srcPortNo);
135 + } else {
136 + ipSrcAddress = Ip4Address.valueOf((int) srcPortNo);
137 + srcPort = ipSrcAddress.toString();
138 + }
139 +
140 + dstPortNo = link.dst().port().toLong();
141 + if (((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET)) {
142 + dstPort = String.valueOf(dstPortNo);
143 + } else {
144 + ipDstAddress = Ip4Address.valueOf((int) dstPortNo);
145 + dstPort = ipDstAddress.toString();
146 + }
125 147
126 - map.put("Src port", link.src().port().toString()); 148 + map.put("Src Address", srcPort);
127 - map.put("Dst port", link.dst().port().toString()); 149 + map.put("Dst Address", dstPort);
128 map.put("Te metric", link.annotations().value(TE_METRIC)); 150 map.put("Te metric", link.annotations().value(TE_METRIC));
129 151
130 ResourceService resService = AbstractShellCommand.get(ResourceService.class); 152 ResourceService resService = AbstractShellCommand.get(ResourceService.class);
131 DiscreteResource devResource = Resources.discrete(link.src().deviceId(), link.src().port()).resource(); 153 DiscreteResource devResource = Resources.discrete(link.src().deviceId(), link.src().port()).resource();
132 if (resService == null) { 154 if (resService == null) {
133 - log.warn("resource service does not exist "); 155 + log.warn("resource service does not exist");
134 return map; 156 return map;
135 } 157 }
136 158
137 if (devResource == null) { 159 if (devResource == null) {
138 - log.warn("Device resources does not exist "); 160 + log.warn("Device resources does not exist");
139 return map; 161 return map;
140 } 162 }
141 - Set<Resource> resources = resService.getAvailableResources(devResource.id(), Bandwidth.class); 163 + double regBandwidth = 0;
142 - if (resources.isEmpty()) { 164 + try {
143 - log.warn("Bandwidth resources does not exist "); 165 + Thread.sleep(100);
144 - return map; 166 + } catch (InterruptedException e) {
167 + log.error("Exception occured while getting the bandwidth.");
168 + }
169 + Set<Resource> resources = resService.getRegisteredResources(devResource.id());
170 + for (Resource res : resources) {
171 + if (res instanceof ContinuousResource) {
172 + regBandwidth = ((ContinuousResource) res).value();
173 + break;
174 + }
145 } 175 }
146 176
147 - if (resources.iterator().next() instanceof ContinuousResource) { 177 + if (regBandwidth != 0) {
148 - map.put("Bandwidth", ((ContinuousResource) resources.iterator().next()).toString()); 178 + bandWidth = String.valueOf(regBandwidth);
179 + map.put("Bandwidth", bandWidth);
149 } 180 }
150 181
151 return map; 182 return map;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 21
22 // injected refs 22 // injected refs
23 var $log, fs, flash, wss, tps, ns, tds, ds; 23 var $log, fs, flash, wss, tps, ns, tds, ds;
24 - var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd; 24 + var tunnelNameData, tunnelNameDataRemove, tunnelDataUpdateInfo, tunnelIdUpd, tunnelNameDataQuery;
25 // constants 25 // constants
26 var srcMessage = 'pceTopovSetSrc', 26 var srcMessage = 'pceTopovSetSrc',
27 dstMessage = 'pceTopovSetDst', 27 dstMessage = 'pceTopovSetDst',
...@@ -35,11 +35,15 @@ ...@@ -35,11 +35,15 @@
35 showTunnelInfoMsg = 'pceTopovShowTunnels', 35 showTunnelInfoMsg = 'pceTopovShowTunnels',
36 queryDisplayTunnelMsg = 'pceTopovTunnelDisplay', 36 queryDisplayTunnelMsg = 'pceTopovTunnelDisplay',
37 showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem', 37 showTunnelInfoRemoveMsg = 'pceTopovShowTunnelsRem',
38 - showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate'; 38 + showTunnelInfoUpdateMsg = 'pceTopovShowTunnelsUpdate',
39 + showTunnelInfoQuery = 'pceTopovShowTunnelsQuery',
40 + showTunnelHighlightMsg = 'pceTopovshowTunnelHighlightMsg';
41 +
39 // internal state 42 // internal state
40 var currentMode = null; 43 var currentMode = null;
41 var handlerMap = {}, 44 var handlerMap = {},
42 handlerMapRem = {}, 45 handlerMapRem = {},
46 + handlerMapshowQuery = {},
43 handlerMapShowUpdate = {}; 47 handlerMapShowUpdate = {};
44 // === --------------------------- 48 // === ---------------------------
45 // === Helper functions 49 // === Helper functions
...@@ -92,6 +96,7 @@ ...@@ -92,6 +96,7 @@
92 id: id 96 id: id
93 }); 97 });
94 } 98 }
99 +
95 p.append('span').text(nameField); 100 p.append('span').text(nameField);
96 p.append('br'); 101 p.append('br');
97 } 102 }
...@@ -107,13 +112,15 @@ ...@@ -107,13 +112,15 @@
107 addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio'); 112 addAttribute('pce-cost-type-valname', 'pce-cost-type-igp', 'IGP', 'radio');
108 addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio'); 113 addAttribute('pce-cost-type-valname', 'pce-cost-type-te', 'TE', 'radio');
109 //Add the LSP type related inputs. 114 //Add the LSP type related inputs.
110 - addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type', 'checkbox'); 115 + addAttribute('pce-lsp-type-name', 'pce-lsp-type', 'Lsp Type *', 'checkbox');
111 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio'); 116 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-cr', 'With signalling', 'radio');
112 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio'); 117 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srbe', 'Without SR without signalling', 'radio');
113 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio'); 118 addAttribute('pce-lsp-type-valname', 'pce-lsp-type-srte', 'With SR without signalling', 'radio');
114 //Add the tunnel name 119 //Add the tunnel name
115 - addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', 'Tunnel Name', 'text'); 120 + p.append('span').text("Tunnel Name *");
116 - 121 + p.append('br');
122 + addAttribute('pce-tunnel-name', 'pce-tunnel-name-id', null, 'text');
123 + p.append('span').text("* indicates mandatory fields");
117 return content; 124 return content;
118 } 125 }
119 126
...@@ -125,19 +132,17 @@ ...@@ -125,19 +132,17 @@
125 p.append('span').text('Tunnel IDs'); 132 p.append('span').text('Tunnel IDs');
126 p.append('br'); 133 p.append('br');
127 134
128 - data.a.forEach( function (val, idx) { 135 + for (var idx = 0; idx < data.a.length; idx++) {
129 p.append('input').attr({ 136 p.append('input').attr({
130 id: 'tunnel-id-'+idx, 137 id: 'tunnel-id-'+idx,
131 type: 'radio', 138 type: 'radio',
132 name: 'tunnel-id-name', 139 name: 'tunnel-id-name',
133 - value: val 140 + value: data.a[idx]
134 }); 141 });
135 - 142 + idx++;
136 - p.append('span').text(val); 143 + p.append('span').text(data.a[idx]);
137 p.append('br'); 144 p.append('br');
138 - 145 + }
139 - } );
140 -
141 return content; 146 return content;
142 } 147 }
143 148
...@@ -192,7 +197,9 @@ ...@@ -192,7 +197,9 @@
192 } 197 }
193 198
194 if (constType == 'BW') { 199 if (constType == 'BW') {
195 - addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox'); 200 + //addAttribute('band-width-name', 'update-band-width-box', 'Band Width', 'checkbox');
201 + p.append('span').text('Band Width');
202 + p.append('br');
196 p.append('input').attr({ 203 p.append('input').attr({
197 id: 'update-band-width-value', 204 id: 'update-band-width-value',
198 type: 'number', 205 type: 'number',
...@@ -211,10 +218,13 @@ ...@@ -211,10 +218,13 @@
211 p.append('br'); 218 p.append('br');
212 addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio'); 219 addAttribute('pce-band-type', 'update-band-kbps-val', 'kbps', 'radio');
213 addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio'); 220 addAttribute('pce-band-type', 'update-band-mbps-val', 'mbps', 'radio');
221 + addAttribute('pce-band-type', 'update-band-none-val', 'none', 'radio');
214 } 222 }
215 223
216 if (constType == 'CT') { 224 if (constType == 'CT') {
217 - addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox'); 225 + //addAttribute('pce-cost-type', 'update-pce-cost-type', 'Cost Type', 'checkbox');
226 + p.append('span').text('Cost Type');
227 + p.append('br');
218 if (val == 'COST') { 228 if (val == 'COST') {
219 p.append('input').attr({ 229 p.append('input').attr({
220 id: 'update-pce-cost-type-igp', 230 id: 'update-pce-cost-type-igp',
...@@ -226,6 +236,7 @@ ...@@ -226,6 +236,7 @@
226 p.append('span').text('IGP'); 236 p.append('span').text('IGP');
227 p.append('br'); 237 p.append('br');
228 addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio'); 238 addAttribute('pce-cost-type-value', 'update-pce-cost-type-te', 'TE', 'radio');
239 + addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
229 240
230 } else { 241 } else {
231 addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio'); 242 addAttribute('pce-cost-type-value', 'update-pce-cost-type-igp', 'IGP', 'radio');
...@@ -238,6 +249,7 @@ ...@@ -238,6 +249,7 @@
238 }); 249 });
239 p.append('span').text('TE'); 250 p.append('span').text('TE');
240 p.append('br'); 251 p.append('br');
252 + addAttribute('pce-cost-type-value', 'update-pce-cost-type-none', 'none', 'radio');
241 } 253 }
242 } 254 }
243 } ); 255 } );
...@@ -251,24 +263,47 @@ ...@@ -251,24 +263,47 @@
251 form = content.append('form'), 263 form = content.append('form'),
252 p = form.append('p'); 264 p = form.append('p');
253 265
254 - p.append('span').text('Tunnel IDs'); 266 + p.append('span').text('Tunnels');
255 p.append('br'); 267 p.append('br');
256 268
257 - data.a.forEach( function (val, idx) { 269 + for (var idx = 0; idx < data.a.length; idx++) {
258 p.append('input').attr({ 270 p.append('input').attr({
259 id: 'tunnel-id-remove-'+idx, 271 id: 'tunnel-id-remove-'+idx,
260 type: 'checkbox', 272 type: 'checkbox',
261 name: 'tunnel-id-name-remove', 273 name: 'tunnel-id-name-remove',
262 - value: val 274 + value: data.a[idx]
263 }); 275 });
264 - 276 + idx++;
265 - p.append('span').text(val); 277 + p.append('span').text(data.a[idx]);
266 p.append('br'); 278 p.append('br');
267 - } ); 279 + }
268 280
269 return content; 281 return content;
270 } 282 }
271 283
284 + function createUserTextQuery(data) {
285 +
286 + var content = ds.createDiv(),
287 + form = content.append('form'),
288 + p = form.append('p');
289 +
290 + p.append('span').text('Tunnels');
291 + p.append('br');
292 +
293 + for (var idx =0; idx < data.a.length; idx++) {
294 + p.append('input').attr({
295 + id: 'tunnel-id-query-'+idx,
296 + type: 'radio',
297 + name: 'tunnel-id-name-query',
298 + value: data.a[idx]
299 + });
300 + idx++;
301 + p.append('span').text(data.a[idx]);
302 + p.append('br');
303 + }
304 + return content;
305 + }
306 +
272 function isChecked(cboxId) { 307 function isChecked(cboxId) {
273 return d3.select('#' + cboxId).property('checked'); 308 return d3.select('#' + cboxId).property('checked');
274 } 309 }
...@@ -283,12 +318,13 @@ ...@@ -283,12 +318,13 @@
283 318
284 function dOkUpdate() { 319 function dOkUpdate() {
285 var tdString = '' ; 320 var tdString = '' ;
286 - tunnelNameData.a.forEach( function (val, idx) { 321 + for (var idx = 0; idx < tunnelNameData.a.length; idx++) {
287 var tunnelName = isChecked('tunnel-id-'+idx); 322 var tunnelName = isChecked('tunnel-id-'+idx);
288 if (tunnelName) { 323 if (tunnelName) {
289 - tdString = val; 324 + tdString = tunnelNameData.a[idx];
290 } 325 }
291 - } ); 326 + idx++;
327 + }
292 //send event to server for getting the tunnel information. 328 //send event to server for getting the tunnel information.
293 if (tdString != null) { 329 if (tdString != null) {
294 handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle; 330 handlerMapShowUpdate[showTunnelInfoUpdateMsg] = showTunnelInfoUpdateMsgHandle;
...@@ -313,31 +349,30 @@ ...@@ -313,31 +349,30 @@
313 function dOkUpdateEvent() { 349 function dOkUpdateEvent() {
314 $log.debug('Select constraints for update path Dialog OK button pressed'); 350 $log.debug('Select constraints for update path Dialog OK button pressed');
315 351
316 - var bandWidth = isChecked('update-band-width-box'), 352 + var bandValue = null,
317 - bandValue = null,
318 bandType = null; 353 bandType = null;
319 354
320 - if (bandWidth) { 355 + bandValue = getCheckedValue('update-band-width-value');
321 - bandValue = getCheckedValue('update-band-width-value');
322 356
323 - if (isChecked('update-band-kbps-val')) { 357 + if (isChecked('update-band-kbps-val')) {
324 bandType = 'kbps'; 358 bandType = 'kbps';
325 - } else if (isChecked('update-band-mbps-val')) { 359 + } else if (isChecked('update-band-mbps-val')) {
326 bandType = 'mbps'; 360 bandType = 'mbps';
327 - } else if (isChecked('update-band-bps-val')) { 361 + } else if (isChecked('update-band-bps-val')) {
328 bandType = 'bps'; 362 bandType = 'bps';
329 - } 363 + } else if (isChecked('update-band-none-val')) {
364 + bandType = null;
365 + bandValue = null;
330 } 366 }
331 367
332 - var costType = isChecked('update-pce-cost-type'), 368 + var costTypeVal = null;
333 - costTypeVal = null;
334 369
335 - if (costType) { 370 + if (isChecked('update-pce-cost-type-igp')) {
336 - if (isChecked('update-pce-cost-type-igp')) { 371 + costTypeVal = 'igp';
337 - costTypeVal = 'igp'; 372 + } else if (isChecked('update-pce-cost-type-te')) {
338 - } else if (isChecked('update-pce-cost-type-te')) { 373 + costTypeVal = 'te';
339 - costTypeVal = 'te'; 374 + } else if (isChecked('update-pce-cost-type-none')) {
340 - } 375 + costTypeVal = null;
341 } 376 }
342 377
343 wss.sendEvent(updatePathmsg, { 378 wss.sendEvent(updatePathmsg, {
...@@ -363,6 +398,18 @@ ...@@ -363,6 +398,18 @@
363 .bindKeys(); 398 .bindKeys();
364 } 399 }
365 400
401 + function showTunnelInformationQuery(data) {
402 +
403 + wss.unbindHandlers(handlerMapshowQuery);
404 + tunnelNameDataQuery = data;
405 + tds.openDialog()
406 + .setTitle('Available Tunnels for highlight')
407 + .addContent(createUserTextQuery(data))
408 + .addOk(dOkQuery, 'OK')
409 + .addCancel(dClose, 'Close')
410 + .bindKeys();
411 + }
412 +
366 function showTunnelInfoUpdateMsgHandle(data) { 413 function showTunnelInfoUpdateMsgHandle(data) {
367 414
368 wss.unbindHandlers(handlerMapShowUpdate); 415 wss.unbindHandlers(handlerMapShowUpdate);
...@@ -456,14 +503,30 @@ ...@@ -456,14 +503,30 @@
456 503
457 function dOkRemove() { 504 function dOkRemove() {
458 505
459 - tunnelNameDataRemove.a.forEach( function (val, idx) { 506 + for (var idx = 0; idx < tunnelNameDataRemove.a.length; idx++) {
460 var tunnelNameVal = isChecked('tunnel-id-remove-'+idx); 507 var tunnelNameVal = isChecked('tunnel-id-remove-'+idx);
461 if (tunnelNameVal) { 508 if (tunnelNameVal) {
462 wss.sendEvent(remPathmsg, { 509 wss.sendEvent(remPathmsg, {
463 - tunnelid: val 510 + tunnelid: tunnelNameDataRemove.a[idx]
464 }); 511 });
465 } 512 }
466 - } ); 513 + idx++;
514 + }
515 +
516 + flash.flash('remove path message');
517 + }
518 +
519 + function dOkQuery() {
520 +
521 + for (var idx = 0; idx < tunnelNameDataQuery.a.length; idx++) {
522 + var tunnelNameVal = isChecked('tunnel-id-query-'+idx);
523 + if (tunnelNameVal) {
524 + wss.sendEvent(showTunnelHighlightMsg, {
525 + tunnelid: tunnelNameDataQuery.a[idx]
526 + });
527 + }
528 + idx++;
529 + }
467 530
468 flash.flash('remove path message'); 531 flash.flash('remove path message');
469 } 532 }
...@@ -479,6 +542,9 @@ ...@@ -479,6 +542,9 @@
479 } 542 }
480 543
481 function queryTunnelDisplay() { 544 function queryTunnelDisplay() {
545 + handlerMapshowQuery[showTunnelInfoQuery] = showTunnelInformationQuery;
546 + wss.bindHandlers(handlerMapshowQuery);
547 +
482 wss.sendEvent(queryDisplayTunnelMsg); 548 wss.sendEvent(queryDisplayTunnelMsg);
483 } 549 }
484 // === --------------------------- 550 // === ---------------------------
......
...@@ -126,8 +126,8 @@ ...@@ -126,8 +126,8 @@
126 } 126 }
127 127
128 sep(); 128 sep();
129 - add('Src port'); 129 + add('Src Address');
130 - add('Dst port'); 130 + add('Dst Address');
131 add('Te metric'); 131 add('Te metric');
132 add('Bandwidth'); 132 add('Bandwidth');
133 133
......