Praseed Balakrishnan

Optical UC fixes for gui and for host2host intent provisoning

Change-Id: I5439583e92c44836632e381e0482bd485a1c5de4
...@@ -30,9 +30,15 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; ...@@ -30,9 +30,15 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
30 import org.onlab.onos.core.ApplicationId; 30 import org.onlab.onos.core.ApplicationId;
31 import org.onlab.onos.core.CoreService; 31 import org.onlab.onos.core.CoreService;
32 import org.onlab.onos.net.ConnectPoint; 32 import org.onlab.onos.net.ConnectPoint;
33 +import org.onlab.onos.net.Host;
33 import org.onlab.onos.net.Link; 34 import org.onlab.onos.net.Link;
34 import org.onlab.onos.net.Path; 35 import org.onlab.onos.net.Path;
35 import org.onlab.onos.net.device.DeviceService; 36 import org.onlab.onos.net.device.DeviceService;
37 +import org.onlab.onos.net.flow.DefaultTrafficSelector;
38 +import org.onlab.onos.net.flow.TrafficSelector;
39 +import org.onlab.onos.net.flow.TrafficTreatment;
40 +import org.onlab.onos.net.host.HostService;
41 +import org.onlab.onos.net.intent.HostToHostIntent;
36 import org.onlab.onos.net.intent.Intent; 42 import org.onlab.onos.net.intent.Intent;
37 import org.onlab.onos.net.intent.IntentEvent; 43 import org.onlab.onos.net.intent.IntentEvent;
38 import org.onlab.onos.net.intent.IntentExtensionService; 44 import org.onlab.onos.net.intent.IntentExtensionService;
...@@ -47,9 +53,12 @@ import org.onlab.onos.net.topology.Topology; ...@@ -47,9 +53,12 @@ import org.onlab.onos.net.topology.Topology;
47 import org.onlab.onos.net.topology.TopologyEdge; 53 import org.onlab.onos.net.topology.TopologyEdge;
48 54
49 import org.onlab.onos.net.topology.TopologyService; 55 import org.onlab.onos.net.topology.TopologyService;
56 +import org.onlab.packet.Ethernet;
50 import org.slf4j.Logger; 57 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory; 58 import org.slf4j.LoggerFactory;
52 59
60 +import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
61 +
53 /** 62 /**
54 * OpticalPathProvisioner listens event notifications from the Intent F/W. 63 * OpticalPathProvisioner listens event notifications from the Intent F/W.
55 * It generates one or more opticalConnectivityIntent(s) and submits (or withdraws) to Intent F/W 64 * It generates one or more opticalConnectivityIntent(s) and submits (or withdraws) to Intent F/W
...@@ -84,6 +93,9 @@ public class OpticalPathProvisioner { ...@@ -84,6 +93,9 @@ public class OpticalPathProvisioner {
84 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 93 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
85 protected LinkResourceService resourceService; 94 protected LinkResourceService resourceService;
86 95
96 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
97 + protected HostService hostService;
98 +
87 private ApplicationId appId; 99 private ApplicationId appId;
88 100
89 //protected <IntentId> intentIdGenerator; 101 //protected <IntentId> intentIdGenerator;
...@@ -125,7 +137,28 @@ public class OpticalPathProvisioner { ...@@ -125,7 +137,28 @@ public class OpticalPathProvisioner {
125 137
126 private void setuplightpath(Intent intent) { 138 private void setuplightpath(Intent intent) {
127 // TODO support more packet intent types 139 // TODO support more packet intent types
128 - if (!intent.getClass().equals(PointToPointIntent.class)) { 140 +
141 + if (intent instanceof HostToHostIntent) {
142 + HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;
143 + Host one = hostService.getHost(hostToHostIntent.one());
144 + Host two = hostService.getHost(hostToHostIntent.two());
145 +
146 + TrafficSelector selector = buildTrafficSelector();
147 + TrafficTreatment treatment = builder().build();
148 +
149 + PointToPointIntent intentOneToTwo =
150 + new PointToPointIntent(appId, selector, treatment,
151 + one.location(), two.location());
152 + intentService.submit(intentOneToTwo);
153 + log.info("Submitting P2P intent {} ", intentOneToTwo);
154 +
155 + PointToPointIntent intentTwoToOne =
156 + new PointToPointIntent(appId, selector, treatment,
157 + two.location(), one.location());
158 + intentService.submit(intentTwoToOne);
159 + log.info("Submitting P2P intent for {} ", intentTwoToOne);
160 + return;
161 + } else if (!intent.getClass().equals(PointToPointIntent.class)) {
129 return; 162 return;
130 } 163 }
131 164
...@@ -162,7 +195,9 @@ public class OpticalPathProvisioner { ...@@ -162,7 +195,9 @@ public class OpticalPathProvisioner {
162 Path firstPath = itrPath.next(); 195 Path firstPath = itrPath.next();
163 log.info(firstPath.links().toString()); 196 log.info(firstPath.links().toString());
164 197
165 - ArrayList<Map<ConnectPoint, ConnectPoint>> connectionList = new ArrayList<>(); 198 + ArrayList<Map<ConnectPoint, ConnectPoint>> connectionList =
199 + new ArrayList<>();
200 +
166 201
167 Iterator<Link> itrLink = firstPath.links().iterator(); 202 Iterator<Link> itrLink = firstPath.links().iterator();
168 while (itrLink.hasNext()) { 203 while (itrLink.hasNext()) {
...@@ -233,6 +268,15 @@ public class OpticalPathProvisioner { ...@@ -233,6 +268,15 @@ public class OpticalPathProvisioner {
233 // TODO: tear down the idle lightpath if the utilization is close to zero. 268 // TODO: tear down the idle lightpath if the utilization is close to zero.
234 } 269 }
235 270
271 + private TrafficSelector buildTrafficSelector() {
272 + TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
273 + Short ethType = Ethernet.TYPE_IPV4;
274 +
275 + selectorBuilder.matchEthType(ethType);
276 +
277 + return selectorBuilder.build();
278 + }
279 +
236 } 280 }
237 281
238 } 282 }
......
...@@ -16,7 +16,7 @@ class NullIntf( Intf ): ...@@ -16,7 +16,7 @@ class NullIntf( Intf ):
16 16
17 class NullLink( Link ): 17 class NullLink( Link ):
18 "A dummy link that doesn't touch either interface" 18 "A dummy link that doesn't touch either interface"
19 - def makeIntfPair( cls, intf1, intf2 ): 19 + def makeIntfPair( cls, intf1, intf2, *args, **kwargs ):
20 pass 20 pass
21 def delete( self ): 21 def delete( self ):
22 pass 22 pass
......
...@@ -174,7 +174,7 @@ public class TopologyWebSocket ...@@ -174,7 +174,7 @@ public class TopologyWebSocket
174 requestDetails(event); 174 requestDetails(event);
175 } else if (type.equals("updateMeta")) { 175 } else if (type.equals("updateMeta")) {
176 updateMetaUi(event); 176 updateMetaUi(event);
177 - } else if (type.equals("requestPath")) { 177 + } else if (type.equals("addHostIntent")) {
178 createHostIntent(event); 178 createHostIntent(event);
179 } else if (type.equals("requestTraffic")) { 179 } else if (type.equals("requestTraffic")) {
180 requestTraffic(event); 180 requestTraffic(event);
......