Optical UC fixes for gui and for host2host intent provisoning
Change-Id: I5439583e92c44836632e381e0482bd485a1c5de4
diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/provisioner/OpticalPathProvisioner.java b/apps/optical/src/main/java/org/onlab/onos/optical/provisioner/OpticalPathProvisioner.java
index ba79d33..8b78800 100644
--- a/apps/optical/src/main/java/org/onlab/onos/optical/provisioner/OpticalPathProvisioner.java
+++ b/apps/optical/src/main/java/org/onlab/onos/optical/provisioner/OpticalPathProvisioner.java
@@ -30,9 +30,15 @@
import org.onlab.onos.core.ApplicationId;
import org.onlab.onos.core.CoreService;
import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.Host;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.device.DeviceService;
+import org.onlab.onos.net.flow.DefaultTrafficSelector;
+import org.onlab.onos.net.flow.TrafficSelector;
+import org.onlab.onos.net.flow.TrafficTreatment;
+import org.onlab.onos.net.host.HostService;
+import org.onlab.onos.net.intent.HostToHostIntent;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentEvent;
import org.onlab.onos.net.intent.IntentExtensionService;
@@ -47,9 +53,12 @@
import org.onlab.onos.net.topology.TopologyEdge;
import org.onlab.onos.net.topology.TopologyService;
+import org.onlab.packet.Ethernet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
+
/**
* OpticalPathProvisioner listens event notifications from the Intent F/W.
* It generates one or more opticalConnectivityIntent(s) and submits (or withdraws) to Intent F/W
@@ -84,6 +93,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected LinkResourceService resourceService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
private ApplicationId appId;
//protected <IntentId> intentIdGenerator;
@@ -125,7 +137,28 @@
private void setuplightpath(Intent intent) {
// TODO support more packet intent types
- if (!intent.getClass().equals(PointToPointIntent.class)) {
+
+ if (intent instanceof HostToHostIntent) {
+ HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;
+ Host one = hostService.getHost(hostToHostIntent.one());
+ Host two = hostService.getHost(hostToHostIntent.two());
+
+ TrafficSelector selector = buildTrafficSelector();
+ TrafficTreatment treatment = builder().build();
+
+ PointToPointIntent intentOneToTwo =
+ new PointToPointIntent(appId, selector, treatment,
+ one.location(), two.location());
+ intentService.submit(intentOneToTwo);
+ log.info("Submitting P2P intent {} ", intentOneToTwo);
+
+ PointToPointIntent intentTwoToOne =
+ new PointToPointIntent(appId, selector, treatment,
+ two.location(), one.location());
+ intentService.submit(intentTwoToOne);
+ log.info("Submitting P2P intent for {} ", intentTwoToOne);
+ return;
+ } else if (!intent.getClass().equals(PointToPointIntent.class)) {
return;
}
@@ -162,7 +195,9 @@
Path firstPath = itrPath.next();
log.info(firstPath.links().toString());
- ArrayList<Map<ConnectPoint, ConnectPoint>> connectionList = new ArrayList<>();
+ ArrayList<Map<ConnectPoint, ConnectPoint>> connectionList =
+ new ArrayList<>();
+
Iterator<Link> itrLink = firstPath.links().iterator();
while (itrLink.hasNext()) {
@@ -233,6 +268,15 @@
// TODO: tear down the idle lightpath if the utilization is close to zero.
}
+ private TrafficSelector buildTrafficSelector() {
+ TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
+ Short ethType = Ethernet.TYPE_IPV4;
+
+ selectorBuilder.matchEthType(ethType);
+
+ return selectorBuilder.build();
+ }
+
}
}
diff --git a/tools/test/topos/optical2.py b/tools/test/topos/optical2.py
index bf4aba5..36cdbad 100644
--- a/tools/test/topos/optical2.py
+++ b/tools/test/topos/optical2.py
@@ -16,7 +16,7 @@
class NullLink( Link ):
"A dummy link that doesn't touch either interface"
- def makeIntfPair( cls, intf1, intf2 ):
+ def makeIntfPair( cls, intf1, intf2, *args, **kwargs ):
pass
def delete( self ):
pass
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyWebSocket.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyWebSocket.java
index eee03ed..af28086 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyWebSocket.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyWebSocket.java
@@ -174,7 +174,7 @@
requestDetails(event);
} else if (type.equals("updateMeta")) {
updateMetaUi(event);
- } else if (type.equals("requestPath")) {
+ } else if (type.equals("addHostIntent")) {
createHostIntent(event);
} else if (type.equals("requestTraffic")) {
requestTraffic(event);