Committed by
Gerrit Code Review
Add Optical ODU cross-connect Intent
Create a new intent: OpticalOduIntent in the OTN Topology. - This intent finds a path of OTU links, and - Allocates TributarySlots resources on the OTU ports (in the path) - also add a utility for converting various SignalTypes to OduSignalType, and to build the OduSignalId. Note: this patch follows the example given in patch https://gerrit.onosproject.org/#/c/7321 of separate resource search from resource allocation. Change-Id: Id9808f61aebb80a21481f3882aff23b236b68078
Showing
9 changed files
with
368 additions
and
46 deletions
... | @@ -20,6 +20,7 @@ import org.apache.karaf.shell.commands.Command; | ... | @@ -20,6 +20,7 @@ import org.apache.karaf.shell.commands.Command; |
20 | import org.apache.karaf.shell.commands.Option; | 20 | import org.apache.karaf.shell.commands.Option; |
21 | import org.onosproject.net.CltSignalType; | 21 | import org.onosproject.net.CltSignalType; |
22 | import org.onosproject.net.ConnectPoint; | 22 | import org.onosproject.net.ConnectPoint; |
23 | +import org.onosproject.net.Device; | ||
23 | import org.onosproject.net.OchPort; | 24 | import org.onosproject.net.OchPort; |
24 | import org.onosproject.net.OduCltPort; | 25 | import org.onosproject.net.OduCltPort; |
25 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
... | @@ -30,6 +31,7 @@ import org.onosproject.net.intent.Intent; | ... | @@ -30,6 +31,7 @@ import org.onosproject.net.intent.Intent; |
30 | import org.onosproject.net.intent.IntentService; | 31 | import org.onosproject.net.intent.IntentService; |
31 | import org.onosproject.net.intent.OpticalCircuitIntent; | 32 | import org.onosproject.net.intent.OpticalCircuitIntent; |
32 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 33 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
34 | +import org.onosproject.net.intent.OpticalOduIntent; | ||
33 | 35 | ||
34 | import java.util.List; | 36 | import java.util.List; |
35 | 37 | ||
... | @@ -96,27 +98,52 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -96,27 +98,52 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
96 | Port dstPort = deviceService.getPort(egress.deviceId(), egress.port()); | 98 | Port dstPort = deviceService.getPort(egress.deviceId(), egress.port()); |
97 | 99 | ||
98 | Intent intent; | 100 | Intent intent; |
99 | - // FIXME: Hardcoded signal types | 101 | + |
100 | if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) { | 102 | if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) { |
103 | + Device srcDevice = deviceService.getDevice(ingress.deviceId()); | ||
104 | + Device dstDevice = deviceService.getDevice(egress.deviceId()); | ||
105 | + | ||
106 | + // continue only if both OduClt port's Devices are of the same type | ||
107 | + if (!(srcDevice.type().equals(dstDevice.type()))) { | ||
108 | + print("Devices without same deviceType: SRC=%s and DST=%s", srcDevice.type(), dstDevice.type()); | ||
109 | + return; | ||
110 | + } | ||
111 | + | ||
112 | + CltSignalType signalType = ((OduCltPort) srcPort).signalType(); | ||
113 | + if (Device.Type.ROADM.equals(srcDevice.type())) { | ||
101 | intent = OpticalCircuitIntent.builder() | 114 | intent = OpticalCircuitIntent.builder() |
102 | .appId(appId()) | 115 | .appId(appId()) |
103 | .key(key()) | 116 | .key(key()) |
104 | .src(ingress) | 117 | .src(ingress) |
105 | .dst(egress) | 118 | .dst(egress) |
106 | - .signalType(CltSignalType.CLT_10GBE) | 119 | + .signalType(signalType) |
120 | + .bidirectional(bidirectional) | ||
121 | + .build(); | ||
122 | + } else if (Device.Type.OTN.equals(srcDevice.type())) { | ||
123 | + intent = OpticalOduIntent.builder() | ||
124 | + .appId(appId()) | ||
125 | + .key(key()) | ||
126 | + .src(ingress) | ||
127 | + .dst(egress) | ||
128 | + .signalType(signalType) | ||
107 | .bidirectional(bidirectional) | 129 | .bidirectional(bidirectional) |
108 | .build(); | 130 | .build(); |
131 | + } else { | ||
132 | + print("Wrong Device Type for connect points %s and %s", ingress, egress); | ||
133 | + return; | ||
134 | + } | ||
109 | } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) { | 135 | } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) { |
136 | + OduSignalType signalType = ((OchPort) srcPort).signalType(); | ||
110 | intent = OpticalConnectivityIntent.builder() | 137 | intent = OpticalConnectivityIntent.builder() |
111 | .appId(appId()) | 138 | .appId(appId()) |
112 | .key(key()) | 139 | .key(key()) |
113 | .src(ingress) | 140 | .src(ingress) |
114 | .dst(egress) | 141 | .dst(egress) |
115 | - .signalType(OduSignalType.ODU4) | 142 | + .signalType(signalType) |
116 | .bidirectional(bidirectional) | 143 | .bidirectional(bidirectional) |
117 | .build(); | 144 | .build(); |
118 | } else { | 145 | } else { |
119 | - print("Unable to create optical intent between connect points {} and {}", ingress, egress); | 146 | + print("Unable to create optical intent between connect points %s and %s", ingress, egress); |
120 | return; | 147 | return; |
121 | } | 148 | } |
122 | 149 | ... | ... |
... | @@ -29,6 +29,7 @@ import org.onosproject.net.intent.LinkCollectionIntent; | ... | @@ -29,6 +29,7 @@ import org.onosproject.net.intent.LinkCollectionIntent; |
29 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 29 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
30 | import org.onosproject.net.intent.OpticalCircuitIntent; | 30 | import org.onosproject.net.intent.OpticalCircuitIntent; |
31 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 31 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
32 | +import org.onosproject.net.intent.OpticalOduIntent; | ||
32 | import org.onosproject.net.intent.PathIntent; | 33 | import org.onosproject.net.intent.PathIntent; |
33 | import org.onosproject.net.intent.PointToPointIntent; | 34 | import org.onosproject.net.intent.PointToPointIntent; |
34 | import org.onosproject.net.intent.SinglePointToMultiPointIntent; | 35 | import org.onosproject.net.intent.SinglePointToMultiPointIntent; |
... | @@ -118,6 +119,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -118,6 +119,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
118 | private IntentSummary summaryLinkCollection; | 119 | private IntentSummary summaryLinkCollection; |
119 | private IntentSummary summaryOpticalCircuit; | 120 | private IntentSummary summaryOpticalCircuit; |
120 | private IntentSummary summaryOpticalConnectivity; | 121 | private IntentSummary summaryOpticalConnectivity; |
122 | + private IntentSummary summaryOpticalOdu; | ||
121 | private IntentSummary summaryUnknownType; | 123 | private IntentSummary summaryUnknownType; |
122 | 124 | ||
123 | /** | 125 | /** |
... | @@ -136,6 +138,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -136,6 +138,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
136 | summaryLinkCollection = new IntentSummary("LinkCollection"); | 138 | summaryLinkCollection = new IntentSummary("LinkCollection"); |
137 | summaryOpticalCircuit = new IntentSummary("OpticalCircuit"); | 139 | summaryOpticalCircuit = new IntentSummary("OpticalCircuit"); |
138 | summaryOpticalConnectivity = new IntentSummary("OpticalConnectivity"); | 140 | summaryOpticalConnectivity = new IntentSummary("OpticalConnectivity"); |
141 | + summaryOpticalOdu = new IntentSummary("OpticalOdu"); | ||
139 | summaryUnknownType = new IntentSummary("UnknownType"); | 142 | summaryUnknownType = new IntentSummary("UnknownType"); |
140 | } | 143 | } |
141 | 144 | ||
... | @@ -196,6 +199,10 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -196,6 +199,10 @@ public class IntentsListCommand extends AbstractShellCommand { |
196 | summaryOpticalConnectivity.update(intentState); | 199 | summaryOpticalConnectivity.update(intentState); |
197 | continue; | 200 | continue; |
198 | } | 201 | } |
202 | + if (intent instanceof OpticalOduIntent) { | ||
203 | + summaryOpticalOdu.update(intentState); | ||
204 | + continue; | ||
205 | + } | ||
199 | summaryUnknownType.update(intentState); | 206 | summaryUnknownType.update(intentState); |
200 | } | 207 | } |
201 | } | 208 | } |
... | @@ -219,6 +226,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -219,6 +226,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
219 | result.set("linkCollection", summaryLinkCollection.json(mapper)); | 226 | result.set("linkCollection", summaryLinkCollection.json(mapper)); |
220 | result.set("opticalCircuit", summaryOpticalCircuit.json(mapper)); | 227 | result.set("opticalCircuit", summaryOpticalCircuit.json(mapper)); |
221 | result.set("opticalConnectivity", summaryOpticalConnectivity.json(mapper)); | 228 | result.set("opticalConnectivity", summaryOpticalConnectivity.json(mapper)); |
229 | + result.set("opticalOdu", summaryOpticalOdu.json(mapper)); | ||
222 | result.set("unknownType", summaryUnknownType.json(mapper)); | 230 | result.set("unknownType", summaryUnknownType.json(mapper)); |
223 | result.set("all", summaryAll.json(mapper)); | 231 | result.set("all", summaryAll.json(mapper)); |
224 | return result; | 232 | return result; |
... | @@ -237,6 +245,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -237,6 +245,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
237 | summaryLinkCollection.printState(); | 245 | summaryLinkCollection.printState(); |
238 | summaryOpticalCircuit.printState(); | 246 | summaryOpticalCircuit.printState(); |
239 | summaryOpticalConnectivity.printState(); | 247 | summaryOpticalConnectivity.printState(); |
248 | + summaryOpticalOdu.printState(); | ||
240 | summaryUnknownType.printState(); | 249 | summaryUnknownType.printState(); |
241 | summaryAll.printState(); | 250 | summaryAll.printState(); |
242 | } | 251 | } |
... | @@ -401,6 +410,9 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -401,6 +410,9 @@ public class IntentsListCommand extends AbstractShellCommand { |
401 | } else if (intent instanceof OpticalConnectivityIntent) { | 410 | } else if (intent instanceof OpticalConnectivityIntent) { |
402 | OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent; | 411 | OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent; |
403 | print(" src=%s, dst=%s", ci.getSrc(), ci.getDst()); | 412 | print(" src=%s, dst=%s", ci.getSrc(), ci.getDst()); |
413 | + } else if (intent instanceof OpticalOduIntent) { | ||
414 | + OpticalOduIntent ci = (OpticalOduIntent) intent; | ||
415 | + print(" src=%s, dst=%s", ci.getSrc(), ci.getDst()); | ||
404 | } | 416 | } |
405 | 417 | ||
406 | List<Intent> installable = service.getInstallableIntents(intent.key()); | 418 | List<Intent> installable = service.getInstallableIntents(intent.key()); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.net; | ||
18 | + | ||
19 | +import java.util.Set; | ||
20 | + | ||
21 | +import org.slf4j.Logger; | ||
22 | +import org.slf4j.LoggerFactory; | ||
23 | + | ||
24 | +/** | ||
25 | + * Collection of helper methods to convert various SignalTypes to OduSignalType, and to build OduSignalId. | ||
26 | + */ | ||
27 | +public final class OduSignalUtils { | ||
28 | + | ||
29 | + private static final Logger log = LoggerFactory.getLogger(OduSignalUtils.class); | ||
30 | + | ||
31 | + // prohibit instantiation | ||
32 | + private OduSignalUtils() {} | ||
33 | + | ||
34 | + /** | ||
35 | + * Maps from OduClt SignalType to OduSignalType. | ||
36 | + * | ||
37 | + * @param cltSignalType OduClt port signal type | ||
38 | + * @return OduSignalType the result of mapping CltSignalType to OduSignalType | ||
39 | + */ | ||
40 | + public static OduSignalType mappingCltSignalTypeToOduSignalType(CltSignalType cltSignalType) { | ||
41 | + switch (cltSignalType) { | ||
42 | + case CLT_1GBE: | ||
43 | + return OduSignalType.ODU0; | ||
44 | + case CLT_10GBE: | ||
45 | + return OduSignalType.ODU2; | ||
46 | + case CLT_40GBE: | ||
47 | + return OduSignalType.ODU3; | ||
48 | + case CLT_100GBE: | ||
49 | + return OduSignalType.ODU4; | ||
50 | + default: | ||
51 | + log.error("Unsupported CltSignalType {}", cltSignalType); | ||
52 | + return OduSignalType.ODU0; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * Maps from OtuPort SignalType to OduSignalType. | ||
58 | + * | ||
59 | + * @param otuSignalType Otu port signal type | ||
60 | + * @return OduSignalType the result of mapping OtuSignalType to OduSignalType | ||
61 | + */ | ||
62 | + public static OduSignalType mappingOtuSignalTypeToOduSignalType(OtuSignalType otuSignalType) { | ||
63 | + switch (otuSignalType) { | ||
64 | + case OTU2: | ||
65 | + return OduSignalType.ODU2; | ||
66 | + case OTU4: | ||
67 | + return OduSignalType.ODU4; | ||
68 | + default: | ||
69 | + log.error("Unsupported OtuSignalType {}", otuSignalType); | ||
70 | + return OduSignalType.ODU0; | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Creates OduSignalId from OduSignalType and TributarySlots. | ||
76 | + * @param oduSignalType - OduSignalType | ||
77 | + * @param slots - a set of TributarySlots | ||
78 | + * @return OduSignalId | ||
79 | + */ | ||
80 | + public static OduSignalId buildOduSignalId(OduSignalType oduSignalType, Set<TributarySlot> slots) { | ||
81 | + int tributaryPortNumber = (int) slots.stream().findFirst().get().index(); | ||
82 | + int tributarySlotLen = oduSignalType.tributarySlots(); | ||
83 | + byte[] tributarySlotBitmap = new byte[OduSignalId.TRIBUTARY_SLOT_BITMAP_SIZE]; | ||
84 | + | ||
85 | + slots.forEach(ts -> tributarySlotBitmap[(byte) (ts.index() - 1) / 8] |= 0x1 << ((ts.index() - 1) % 8)); | ||
86 | + return OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap); | ||
87 | + } | ||
88 | + | ||
89 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.net.intent; | ||
17 | + | ||
18 | +import com.google.common.annotations.Beta; | ||
19 | +import com.google.common.base.MoreObjects; | ||
20 | +import org.onosproject.core.ApplicationId; | ||
21 | +import org.onosproject.net.CltSignalType; | ||
22 | +import org.onosproject.net.ConnectPoint; | ||
23 | + | ||
24 | +import java.util.Collections; | ||
25 | + | ||
26 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
27 | + | ||
28 | +/** | ||
29 | + * An optical layer intent between two OduClt ports - in an OTN Topology. | ||
30 | + * No traffic selector or traffic treatment are needed. | ||
31 | + */ | ||
32 | +@Beta | ||
33 | +public final class OpticalOduIntent extends Intent { | ||
34 | + private final ConnectPoint src; | ||
35 | + private final ConnectPoint dst; | ||
36 | + private final CltSignalType signalType; | ||
37 | + private final boolean isBidirectional; | ||
38 | + | ||
39 | + /** | ||
40 | + * Creates an optical ODU intent between the specified connection points. | ||
41 | + * | ||
42 | + * @param appId application identification | ||
43 | + * @param key intent key | ||
44 | + * @param src the source transponder port | ||
45 | + * @param dst the destination transponder port | ||
46 | + * @param signalType CltSignalType signal type | ||
47 | + * @param isBidirectional indicate if intent is bidirectional | ||
48 | + * @param priority priority to use for flows from this intent | ||
49 | + */ | ||
50 | + protected OpticalOduIntent(ApplicationId appId, | ||
51 | + Key key, | ||
52 | + ConnectPoint src, | ||
53 | + ConnectPoint dst, | ||
54 | + CltSignalType signalType, | ||
55 | + boolean isBidirectional, | ||
56 | + int priority) { | ||
57 | + super(appId, key, Collections.emptyList(), priority); | ||
58 | + this.src = checkNotNull(src); | ||
59 | + this.dst = checkNotNull(dst); | ||
60 | + this.signalType = checkNotNull(signalType); | ||
61 | + this.isBidirectional = isBidirectional; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Returns a new optical ODU intent builder. | ||
66 | + * | ||
67 | + * @return intent builder | ||
68 | + */ | ||
69 | + public static Builder builder() { | ||
70 | + return new Builder(); | ||
71 | + } | ||
72 | + | ||
73 | + | ||
74 | + /** | ||
75 | + * Builder for optical ODU intents. | ||
76 | + */ | ||
77 | + public static class Builder extends Intent.Builder { | ||
78 | + private ConnectPoint src; | ||
79 | + private ConnectPoint dst; | ||
80 | + private CltSignalType signalType; | ||
81 | + private boolean isBidirectional; | ||
82 | + | ||
83 | + @Override | ||
84 | + public Builder appId(ApplicationId appId) { | ||
85 | + return (Builder) super.appId(appId); | ||
86 | + } | ||
87 | + | ||
88 | + @Override | ||
89 | + public Builder key(Key key) { | ||
90 | + return (Builder) super.key(key); | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public Builder priority(int priority) { | ||
95 | + return (Builder) super.priority(priority); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Sets the source for the intent that will be built. | ||
100 | + * | ||
101 | + * @param src source to use for built intent | ||
102 | + * @return this builder | ||
103 | + */ | ||
104 | + public Builder src(ConnectPoint src) { | ||
105 | + this.src = src; | ||
106 | + return this; | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Sets the destination for the intent that will be built. | ||
111 | + * | ||
112 | + * @param dst dest to use for built intent | ||
113 | + * @return this builder | ||
114 | + */ | ||
115 | + public Builder dst(ConnectPoint dst) { | ||
116 | + this.dst = dst; | ||
117 | + return this; | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * Sets the ODU signal type for the intent that will be built. | ||
122 | + * | ||
123 | + * @param signalType signal type to use for built intent | ||
124 | + * @return this builder | ||
125 | + */ | ||
126 | + public Builder signalType(CltSignalType signalType) { | ||
127 | + this.signalType = signalType; | ||
128 | + return this; | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Sets the directionality of the intent. | ||
133 | + * | ||
134 | + * @param isBidirectional true if bidirectional, false if unidirectional | ||
135 | + * @return this builder | ||
136 | + */ | ||
137 | + public Builder bidirectional(boolean isBidirectional) { | ||
138 | + this.isBidirectional = isBidirectional; | ||
139 | + return this; | ||
140 | + } | ||
141 | + | ||
142 | + /** | ||
143 | + * Builds an optical ODU intent from the accumulated parameters. | ||
144 | + * | ||
145 | + * @return point to point intent | ||
146 | + */ | ||
147 | + public OpticalOduIntent build() { | ||
148 | + | ||
149 | + return new OpticalOduIntent( | ||
150 | + appId, | ||
151 | + key, | ||
152 | + src, | ||
153 | + dst, | ||
154 | + signalType, | ||
155 | + isBidirectional, | ||
156 | + priority | ||
157 | + ); | ||
158 | + } | ||
159 | + } | ||
160 | + | ||
161 | + /** | ||
162 | + * Constructor for serializer. | ||
163 | + */ | ||
164 | + protected OpticalOduIntent() { | ||
165 | + super(); | ||
166 | + this.src = null; | ||
167 | + this.dst = null; | ||
168 | + this.signalType = null; | ||
169 | + this.isBidirectional = false; | ||
170 | + } | ||
171 | + | ||
172 | + /** | ||
173 | + * Returns the source transponder port. | ||
174 | + * | ||
175 | + * @return source transponder port | ||
176 | + */ | ||
177 | + public ConnectPoint getSrc() { | ||
178 | + return src; | ||
179 | + } | ||
180 | + | ||
181 | + /** | ||
182 | + * Returns the destination transponder port. | ||
183 | + * | ||
184 | + * @return source transponder port | ||
185 | + */ | ||
186 | + public ConnectPoint getDst() { | ||
187 | + return dst; | ||
188 | + } | ||
189 | + | ||
190 | + /** | ||
191 | + * Returns the CltSignalType signal type. | ||
192 | + * | ||
193 | + * @return CltSignalType signal type | ||
194 | + */ | ||
195 | + public CltSignalType getSignalType() { | ||
196 | + return signalType; | ||
197 | + } | ||
198 | + | ||
199 | + /** | ||
200 | + * Returns the directionality of the intent. | ||
201 | + * | ||
202 | + * @return true if bidirectional, false if unidirectional | ||
203 | + */ | ||
204 | + public boolean isBidirectional() { | ||
205 | + return isBidirectional; | ||
206 | + } | ||
207 | + | ||
208 | + @Override | ||
209 | + public String toString() { | ||
210 | + return MoreObjects.toStringHelper(this) | ||
211 | + .add("id", id()) | ||
212 | + .add("key", key()) | ||
213 | + .add("appId", appId()) | ||
214 | + .add("priority", priority()) | ||
215 | + .add("resources", resources()) | ||
216 | + .add("src", src) | ||
217 | + .add("dst", dst) | ||
218 | + .add("signalType", signalType) | ||
219 | + .add("isBidirectional", isBidirectional) | ||
220 | + .toString(); | ||
221 | + } | ||
222 | + | ||
223 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -36,6 +36,7 @@ import org.onosproject.net.OchPort; | ... | @@ -36,6 +36,7 @@ import org.onosproject.net.OchPort; |
36 | import org.onosproject.net.OduCltPort; | 36 | import org.onosproject.net.OduCltPort; |
37 | import org.onosproject.net.OduSignalId; | 37 | import org.onosproject.net.OduSignalId; |
38 | import org.onosproject.net.OduSignalType; | 38 | import org.onosproject.net.OduSignalType; |
39 | +import org.onosproject.net.OduSignalUtils; | ||
39 | import org.onosproject.net.Port; | 40 | import org.onosproject.net.Port; |
40 | import org.onosproject.net.TributarySlot; | 41 | import org.onosproject.net.TributarySlot; |
41 | import org.onosproject.net.behaviour.TributarySlotQuery; | 42 | import org.onosproject.net.behaviour.TributarySlotQuery; |
... | @@ -276,7 +277,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -276,7 +277,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
276 | } | 277 | } |
277 | 278 | ||
278 | private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) { | 279 | private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) { |
279 | - OduSignalType oduSignalType = mappingCltSignalTypeToOduSignalType(signalType); | 280 | + OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType); |
280 | int requestedTsNum = oduSignalType.tributarySlots(); | 281 | int requestedTsNum = oduSignalType.tributarySlots(); |
281 | Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst); | 282 | Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst); |
282 | if (commonTributarySlots.isEmpty()) { | 283 | if (commonTributarySlots.isEmpty()) { |
... | @@ -339,7 +340,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -339,7 +340,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
339 | CltSignalType signalType, | 340 | CltSignalType signalType, |
340 | boolean multiplexingSupported) { | 341 | boolean multiplexingSupported) { |
341 | 342 | ||
342 | - OduSignalType oduSignalType = mappingCltSignalTypeToOduSignalType(signalType); | 343 | + OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType); |
343 | 344 | ||
344 | return Tools.stream(intentService.getIntents()) | 345 | return Tools.stream(intentService.getIntents()) |
345 | .filter(x -> x instanceof OpticalConnectivityIntent) | 346 | .filter(x -> x instanceof OpticalConnectivityIntent) |
... | @@ -509,23 +510,25 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -509,23 +510,25 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
509 | OduSignalType ochPortOduSignalType; | 510 | OduSignalType ochPortOduSignalType; |
510 | 511 | ||
511 | if (srcPort instanceof OduCltPort) { | 512 | if (srcPort instanceof OduCltPort) { |
512 | - oduCltPortOduSignalType = mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType()); | 513 | + oduCltPortOduSignalType = |
514 | + OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType()); | ||
513 | ochPortOduSignalType = ((OchPort) dstPort).signalType(); | 515 | ochPortOduSignalType = ((OchPort) dstPort).signalType(); |
514 | 516 | ||
515 | selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType)); | 517 | selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType)); |
516 | // use Instruction of OduSignalId only in case of ODU Multiplexing | 518 | // use Instruction of OduSignalId only in case of ODU Multiplexing |
517 | if (oduCltPortOduSignalType != ochPortOduSignalType) { | 519 | if (oduCltPortOduSignalType != ochPortOduSignalType) { |
518 | - OduSignalId oduSignalId = buildOduSignalId(ochPortOduSignalType, slots); | 520 | + OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots); |
519 | treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId)); | 521 | treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId)); |
520 | } | 522 | } |
521 | } else { // srcPort is OchPort | 523 | } else { // srcPort is OchPort |
522 | - oduCltPortOduSignalType = mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType()); | 524 | + oduCltPortOduSignalType = |
525 | + OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType()); | ||
523 | ochPortOduSignalType = ((OchPort) srcPort).signalType(); | 526 | ochPortOduSignalType = ((OchPort) srcPort).signalType(); |
524 | 527 | ||
525 | selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType)); | 528 | selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType)); |
526 | // use Criteria of OduSignalId only in case of ODU Multiplexing | 529 | // use Criteria of OduSignalId only in case of ODU Multiplexing |
527 | if (oduCltPortOduSignalType != ochPortOduSignalType) { | 530 | if (oduCltPortOduSignalType != ochPortOduSignalType) { |
528 | - OduSignalId oduSignalId = buildOduSignalId(ochPortOduSignalType, slots); | 531 | + OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots); |
529 | selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId)); | 532 | selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId)); |
530 | } | 533 | } |
531 | } | 534 | } |
... | @@ -544,19 +547,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -544,19 +547,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
544 | return flowRule; | 547 | return flowRule; |
545 | } | 548 | } |
546 | 549 | ||
547 | - OduSignalId buildOduSignalId(OduSignalType ochPortSignalType, Set<TributarySlot> slots) { | ||
548 | - int tributaryPortNumber = findFirstTributarySlotIndex(slots); | ||
549 | - int tributarySlotLen = ochPortSignalType.tributarySlots(); | ||
550 | - byte[] tributarySlotBitmap = new byte[OduSignalId.TRIBUTARY_SLOT_BITMAP_SIZE]; | ||
551 | - | ||
552 | - slots.forEach(ts -> tributarySlotBitmap[(byte) (ts.index() - 1) / 8] |= 0x1 << ((ts.index() - 1) % 8)); | ||
553 | - return OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap); | ||
554 | - } | ||
555 | - | ||
556 | - private int findFirstTributarySlotIndex(Set<TributarySlot> tributarySlots) { | ||
557 | - return (int) tributarySlots.stream().findFirst().get().index(); | ||
558 | - } | ||
559 | - | ||
560 | private boolean isMultiplexingSupported(ConnectPoint cp) { | 550 | private boolean isMultiplexingSupported(ConnectPoint cp) { |
561 | Driver driver = driverService.getDriver(cp.deviceId()); | 551 | Driver driver = driverService.getDriver(cp.deviceId()); |
562 | return driver != null | 552 | return driver != null |
... | @@ -565,28 +555,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -565,28 +555,6 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
565 | } | 555 | } |
566 | 556 | ||
567 | /** | 557 | /** |
568 | - * Maps from Intent's OduClt SignalType to OduSignalType. | ||
569 | - * | ||
570 | - * @param cltSignalType OduClt port signal type | ||
571 | - * @return OduSignalType the result of mapping CltSignalType to OduSignalType | ||
572 | - */ | ||
573 | - OduSignalType mappingCltSignalTypeToOduSignalType(CltSignalType cltSignalType) { | ||
574 | - switch (cltSignalType) { | ||
575 | - case CLT_1GBE: | ||
576 | - return OduSignalType.ODU0; | ||
577 | - case CLT_10GBE: | ||
578 | - return OduSignalType.ODU2; | ||
579 | - case CLT_40GBE: | ||
580 | - return OduSignalType.ODU3; | ||
581 | - case CLT_100GBE: | ||
582 | - return OduSignalType.ODU4; | ||
583 | - default: | ||
584 | - log.error("Unsupported CltSignalType {}", cltSignalType); | ||
585 | - return OduSignalType.ODU0; | ||
586 | - } | ||
587 | - } | ||
588 | - | ||
589 | - /** | ||
590 | * Finds the common TributarySlots available on the two connect points. | 558 | * Finds the common TributarySlots available on the two connect points. |
591 | * | 559 | * |
592 | * @param src source connect point | 560 | * @param src source connect point | ... | ... |
core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
0 → 100644
This diff is collapsed. Click to expand it.
... | @@ -38,6 +38,7 @@ import org.onosproject.net.OchSignal; | ... | @@ -38,6 +38,7 @@ import org.onosproject.net.OchSignal; |
38 | import org.onosproject.net.OduCltPort; | 38 | import org.onosproject.net.OduCltPort; |
39 | import org.onosproject.net.OduSignalId; | 39 | import org.onosproject.net.OduSignalId; |
40 | import org.onosproject.net.OduSignalType; | 40 | import org.onosproject.net.OduSignalType; |
41 | +import org.onosproject.net.OduSignalUtils; | ||
41 | import org.onosproject.net.Port; | 42 | import org.onosproject.net.Port; |
42 | import org.onosproject.net.PortNumber; | 43 | import org.onosproject.net.PortNumber; |
43 | import org.onosproject.net.TributarySlot; | 44 | import org.onosproject.net.TributarySlot; |
... | @@ -429,7 +430,7 @@ public class OpticalCircuitIntentCompilerTest { | ... | @@ -429,7 +430,7 @@ public class OpticalCircuitIntentCompilerTest { |
429 | TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder(); | 430 | TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder(); |
430 | Set<TributarySlot> slots = new HashSet<>(); | 431 | Set<TributarySlot> slots = new HashSet<>(); |
431 | slots.add(TributarySlot.of(1)); | 432 | slots.add(TributarySlot.of(1)); |
432 | - OduSignalId oduSignalId = sut.buildOduSignalId(D1P2.signalType(), slots); | 433 | + OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots); |
433 | treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId)); | 434 | treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId)); |
434 | treatmentBuilder1.setOutput(ochSrcCP.port()); | 435 | treatmentBuilder1.setOutput(ochSrcCP.port()); |
435 | assertThat(rule1.treatment(), is(treatmentBuilder1.build())); | 436 | assertThat(rule1.treatment(), is(treatmentBuilder1.build())); | ... | ... |
core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
0 → 100644
This diff is collapsed. Click to expand it.
... | @@ -163,6 +163,7 @@ import org.onosproject.net.intent.MplsPathIntent; | ... | @@ -163,6 +163,7 @@ import org.onosproject.net.intent.MplsPathIntent; |
163 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; | 163 | import org.onosproject.net.intent.MultiPointToSinglePointIntent; |
164 | import org.onosproject.net.intent.OpticalCircuitIntent; | 164 | import org.onosproject.net.intent.OpticalCircuitIntent; |
165 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 165 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
166 | +import org.onosproject.net.intent.OpticalOduIntent; | ||
166 | import org.onosproject.net.intent.OpticalPathIntent; | 167 | import org.onosproject.net.intent.OpticalPathIntent; |
167 | import org.onosproject.net.intent.PathIntent; | 168 | import org.onosproject.net.intent.PathIntent; |
168 | import org.onosproject.net.intent.PointToPointIntent; | 169 | import org.onosproject.net.intent.PointToPointIntent; |
... | @@ -422,6 +423,7 @@ public final class KryoNamespaces { | ... | @@ -422,6 +423,7 @@ public final class KryoNamespaces { |
422 | OpticalConnectivityIntent.class, | 423 | OpticalConnectivityIntent.class, |
423 | OpticalPathIntent.class, | 424 | OpticalPathIntent.class, |
424 | OpticalCircuitIntent.class, | 425 | OpticalCircuitIntent.class, |
426 | + OpticalOduIntent.class, | ||
425 | DiscreteResource.class, | 427 | DiscreteResource.class, |
426 | ContinuousResource.class, | 428 | ContinuousResource.class, |
427 | DiscreteResourceId.class, | 429 | DiscreteResourceId.class, | ... | ... |
-
Please register or login to post a comment