optical intent
Change-Id: I23714985a2fe1e3bbc59deff2d267007750d0420
Showing
4 changed files
with
121 additions
and
60 deletions
... | @@ -30,7 +30,7 @@ import org.onlab.onos.net.resource.LinkResourceService; | ... | @@ -30,7 +30,7 @@ import org.onlab.onos.net.resource.LinkResourceService; |
30 | import org.onlab.onos.net.topology.LinkWeight; | 30 | import org.onlab.onos.net.topology.LinkWeight; |
31 | import org.onlab.onos.net.topology.Topology; | 31 | import org.onlab.onos.net.topology.Topology; |
32 | import org.onlab.onos.net.topology.TopologyEdge; | 32 | import org.onlab.onos.net.topology.TopologyEdge; |
33 | -import org.onlab.onos.net.topology.TopologyGraph; | 33 | + |
34 | import org.onlab.onos.net.topology.TopologyService; | 34 | import org.onlab.onos.net.topology.TopologyService; |
35 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
36 | import org.slf4j.LoggerFactory; | 36 | import org.slf4j.LoggerFactory; |
... | @@ -120,7 +120,6 @@ public class OpticalPathProvisioner { | ... | @@ -120,7 +120,6 @@ public class OpticalPathProvisioner { |
120 | } | 120 | } |
121 | 121 | ||
122 | Topology topology = topologyService.currentTopology(); | 122 | Topology topology = topologyService.currentTopology(); |
123 | - TopologyGraph graph = topologyService.getGraph(topology); | ||
124 | 123 | ||
125 | LinkWeight weight = new LinkWeight() { | 124 | LinkWeight weight = new LinkWeight() { |
126 | @Override | 125 | @Override | ... | ... |
... | @@ -13,8 +13,8 @@ import com.google.common.base.MoreObjects; | ... | @@ -13,8 +13,8 @@ import com.google.common.base.MoreObjects; |
13 | 13 | ||
14 | public class OpticalPathIntent extends OpticalConnectivityIntent { | 14 | public class OpticalPathIntent extends OpticalConnectivityIntent { |
15 | private final Path path; | 15 | private final Path path; |
16 | - private final TrafficSelector opticalMatch; | 16 | + // private final TrafficSelector opticalMatch; |
17 | - private final TrafficTreatment opticalAction; | 17 | + // private final TrafficTreatment opticalAction; |
18 | 18 | ||
19 | public OpticalPathIntent(ApplicationId appId, | 19 | public OpticalPathIntent(ApplicationId appId, |
20 | ConnectPoint src, | 20 | ConnectPoint src, |
... | @@ -23,29 +23,29 @@ public class OpticalPathIntent extends OpticalConnectivityIntent { | ... | @@ -23,29 +23,29 @@ public class OpticalPathIntent extends OpticalConnectivityIntent { |
23 | TrafficTreatment action, | 23 | TrafficTreatment action, |
24 | Path path) { | 24 | Path path) { |
25 | super(appId, src, dst); | 25 | super(appId, src, dst); |
26 | - this.opticalMatch = match; | 26 | + // this.opticalMatch = match; |
27 | - this.opticalAction = action; | 27 | + // this.opticalAction = action; |
28 | this.path = path; | 28 | this.path = path; |
29 | } | 29 | } |
30 | 30 | ||
31 | - public OpticalPathIntent() { | 31 | + protected OpticalPathIntent() { |
32 | - this.opticalMatch = null; | 32 | + // this.opticalMatch = null; |
33 | - this.opticalAction = null; | 33 | + // this.opticalAction = null; |
34 | this.path = null; | 34 | this.path = null; |
35 | } | 35 | } |
36 | 36 | ||
37 | public Path path() { | 37 | public Path path() { |
38 | return path; | 38 | return path; |
39 | } | 39 | } |
40 | - | 40 | +/* |
41 | public TrafficSelector selector() { | 41 | public TrafficSelector selector() { |
42 | - return opticalMatch; | 42 | + // return opticalMatch; |
43 | } | 43 | } |
44 | 44 | ||
45 | public TrafficTreatment treatment() { | 45 | public TrafficTreatment treatment() { |
46 | - return opticalAction; | 46 | + // return opticalAction; |
47 | } | 47 | } |
48 | - | 48 | +*/ |
49 | @Override | 49 | @Override |
50 | public boolean isInstallable() { | 50 | public boolean isInstallable() { |
51 | return true; | 51 | return true; |
... | @@ -55,8 +55,8 @@ public class OpticalPathIntent extends OpticalConnectivityIntent { | ... | @@ -55,8 +55,8 @@ public class OpticalPathIntent extends OpticalConnectivityIntent { |
55 | public String toString() { | 55 | public String toString() { |
56 | return MoreObjects.toStringHelper(getClass()) | 56 | return MoreObjects.toStringHelper(getClass()) |
57 | .add("id", id()) | 57 | .add("id", id()) |
58 | - .add("match", opticalMatch) | 58 | + //.add("match", opticalMatch) |
59 | - .add("action", opticalAction) | 59 | + //.add("action", opticalAction) |
60 | .add("ingressPort", this.getSrcConnectPoint()) | 60 | .add("ingressPort", this.getSrcConnectPoint()) |
61 | .add("egressPort", this.getDst()) | 61 | .add("egressPort", this.getDst()) |
62 | .add("path", path) | 62 | .add("path", path) | ... | ... |
... | @@ -14,7 +14,7 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -14,7 +14,7 @@ import org.apache.felix.scr.annotations.Reference; |
14 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 14 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
15 | import org.onlab.onos.CoreService; | 15 | import org.onlab.onos.CoreService; |
16 | import org.onlab.onos.net.ConnectPoint; | 16 | import org.onlab.onos.net.ConnectPoint; |
17 | -import org.onlab.onos.net.DefaultEdgeLink; | 17 | + |
18 | import org.onlab.onos.net.Link; | 18 | import org.onlab.onos.net.Link; |
19 | import org.onlab.onos.net.Path; | 19 | import org.onlab.onos.net.Path; |
20 | import org.onlab.onos.net.flow.TrafficSelector; | 20 | import org.onlab.onos.net.flow.TrafficSelector; |
... | @@ -84,9 +84,9 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -84,9 +84,9 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
84 | } | 84 | } |
85 | 85 | ||
86 | List<Link> links = new ArrayList<>(); | 86 | List<Link> links = new ArrayList<>(); |
87 | - links.add(DefaultEdgeLink.createEdgeLink(intent.getSrcConnectPoint(), true)); | 87 | + // links.add(DefaultEdgeLink.createEdgeLink(intent.getSrcConnectPoint(), true)); |
88 | links.addAll(path.links()); | 88 | links.addAll(path.links()); |
89 | - links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false)); | 89 | + //links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false)); |
90 | 90 | ||
91 | TrafficSelector opticalSelector = null; | 91 | TrafficSelector opticalSelector = null; |
92 | TrafficTreatment opticalTreatment = null; | 92 | TrafficTreatment opticalTreatment = null; | ... | ... |
... | @@ -3,9 +3,8 @@ package org.onlab.onos.net.intent.impl; | ... | @@ -3,9 +3,8 @@ package org.onlab.onos.net.intent.impl; |
3 | import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; | 3 | import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder; |
4 | import static org.slf4j.LoggerFactory.getLogger; | 4 | import static org.slf4j.LoggerFactory.getLogger; |
5 | 5 | ||
6 | -import java.util.Iterator; | 6 | + |
7 | import java.util.List; | 7 | import java.util.List; |
8 | -import java.util.concurrent.Future; | ||
9 | 8 | ||
10 | import org.apache.felix.scr.annotations.Activate; | 9 | import org.apache.felix.scr.annotations.Activate; |
11 | import org.apache.felix.scr.annotations.Component; | 10 | import org.apache.felix.scr.annotations.Component; |
... | @@ -16,7 +15,6 @@ import org.onlab.onos.ApplicationId; | ... | @@ -16,7 +15,6 @@ import org.onlab.onos.ApplicationId; |
16 | import org.onlab.onos.CoreService; | 15 | import org.onlab.onos.CoreService; |
17 | import org.onlab.onos.net.ConnectPoint; | 16 | import org.onlab.onos.net.ConnectPoint; |
18 | import org.onlab.onos.net.Link; | 17 | import org.onlab.onos.net.Link; |
19 | -import org.onlab.onos.net.flow.CompletedBatchOperation; | ||
20 | import org.onlab.onos.net.flow.DefaultFlowRule; | 18 | import org.onlab.onos.net.flow.DefaultFlowRule; |
21 | import org.onlab.onos.net.flow.DefaultTrafficSelector; | 19 | import org.onlab.onos.net.flow.DefaultTrafficSelector; |
22 | import org.onlab.onos.net.flow.DefaultTrafficTreatment; | 20 | import org.onlab.onos.net.flow.DefaultTrafficTreatment; |
... | @@ -30,11 +28,14 @@ import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; | ... | @@ -30,11 +28,14 @@ import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
30 | import org.onlab.onos.net.intent.IntentExtensionService; | 28 | import org.onlab.onos.net.intent.IntentExtensionService; |
31 | import org.onlab.onos.net.intent.IntentInstaller; | 29 | import org.onlab.onos.net.intent.IntentInstaller; |
32 | import org.onlab.onos.net.intent.OpticalPathIntent; | 30 | import org.onlab.onos.net.intent.OpticalPathIntent; |
31 | +import org.onlab.onos.net.resource.DefaultLinkResourceRequest; | ||
33 | import org.onlab.onos.net.resource.Lambda; | 32 | import org.onlab.onos.net.resource.Lambda; |
33 | +import org.onlab.onos.net.resource.LambdaResourceAllocation; | ||
34 | import org.onlab.onos.net.resource.LinkResourceAllocations; | 34 | import org.onlab.onos.net.resource.LinkResourceAllocations; |
35 | import org.onlab.onos.net.resource.LinkResourceRequest; | 35 | import org.onlab.onos.net.resource.LinkResourceRequest; |
36 | import org.onlab.onos.net.resource.LinkResourceService; | 36 | import org.onlab.onos.net.resource.LinkResourceService; |
37 | -import org.onlab.onos.net.resource.ResourceRequest; | 37 | +import org.onlab.onos.net.resource.ResourceAllocation; |
38 | +import org.onlab.onos.net.resource.ResourceType; | ||
38 | import org.onlab.onos.net.topology.TopologyService; | 39 | import org.onlab.onos.net.topology.TopologyService; |
39 | import org.slf4j.Logger; | 40 | import org.slf4j.Logger; |
40 | 41 | ||
... | @@ -67,7 +68,7 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn | ... | @@ -67,7 +68,7 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn |
67 | 68 | ||
68 | private ApplicationId appId; | 69 | private ApplicationId appId; |
69 | 70 | ||
70 | - final static short WAVELENGTH = 80; | 71 | + //final short WAVELENGTH = 80; |
71 | 72 | ||
72 | @Activate | 73 | @Activate |
73 | public void activate() { | 74 | public void activate() { |
... | @@ -82,44 +83,72 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn | ... | @@ -82,44 +83,72 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn |
82 | 83 | ||
83 | @Override | 84 | @Override |
84 | public List<FlowRuleBatchOperation> install(OpticalPathIntent intent) { | 85 | public List<FlowRuleBatchOperation> install(OpticalPathIntent intent) { |
85 | - Lambda la = assignWavelength(intent.path().links()); | 86 | + LinkResourceAllocations allocations = assignWavelength(intent); |
87 | + | ||
88 | + TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); | ||
89 | + selectorBuilder.matchInport(intent.getSrcConnectPoint().port()); | ||
90 | + | ||
91 | + TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); | ||
92 | + | ||
93 | + List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); | ||
94 | + ConnectPoint prev = intent.getSrcConnectPoint(); | ||
95 | + | ||
96 | + //TODO throw exception if the lambda was not assigned successfully | ||
97 | + for (Link link : intent.path().links()) { | ||
98 | + Lambda la = null; | ||
99 | + for (ResourceAllocation allocation : allocations.getResourceAllocation(link)) { | ||
100 | + if (allocation.type() == ResourceType.LAMBDA) { | ||
101 | + la = ((LambdaResourceAllocation) allocation).lambda(); | ||
102 | + break; | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
86 | if (la == null) { | 106 | if (la == null) { |
107 | + log.info("Lambda was not assigned successfully"); | ||
87 | return null; | 108 | return null; |
88 | } | 109 | } |
89 | - // resourceService.requestResources(la); | ||
90 | - // la.toInt(); | ||
91 | - //intent.selector().criteria(); | ||
92 | 110 | ||
93 | - //TrafficSelector.Builder builder = DefaultTrafficSelector.builder(); | 111 | + treatmentBuilder.setOutput(link.src().port()); |
94 | - //builder.matchLambdaType(la.toInt()) | 112 | + //treatmentBuilder.setLambda(la.toInt()); |
95 | - // .matchInport(intent.getSrcConnectPoint().port()); | ||
96 | 113 | ||
97 | - TrafficSelector.Builder builder = | 114 | + FlowRule rule = new DefaultFlowRule(prev.deviceId(), |
98 | - DefaultTrafficSelector.builder(intent.selector()); | 115 | + selectorBuilder.build(), |
99 | - Iterator<Link> links = intent.path().links().iterator(); | 116 | + treatmentBuilder.build(), |
100 | - ConnectPoint prev = links.next().dst(); | ||
101 | - List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); | ||
102 | - // TODO Generate multiple batches | ||
103 | - while (links.hasNext()) { | ||
104 | - builder.matchInport(prev.port()); | ||
105 | - Link link = links.next(); | ||
106 | - TrafficTreatment treatment = builder() | ||
107 | - .setOutput(link.src().port()).build(); | ||
108 | - | ||
109 | - FlowRule rule = new DefaultFlowRule(link.src().deviceId(), | ||
110 | - builder.build(), | ||
111 | - treatment, | ||
112 | 100, | 117 | 100, |
113 | appId, | 118 | appId, |
114 | 100, | 119 | 100, |
115 | true); | 120 | true); |
116 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); | 121 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); |
122 | + | ||
117 | prev = link.dst(); | 123 | prev = link.dst(); |
124 | + selectorBuilder.matchInport(link.dst().port()); | ||
125 | + //selectorBuilder.setLambda(la.toInt()); | ||
118 | } | 126 | } |
127 | + | ||
128 | + // build the last T port rule | ||
129 | + TrafficTreatment treatmentLast = builder() | ||
130 | + .setOutput(intent.getDst().port()).build(); | ||
131 | + FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(), | ||
132 | + selectorBuilder.build(), | ||
133 | + treatmentLast, | ||
134 | + 100, | ||
135 | + appId, | ||
136 | + 100, | ||
137 | + true); | ||
138 | + rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)); | ||
139 | + | ||
119 | return Lists.newArrayList(new FlowRuleBatchOperation(rules)); | 140 | return Lists.newArrayList(new FlowRuleBatchOperation(rules)); |
120 | } | 141 | } |
121 | 142 | ||
122 | - private Lambda assignWavelength(List<Link> links) { | 143 | + private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) { |
144 | + LinkResourceRequest.Builder request = DefaultLinkResourceRequest.builder(intent.id(), | ||
145 | + intent.path().links()) | ||
146 | + .addLambdaRequest(); | ||
147 | + LinkResourceAllocations retLambda = resourceService.requestResources(request.build()); | ||
148 | + return retLambda; | ||
149 | + } | ||
150 | + | ||
151 | + /*private Lambda assignWavelength(List<Link> links) { | ||
123 | // TODO More wavelength assignment algorithm | 152 | // TODO More wavelength assignment algorithm |
124 | int wavenum = 0; | 153 | int wavenum = 0; |
125 | Iterator<Link> itrlink = links.iterator(); | 154 | Iterator<Link> itrlink = links.iterator(); |
... | @@ -154,31 +183,64 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn | ... | @@ -154,31 +183,64 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn |
154 | //} | 183 | //} |
155 | } | 184 | } |
156 | return false; | 185 | return false; |
157 | - } | 186 | + }*/ |
158 | 187 | ||
159 | @Override | 188 | @Override |
160 | public List<FlowRuleBatchOperation> uninstall(OpticalPathIntent intent) { | 189 | public List<FlowRuleBatchOperation> uninstall(OpticalPathIntent intent) { |
161 | - TrafficSelector.Builder builder = | 190 | + LinkResourceAllocations allocations = resourceService.getAllocation(intent.id()); |
162 | - DefaultTrafficSelector.builder(intent.selector()); | 191 | + |
163 | - Iterator<Link> links = intent.path().links().iterator(); | 192 | + TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder(); |
164 | - ConnectPoint prev = links.next().dst(); | 193 | + selectorBuilder.matchInport(intent.getSrcConnectPoint().port()); |
194 | + | ||
195 | + TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); | ||
196 | + | ||
165 | List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); | 197 | List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); |
166 | - // TODO Generate multiple batches | 198 | + ConnectPoint prev = intent.getSrcConnectPoint(); |
167 | - while (links.hasNext()) { | 199 | + |
168 | - builder.matchInport(prev.port()); | 200 | + //TODO throw exception if the lambda was not retrieved successfully |
169 | - Link link = links.next(); | 201 | + for (Link link : intent.path().links()) { |
170 | - TrafficTreatment treatment = builder() | 202 | + Lambda la = null; |
171 | - .setOutput(link.src().port()).build(); | 203 | + for (ResourceAllocation allocation : allocations.getResourceAllocation(link)) { |
172 | - FlowRule rule = new DefaultFlowRule(link.src().deviceId(), | 204 | + if (allocation.type() == ResourceType.LAMBDA) { |
173 | - builder.build(), | 205 | + la = ((LambdaResourceAllocation) allocation).lambda(); |
174 | - treatment, | 206 | + break; |
207 | + } | ||
208 | + } | ||
209 | + | ||
210 | + if (la == null) { | ||
211 | + log.info("Lambda was not retrieved successfully"); | ||
212 | + return null; | ||
213 | + } | ||
214 | + | ||
215 | + treatmentBuilder.setOutput(link.src().port()); | ||
216 | + //treatmentBuilder.setLambda(la.toInt()); | ||
217 | + | ||
218 | + FlowRule rule = new DefaultFlowRule(prev.deviceId(), | ||
219 | + selectorBuilder.build(), | ||
220 | + treatmentBuilder.build(), | ||
175 | 100, | 221 | 100, |
176 | appId, | 222 | appId, |
177 | 100, | 223 | 100, |
178 | true); | 224 | true); |
179 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule)); | 225 | rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule)); |
226 | + | ||
180 | prev = link.dst(); | 227 | prev = link.dst(); |
228 | + selectorBuilder.matchInport(link.dst().port()); | ||
229 | + //selectorBuilder.setLambda(la.toInt()); | ||
181 | } | 230 | } |
231 | + | ||
232 | + // build the last T port rule | ||
233 | + TrafficTreatment treatmentLast = builder() | ||
234 | + .setOutput(intent.getDst().port()).build(); | ||
235 | + FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(), | ||
236 | + selectorBuilder.build(), | ||
237 | + treatmentLast, | ||
238 | + 100, | ||
239 | + appId, | ||
240 | + 100, | ||
241 | + true); | ||
242 | + rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule)); | ||
243 | + | ||
182 | return Lists.newArrayList(new FlowRuleBatchOperation(rules)); | 244 | return Lists.newArrayList(new FlowRuleBatchOperation(rules)); |
183 | } | 245 | } |
184 | 246 | ... | ... |
-
Please register or login to post a comment