Thomas Vachuska

Connecting packet paths to optical tunnels visually.

Change-Id: Ib6a8cefd9e6eb466e38e305b2fcda4b40a8854fd
...@@ -5,4 +5,4 @@ export OC1="192.168.56.101" ...@@ -5,4 +5,4 @@ export OC1="192.168.56.101"
5 export OCN="192.168.56.103" 5 export OCN="192.168.56.103"
6 export OCI="${OC1}" 6 export OCI="${OC1}"
7 7
8 -export ONOS_FEATURES=webconsole,onos-api,onos-core-trivial,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-tvue 8 +export ONOS_FEATURES=webconsole,onos-api,onos-core-trivial,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-optical
......
...@@ -40,11 +40,11 @@ import org.onlab.onos.net.device.DeviceEvent; ...@@ -40,11 +40,11 @@ import org.onlab.onos.net.device.DeviceEvent;
40 import org.onlab.onos.net.device.DeviceService; 40 import org.onlab.onos.net.device.DeviceService;
41 import org.onlab.onos.net.host.HostEvent; 41 import org.onlab.onos.net.host.HostEvent;
42 import org.onlab.onos.net.host.HostService; 42 import org.onlab.onos.net.host.HostService;
43 -import org.onlab.onos.net.intent.ConnectivityIntent;
44 import org.onlab.onos.net.intent.Intent; 43 import org.onlab.onos.net.intent.Intent;
45 import org.onlab.onos.net.intent.IntentService; 44 import org.onlab.onos.net.intent.IntentService;
46 import org.onlab.onos.net.intent.LinkCollectionIntent; 45 import org.onlab.onos.net.intent.LinkCollectionIntent;
47 import org.onlab.onos.net.intent.OpticalConnectivityIntent; 46 import org.onlab.onos.net.intent.OpticalConnectivityIntent;
47 +import org.onlab.onos.net.intent.OpticalPathIntent;
48 import org.onlab.onos.net.intent.PathIntent; 48 import org.onlab.onos.net.intent.PathIntent;
49 import org.onlab.onos.net.link.LinkEvent; 49 import org.onlab.onos.net.link.LinkEvent;
50 import org.onlab.onos.net.link.LinkService; 50 import org.onlab.onos.net.link.LinkService;
...@@ -384,9 +384,14 @@ public abstract class TopologyMessages { ...@@ -384,9 +384,14 @@ public abstract class TopologyMessages {
384 if (installables != null) { 384 if (installables != null) {
385 for (Intent installable : installables) { 385 for (Intent installable : installables) {
386 String cls = isOptical ? trafficClass.type + " optical" : trafficClass.type; 386 String cls = isOptical ? trafficClass.type + " optical" : trafficClass.type;
387 - if (installable instanceof ConnectivityIntent) { 387 + if (installable instanceof PathIntent) {
388 - addPathTraffic(paths, cls, (ConnectivityIntent) installable); 388 + addPathTraffic(paths, cls, ((PathIntent) installable).path().links());
389 + } else if (installable instanceof LinkCollectionIntent) {
390 + addPathTraffic(paths, cls, ((LinkCollectionIntent) installable).links());
391 + } else if (installable instanceof OpticalPathIntent) {
392 + addPathTraffic(paths, cls, ((OpticalPathIntent) installable).path().links());
389 } 393 }
394 +
390 } 395 }
391 } 396 }
392 } 397 }
...@@ -397,12 +402,10 @@ public abstract class TopologyMessages { ...@@ -397,12 +402,10 @@ public abstract class TopologyMessages {
397 402
398 // Adds the link segments (path or tree) associated with the specified 403 // Adds the link segments (path or tree) associated with the specified
399 // connectivity intent 404 // connectivity intent
400 - protected void addPathTraffic(ArrayNode paths, String type, 405 + protected void addPathTraffic(ArrayNode paths, String type, Iterable<Link> links) {
401 - ConnectivityIntent installable) {
402 ObjectNode pathNode = mapper.createObjectNode(); 406 ObjectNode pathNode = mapper.createObjectNode();
403 ArrayNode linksNode = mapper.createArrayNode(); 407 ArrayNode linksNode = mapper.createArrayNode();
404 408
405 - Iterable<Link> links = pathLinks(installable);
406 if (links != null) { 409 if (links != null) {
407 ArrayNode labels = mapper.createArrayNode(); 410 ArrayNode labels = mapper.createArrayNode();
408 boolean hasTraffic = true; // FIXME 411 boolean hasTraffic = true; // FIXME
...@@ -423,15 +426,6 @@ public abstract class TopologyMessages { ...@@ -423,15 +426,6 @@ public abstract class TopologyMessages {
423 } 426 }
424 } 427 }
425 428
426 - private Iterable<Link> pathLinks(ConnectivityIntent intent) {
427 - if (intent instanceof PathIntent) {
428 - return ((PathIntent) intent).path().links();
429 - } else if (intent instanceof LinkCollectionIntent) {
430 - return ((LinkCollectionIntent) intent).links();
431 - }
432 - return null;
433 - }
434 -
435 // Produces compact string representation of a link. 429 // Produces compact string representation of a link.
436 private static String compactLinkString(Link link) { 430 private static String compactLinkString(Link link) {
437 return String.format(COMPACT, link.src().elementId(), link.src().port(), 431 return String.format(COMPACT, link.src().elementId(), link.src().port(),
......
...@@ -29,7 +29,6 @@ import org.onlab.onos.net.Device; ...@@ -29,7 +29,6 @@ import org.onlab.onos.net.Device;
29 import org.onlab.onos.net.Host; 29 import org.onlab.onos.net.Host;
30 import org.onlab.onos.net.HostId; 30 import org.onlab.onos.net.HostId;
31 import org.onlab.onos.net.Link; 31 import org.onlab.onos.net.Link;
32 -import org.onlab.onos.net.Path;
33 import org.onlab.onos.net.device.DeviceEvent; 32 import org.onlab.onos.net.device.DeviceEvent;
34 import org.onlab.onos.net.device.DeviceListener; 33 import org.onlab.onos.net.device.DeviceListener;
35 import org.onlab.onos.net.flow.DefaultTrafficSelector; 34 import org.onlab.onos.net.flow.DefaultTrafficSelector;
...@@ -378,14 +377,20 @@ public class TopologyWebSocket ...@@ -378,14 +377,20 @@ public class TopologyWebSocket
378 // Indicates whether the specified intent involves all of the given edge points. 377 // Indicates whether the specified intent involves all of the given edge points.
379 private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent, 378 private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent,
380 Set<Intent> intents) { 379 Set<Intent> intents) {
380 + Link ccSrc = getFirstLink(opticalIntent.getSrcConnectPoint(), false);
381 + Link ccDst = getFirstLink(opticalIntent.getDst(), true);
382 +
381 for (Intent intent : intents) { 383 for (Intent intent : intents) {
382 List<Intent> installables = intentService.getInstallableIntents(intent.id()); 384 List<Intent> installables = intentService.getInstallableIntents(intent.id());
383 for (Intent installable : installables) { 385 for (Intent installable : installables) {
384 if (installable instanceof PathIntent) { 386 if (installable instanceof PathIntent) {
385 - Path path = ((PathIntent) installable).path(); 387 + List<Link> links = ((PathIntent) installable).path().links();
386 - if (opticalIntent.getSrcConnectPoint().equals(path.src()) && 388 + if (links.size() == 3) {
387 - opticalIntent.getDst().equals(path.dst())) { 389 + Link tunnel = links.get(1);
388 - return true; 390 + if (tunnel.src().equals(ccSrc.src()) &&
391 + tunnel.dst().equals(ccDst.dst())) {
392 + return true;
393 + }
389 } 394 }
390 } 395 }
391 } 396 }
...@@ -393,6 +398,15 @@ public class TopologyWebSocket ...@@ -393,6 +398,15 @@ public class TopologyWebSocket
393 return false; 398 return false;
394 } 399 }
395 400
401 + private Link getFirstLink(ConnectPoint point, boolean ingress) {
402 + for (Link link : linkService.getLinks(point)) {
403 + if (point.equals(ingress ? link.src() : link.dst())) {
404 + return link;
405 + }
406 + }
407 + return null;
408 + }
409 +
396 // Produces a set of all host ids listed in the specified JSON array. 410 // Produces a set of all host ids listed in the specified JSON array.
397 private Set<Host> getHosts(ArrayNode array) { 411 private Set<Host> getHosts(ArrayNode array) {
398 Set<Host> hosts = new HashSet<>(); 412 Set<Host> hosts = new HashSet<>();
......