Committed by
Gerrit Code Review
ONOS-3503 Remove OchPort out of core.
- Implementation of a Behavior OpticalDevice has the knowledge of translating annotations into optical specific port. - OpticalDeviceServiceView checks if the Device is a OpticalDevice and translate all the Ports to optical specific port before returning. - This commit contains feedbacks, issues, and fixes by Michele Santuari. - Note: 3 more Port types to go (OduClt, Oms, Otu) Change-Id: I4cbda8bc1922fbdd4dac8de8d02294bad74b8058
Showing
44 changed files
with
1795 additions
and
86 deletions
... | @@ -30,7 +30,6 @@ import org.onosproject.net.ConnectPoint; | ... | @@ -30,7 +30,6 @@ import org.onosproject.net.ConnectPoint; |
30 | import org.onosproject.net.Device; | 30 | import org.onosproject.net.Device; |
31 | import org.onosproject.net.Host; | 31 | import org.onosproject.net.Host; |
32 | import org.onosproject.net.Link; | 32 | import org.onosproject.net.Link; |
33 | -import org.onosproject.net.OchPort; | ||
34 | import org.onosproject.net.OduCltPort; | 33 | import org.onosproject.net.OduCltPort; |
35 | import org.onosproject.net.OduSignalType; | 34 | import org.onosproject.net.OduSignalType; |
36 | import org.onosproject.net.Path; | 35 | import org.onosproject.net.Path; |
... | @@ -46,6 +45,7 @@ import org.onosproject.net.intent.IntentState; | ... | @@ -46,6 +45,7 @@ import org.onosproject.net.intent.IntentState; |
46 | import org.onosproject.net.intent.OpticalCircuitIntent; | 45 | import org.onosproject.net.intent.OpticalCircuitIntent; |
47 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 46 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
48 | import org.onosproject.net.intent.PointToPointIntent; | 47 | import org.onosproject.net.intent.PointToPointIntent; |
48 | +import org.onosproject.net.optical.OchPort; | ||
49 | import org.onosproject.net.topology.LinkWeight; | 49 | import org.onosproject.net.topology.LinkWeight; |
50 | import org.onosproject.net.topology.PathService; | 50 | import org.onosproject.net.topology.PathService; |
51 | import org.onosproject.net.topology.TopologyEdge; | 51 | import org.onosproject.net.topology.TopologyEdge; |
... | @@ -60,6 +60,7 @@ import java.util.Set; | ... | @@ -60,6 +60,7 @@ import java.util.Set; |
60 | 60 | ||
61 | import static com.google.common.base.Preconditions.checkArgument; | 61 | import static com.google.common.base.Preconditions.checkArgument; |
62 | import static com.google.common.base.Preconditions.checkNotNull; | 62 | import static com.google.common.base.Preconditions.checkNotNull; |
63 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
63 | 64 | ||
64 | /** | 65 | /** |
65 | * OpticalPathProvisioner listens for event notifications from the Intent F/W. | 66 | * OpticalPathProvisioner listens for event notifications from the Intent F/W. |
... | @@ -100,6 +101,7 @@ public class OpticalPathProvisioner { | ... | @@ -100,6 +101,7 @@ public class OpticalPathProvisioner { |
100 | 101 | ||
101 | @Activate | 102 | @Activate |
102 | protected void activate() { | 103 | protected void activate() { |
104 | + deviceService = opticalView(deviceService); | ||
103 | intentService.addListener(pathProvisioner); | 105 | intentService.addListener(pathProvisioner); |
104 | appId = coreService.registerApplication("org.onosproject.optical"); | 106 | appId = coreService.registerApplication("org.onosproject.optical"); |
105 | initOpticalPorts(); | 107 | initOpticalPorts(); | ... | ... |
... | @@ -21,7 +21,6 @@ import org.apache.karaf.shell.commands.Option; | ... | @@ -21,7 +21,6 @@ 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.Device; |
24 | -import org.onosproject.net.OchPort; | ||
25 | import org.onosproject.net.OduCltPort; | 24 | import org.onosproject.net.OduCltPort; |
26 | import org.onosproject.net.DeviceId; | 25 | import org.onosproject.net.DeviceId; |
27 | import org.onosproject.net.OduSignalType; | 26 | import org.onosproject.net.OduSignalType; |
... | @@ -32,10 +31,12 @@ import org.onosproject.net.intent.IntentService; | ... | @@ -32,10 +31,12 @@ import org.onosproject.net.intent.IntentService; |
32 | import org.onosproject.net.intent.OpticalCircuitIntent; | 31 | import org.onosproject.net.intent.OpticalCircuitIntent; |
33 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 32 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
34 | import org.onosproject.net.intent.OpticalOduIntent; | 33 | import org.onosproject.net.intent.OpticalOduIntent; |
34 | +import org.onosproject.net.optical.OchPort; | ||
35 | 35 | ||
36 | import java.util.List; | 36 | import java.util.List; |
37 | 37 | ||
38 | import static com.google.common.base.Preconditions.checkArgument; | 38 | import static com.google.common.base.Preconditions.checkArgument; |
39 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * Installs optical connectivity or circuit intents, depending on given port types. | 42 | * Installs optical connectivity or circuit intents, depending on given port types. |
... | @@ -93,7 +94,8 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -93,7 +94,8 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
93 | return; | 94 | return; |
94 | } | 95 | } |
95 | 96 | ||
96 | - DeviceService deviceService = get(DeviceService.class); | 97 | + DeviceService deviceService = opticalView(get(DeviceService.class)); |
98 | + | ||
97 | Port srcPort = deviceService.getPort(ingress.deviceId(), ingress.port()); | 99 | Port srcPort = deviceService.getPort(ingress.deviceId(), ingress.port()); |
98 | Port dstPort = deviceService.getPort(egress.deviceId(), egress.port()); | 100 | Port dstPort = deviceService.getPort(egress.deviceId(), egress.port()); |
99 | 101 | ||
... | @@ -142,6 +144,19 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { | ... | @@ -142,6 +144,19 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand { |
142 | .signalType(signalType) | 144 | .signalType(signalType) |
143 | .bidirectional(bidirectional) | 145 | .bidirectional(bidirectional) |
144 | .build(); | 146 | .build(); |
147 | + } else if (srcPort instanceof org.onosproject.net.OchPort && | ||
148 | + dstPort instanceof org.onosproject.net.OchPort) { | ||
149 | + print("WARN: encountered old OchPort model"); | ||
150 | + // old OchPort model can be removed when ready | ||
151 | + OduSignalType signalType = ((org.onosproject.net.OchPort) srcPort).signalType(); | ||
152 | + intent = OpticalConnectivityIntent.builder() | ||
153 | + .appId(appId()) | ||
154 | + .key(key()) | ||
155 | + .src(ingress) | ||
156 | + .dst(egress) | ||
157 | + .signalType(signalType) | ||
158 | + .bidirectional(bidirectional) | ||
159 | + .build(); | ||
145 | } else { | 160 | } else { |
146 | print("Unable to create optical intent between connect points %s and %s", ingress, egress); | 161 | print("Unable to create optical intent between connect points %s and %s", ingress, egress); |
147 | return; | 162 | return; | ... | ... |
... | @@ -25,19 +25,20 @@ import org.apache.karaf.shell.commands.Option; | ... | @@ -25,19 +25,20 @@ import org.apache.karaf.shell.commands.Option; |
25 | import org.onlab.util.Frequency; | 25 | import org.onlab.util.Frequency; |
26 | import org.onosproject.utils.Comparators; | 26 | import org.onosproject.utils.Comparators; |
27 | import org.onosproject.net.Device; | 27 | import org.onosproject.net.Device; |
28 | -import org.onosproject.net.OchPort; | ||
29 | import org.onosproject.net.OduCltPort; | 28 | import org.onosproject.net.OduCltPort; |
30 | import org.onosproject.net.OmsPort; | 29 | import org.onosproject.net.OmsPort; |
31 | import org.onosproject.net.OtuPort; | 30 | import org.onosproject.net.OtuPort; |
32 | import org.onosproject.net.Port; | 31 | import org.onosproject.net.Port; |
33 | import org.onosproject.net.PortNumber; | 32 | import org.onosproject.net.PortNumber; |
34 | import org.onosproject.net.device.DeviceService; | 33 | import org.onosproject.net.device.DeviceService; |
35 | - | 34 | +import org.onosproject.net.optical.OchPort; |
35 | +import org.onosproject.net.optical.OpticalDevice; | ||
36 | import java.util.ArrayList; | 36 | import java.util.ArrayList; |
37 | import java.util.Collections; | 37 | import java.util.Collections; |
38 | import java.util.List; | 38 | import java.util.List; |
39 | 39 | ||
40 | import static org.onosproject.net.DeviceId.deviceId; | 40 | import static org.onosproject.net.DeviceId.deviceId; |
41 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
41 | 42 | ||
42 | /** | 43 | /** |
43 | * Lists all ports or all ports of a device. | 44 | * Lists all ports or all ports of a device. |
... | @@ -65,7 +66,7 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -65,7 +66,7 @@ public class DevicePortsListCommand extends DevicesListCommand { |
65 | 66 | ||
66 | @Override | 67 | @Override |
67 | protected void execute() { | 68 | protected void execute() { |
68 | - DeviceService service = get(DeviceService.class); | 69 | + DeviceService service = opticalView(get(DeviceService.class)); |
69 | if (uri == null) { | 70 | if (uri == null) { |
70 | if (outputJson()) { | 71 | if (outputJson()) { |
71 | print("%s", jsonPorts(service, getSortedDevices(service))); | 72 | print("%s", jsonPorts(service, getSortedDevices(service))); |
... | @@ -154,10 +155,37 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -154,10 +155,37 @@ public class DevicePortsListCommand extends DevicesListCommand { |
154 | String annotations = annotations(port.annotations()); | 155 | String annotations = annotations(port.annotations()); |
155 | switch (port.type()) { | 156 | switch (port.type()) { |
156 | case OCH: | 157 | case OCH: |
157 | - print(FMT_OCH, portName, portIsEnabled, portType, | 158 | + if (port instanceof org.onosproject.net.OchPort) { |
158 | - ((OchPort) port).signalType().toString(), | 159 | + // old OchPort model |
159 | - ((OchPort) port).isTunable() ? "yes" : "no", annotations); | 160 | + org.onosproject.net.OchPort oPort = (org.onosproject.net.OchPort) port; |
160 | - break; | 161 | + print("WARN: OchPort in old model"); |
162 | + print(FMT_OCH, portName, portIsEnabled, portType, | ||
163 | + oPort.signalType().toString(), | ||
164 | + oPort.isTunable() ? "yes" : "no", annotations); | ||
165 | + break; | ||
166 | + } | ||
167 | + if (port instanceof OchPort) { | ||
168 | + OchPort och = (OchPort) port; | ||
169 | + print(FMT_OCH, portName, portIsEnabled, portType, | ||
170 | + och.signalType().toString(), | ||
171 | + och.isTunable() ? "yes" : "no", annotations); | ||
172 | + break; | ||
173 | + } else if (port.element().is(OpticalDevice.class)) { | ||
174 | + // Note: should never reach here, but | ||
175 | + // leaving it here as an example to | ||
176 | + // manually translate to specific port. | ||
177 | + OpticalDevice optDevice = port.element().as(OpticalDevice.class); | ||
178 | + if (optDevice.portIs(port, OchPort.class)) { | ||
179 | + OchPort och = optDevice.portAs(port, OchPort.class).get(); | ||
180 | + print(FMT_OCH, portName, portIsEnabled, portType, | ||
181 | + och.signalType().toString(), | ||
182 | + och.isTunable() ? "yes" : "no", annotations); | ||
183 | + break; | ||
184 | + } | ||
185 | + } | ||
186 | + print("WARN: OchPort but not on OpticalDevice or ill-formed"); | ||
187 | + print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations); | ||
188 | + break; | ||
161 | case ODUCLT: | 189 | case ODUCLT: |
162 | print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, | 190 | print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, |
163 | ((OduCltPort) port).signalType().toString(), annotations); | 191 | ((OduCltPort) port).signalType().toString(), annotations); | ... | ... |
... | @@ -24,7 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -24,7 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull; |
24 | * Implementation of OCh port (Optical Channel). | 24 | * Implementation of OCh port (Optical Channel). |
25 | * Also referred to as a line side port (L-port) or narrow band port. | 25 | * Also referred to as a line side port (L-port) or narrow band port. |
26 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" | 26 | * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" |
27 | + * | ||
28 | + * @deprecated in Goldeneye (1.6.0) | ||
27 | */ | 29 | */ |
30 | +@Deprecated | ||
28 | public class OchPort extends DefaultPort { | 31 | public class OchPort extends DefaultPort { |
29 | 32 | ||
30 | private final OduSignalType signalType; | 33 | private final OduSignalType signalType; | ... | ... |
... | @@ -37,7 +37,7 @@ public class DefaultPortDescription extends AbstractDescription | ... | @@ -37,7 +37,7 @@ public class DefaultPortDescription extends AbstractDescription |
37 | private final long portSpeed; | 37 | private final long portSpeed; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * Creates a port description using the supplied information. | 40 | + * Creates a DEFAULT_SPEED COPPER port description using the supplied information. |
41 | * | 41 | * |
42 | * @param number port number | 42 | * @param number port number |
43 | * @param isEnabled port enabled state | 43 | * @param isEnabled port enabled state | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.net.device; | 16 | package org.onosproject.net.device; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | + | ||
19 | import org.onosproject.net.OchSignal; | 20 | import org.onosproject.net.OchSignal; |
20 | import org.onosproject.net.OduSignalType; | 21 | import org.onosproject.net.OduSignalType; |
21 | import org.onosproject.net.Port; | 22 | import org.onosproject.net.Port; |
... | @@ -26,7 +27,10 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -26,7 +27,10 @@ import static com.google.common.base.Preconditions.checkNotNull; |
26 | 27 | ||
27 | /** | 28 | /** |
28 | * Default implementation of immutable OCh port description. | 29 | * Default implementation of immutable OCh port description. |
30 | + * | ||
31 | + * @deprecated in Goldeneye (1.6.0) | ||
29 | */ | 32 | */ |
33 | +@Deprecated | ||
30 | public class OchPortDescription extends DefaultPortDescription { | 34 | public class OchPortDescription extends DefaultPortDescription { |
31 | 35 | ||
32 | private final OduSignalType signalType; | 36 | private final OduSignalType signalType; |
... | @@ -42,7 +46,10 @@ public class OchPortDescription extends DefaultPortDescription { | ... | @@ -42,7 +46,10 @@ public class OchPortDescription extends DefaultPortDescription { |
42 | * @param isTunable tunable wavelength capability | 46 | * @param isTunable tunable wavelength capability |
43 | * @param lambda OCh signal | 47 | * @param lambda OCh signal |
44 | * @param annotations optional key/value annotations map | 48 | * @param annotations optional key/value annotations map |
49 | + * | ||
50 | + * @deprecated in Goldeneye (1.6.0) | ||
45 | */ | 51 | */ |
52 | + @Deprecated | ||
46 | public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, | 53 | public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, |
47 | boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) { | 54 | boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) { |
48 | super(number, isEnabled, Port.Type.OCH, 0, annotations); | 55 | super(number, isEnabled, Port.Type.OCH, 0, annotations); |
... | @@ -59,7 +66,10 @@ public class OchPortDescription extends DefaultPortDescription { | ... | @@ -59,7 +66,10 @@ public class OchPortDescription extends DefaultPortDescription { |
59 | * @param isTunable tunable wavelength capability | 66 | * @param isTunable tunable wavelength capability |
60 | * @param lambda OCh signal | 67 | * @param lambda OCh signal |
61 | * @param annotations optional key/value annotations map | 68 | * @param annotations optional key/value annotations map |
69 | + * | ||
70 | + * @deprecated in Goldeneye (1.6.0) | ||
62 | */ | 71 | */ |
72 | + @Deprecated | ||
63 | public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, | 73 | public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable, |
64 | OchSignal lambda, SparseAnnotations annotations) { | 74 | OchSignal lambda, SparseAnnotations annotations) { |
65 | super(base, annotations); | 75 | super(base, annotations); | ... | ... |
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.optical; | ||
17 | + | ||
18 | +import org.onosproject.net.OchSignal; | ||
19 | +import org.onosproject.net.OduSignalType; | ||
20 | +import org.onosproject.net.Port; | ||
21 | + | ||
22 | +import com.google.common.annotations.Beta; | ||
23 | + | ||
24 | +/** | ||
25 | + * OCh port (Optical Channel). | ||
26 | + * Also referred to as a line side port (L-port) or narrow band port. | ||
27 | + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" | ||
28 | + */ | ||
29 | +@Beta | ||
30 | +public interface OchPort extends Port { | ||
31 | + | ||
32 | + /** | ||
33 | + * Returns ODU signal type. | ||
34 | + * | ||
35 | + * @return ODU signal type | ||
36 | + */ | ||
37 | + public OduSignalType signalType(); | ||
38 | + | ||
39 | + /** | ||
40 | + * Returns true if port is wavelength tunable. | ||
41 | + * | ||
42 | + * @return tunable wavelength capability | ||
43 | + */ | ||
44 | + public boolean isTunable(); | ||
45 | + | ||
46 | + /** | ||
47 | + * Returns OCh signal. | ||
48 | + * | ||
49 | + * @return OCh signal | ||
50 | + */ | ||
51 | + public OchSignal lambda(); | ||
52 | + | ||
53 | +} |
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.optical; | ||
17 | + | ||
18 | +import java.util.Optional; | ||
19 | + | ||
20 | +import org.onosproject.net.Device; | ||
21 | +import org.onosproject.net.Port; | ||
22 | +import org.onosproject.net.driver.Behaviour; | ||
23 | + | ||
24 | +import com.google.common.annotations.Beta; | ||
25 | + | ||
26 | + | ||
27 | +// TODO consider more fine grained device type. e.g., Transponder, WSS, ROADM | ||
28 | +/** | ||
29 | + * Representation of a optical network infrastructure device. | ||
30 | + */ | ||
31 | +@Beta | ||
32 | +public interface OpticalDevice extends Device, Behaviour { | ||
33 | + | ||
34 | + /** | ||
35 | + * Returns true if {@code port} is capable of being projected as the | ||
36 | + * specified class. | ||
37 | + * | ||
38 | + * @param port Port instance to test | ||
39 | + * @param portClass requested projection class | ||
40 | + * @param <T> type of Port | ||
41 | + * @return true if the requested projection is supported | ||
42 | + */ | ||
43 | + <T extends Port> boolean portIs(Port port, Class<T> portClass); | ||
44 | + | ||
45 | + /** | ||
46 | + * Returns the specified projection of the {@code port} if such projection | ||
47 | + * is supported. | ||
48 | + * | ||
49 | + * @param port Port instance to project | ||
50 | + * @param portClass requested projection class | ||
51 | + * @param <T> type of Port | ||
52 | + * @return projection instance or empty if not supported. | ||
53 | + */ | ||
54 | + <T extends Port> Optional<T> portAs(Port port, Class<T> portClass); | ||
55 | + | ||
56 | + /** | ||
57 | + * Returns most specific projection of the {@code port} or the {@code port} | ||
58 | + * itself. | ||
59 | + * | ||
60 | + * @param port Port instance | ||
61 | + * @return projection instance or {@code port} itself | ||
62 | + */ | ||
63 | + Port port(Port port); | ||
64 | + | ||
65 | +} |
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.optical.device; | ||
17 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | +import static com.google.common.base.Preconditions.checkState; | ||
20 | +import static org.slf4j.LoggerFactory.getLogger; | ||
21 | + | ||
22 | +import java.util.Map; | ||
23 | +import java.util.Optional; | ||
24 | +import org.onlab.osgi.DefaultServiceDirectory; | ||
25 | +import org.onosproject.net.Device; | ||
26 | +import org.onosproject.net.Port; | ||
27 | +import org.onosproject.net.device.DeviceService; | ||
28 | +import org.onosproject.net.driver.AbstractBehaviour; | ||
29 | +import org.onosproject.net.driver.DriverData; | ||
30 | +import org.onosproject.net.optical.OchPort; | ||
31 | +import org.onosproject.net.optical.OpticalDevice; | ||
32 | +import org.onosproject.net.optical.device.port.OchPortMapper; | ||
33 | +import org.onosproject.net.optical.device.port.PortMapper; | ||
34 | +import org.onosproject.net.optical.utils.ForwardingDevice; | ||
35 | +import org.slf4j.Logger; | ||
36 | + | ||
37 | +import com.google.common.annotations.Beta; | ||
38 | +import com.google.common.base.MoreObjects; | ||
39 | +import com.google.common.collect.ImmutableMap; | ||
40 | + | ||
41 | +// FIXME This needs to be moved back to org.onosproject.net.optical.impl | ||
42 | +// after optical driver package separation process is complete. | ||
43 | +/** | ||
44 | + * Implementation of {@link OpticalDevice}. | ||
45 | + * <p> | ||
46 | + * Currently supports | ||
47 | + * <ul> | ||
48 | + * <li> {@link OchPort} | ||
49 | + * </ul> | ||
50 | + */ | ||
51 | +@Beta | ||
52 | +public class DefaultOpticalDevice | ||
53 | + extends AbstractBehaviour | ||
54 | + implements OpticalDevice, ForwardingDevice { | ||
55 | + | ||
56 | + private static final Logger log = getLogger(DefaultOpticalDevice.class); | ||
57 | + | ||
58 | + // shared Port type handler map. | ||
59 | + // TODO Is there a use case, where we need to differentiate this map per Device? | ||
60 | + private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS | ||
61 | + = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder() | ||
62 | + .put(OchPort.class, new OchPortMapper()) | ||
63 | + // TODO add other optical port type here | ||
64 | + .build(); | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | + // effectively final | ||
69 | + private Device delegate; | ||
70 | + | ||
71 | + // Default constructor required as a Behaviour. | ||
72 | + public DefaultOpticalDevice() {} | ||
73 | + | ||
74 | + @Override | ||
75 | + public Device delegate() { | ||
76 | + if (delegate == null) { | ||
77 | + // dirty work around. | ||
78 | + // wanted to pass delegate Device at construction, | ||
79 | + // but was not possible. A Behaviour requires no-arg constructor. | ||
80 | + checkState(data() != null, "DriverData must exist"); | ||
81 | + DriverData data = data(); | ||
82 | + DeviceService service = DefaultServiceDirectory.getService(DeviceService.class); | ||
83 | + delegate = checkNotNull(service.getDevice(data.deviceId()), | ||
84 | + "No Device found for %s", data.deviceId()); | ||
85 | + } | ||
86 | + return delegate; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public <T extends Port> boolean portIs(Port port, Class<T> portClass) { | ||
91 | + | ||
92 | + PortMapper<? extends Port> mapper = MAPPERS.get(portClass); | ||
93 | + if (mapper != null) { | ||
94 | + return mapper.is(port); | ||
95 | + } | ||
96 | + return false; | ||
97 | + } | ||
98 | + | ||
99 | + @Override | ||
100 | + public <T extends Port> Optional<T> portAs(Port port, Class<T> portClass) { | ||
101 | + PortMapper<? extends Port> mapper = MAPPERS.get(portClass); | ||
102 | + if (mapper != null) { | ||
103 | + return (Optional<T>) (mapper.as(port)); | ||
104 | + } | ||
105 | + return Optional.empty(); | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public Port port(Port port) { | ||
110 | + for (PortMapper<? extends Port> mapper : MAPPERS.values()) { | ||
111 | + if (mapper.is(port)) { | ||
112 | + return mapper.as(port).map(Port.class::cast).orElse(port); | ||
113 | + } | ||
114 | + } | ||
115 | + return port; | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public boolean equals(Object obj) { | ||
120 | + return delegate().equals(obj); | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public int hashCode() { | ||
125 | + return delegate().hashCode(); | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public String toString() { | ||
130 | + return MoreObjects.toStringHelper(this) | ||
131 | + .add("delegate", delegate) | ||
132 | + .toString(); | ||
133 | + } | ||
134 | +} |
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.optical.device; | ||
17 | + | ||
18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
19 | + | ||
20 | +import java.io.IOException; | ||
21 | +import java.util.Optional; | ||
22 | + | ||
23 | +import org.onosproject.net.Annotations; | ||
24 | +import org.onosproject.net.DefaultAnnotations; | ||
25 | +import org.onosproject.net.DefaultAnnotations.Builder; | ||
26 | +import org.onosproject.net.OchSignal; | ||
27 | +import org.onosproject.net.OduSignalType; | ||
28 | +import org.onosproject.net.Port; | ||
29 | +import org.onosproject.net.PortNumber; | ||
30 | +import org.onosproject.net.SparseAnnotations; | ||
31 | +import org.onosproject.net.device.DefaultPortDescription; | ||
32 | +import org.onosproject.net.device.PortDescription; | ||
33 | +import org.onosproject.net.optical.OchPort; | ||
34 | +import org.onosproject.net.optical.impl.DefaultOchPort; | ||
35 | +import org.onosproject.net.optical.json.OchSignalCodec; | ||
36 | +import org.slf4j.Logger; | ||
37 | + | ||
38 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
39 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
40 | +import com.google.common.annotations.Beta; | ||
41 | + | ||
42 | +/** | ||
43 | + * OCh port related helpers. | ||
44 | + */ | ||
45 | +@Beta | ||
46 | +public final class OchPortHelper { | ||
47 | + | ||
48 | + private static final Logger log = getLogger(OchPortHelper.class); | ||
49 | + | ||
50 | + private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
51 | + | ||
52 | + // Annotation keys | ||
53 | + private static final String SIGNAL_TYPE = "signalType"; | ||
54 | + private static final String TUNABLE = "tunable"; | ||
55 | + private static final String LAMBDA = "lambda"; | ||
56 | + | ||
57 | + /** | ||
58 | + * Creates OCh port DefaultPortDescription based on the supplied information. | ||
59 | + * | ||
60 | + * @param number port number | ||
61 | + * @param isEnabled port enabled state | ||
62 | + * @param signalType ODU signal type | ||
63 | + * @param isTunable tunable wavelength capability | ||
64 | + * @param lambda OCh signal | ||
65 | + * @return OCh port DefaultPortDescription with OCh annotations | ||
66 | + */ | ||
67 | + public static PortDescription ochPortDescription(PortNumber number, | ||
68 | + boolean isEnabled, | ||
69 | + OduSignalType signalType, | ||
70 | + boolean isTunable, | ||
71 | + OchSignal lambda) { | ||
72 | + return ochPortDescription(number, isEnabled, signalType, isTunable, lambda, DefaultAnnotations.EMPTY); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Creates OCh port DefaultPortDescription based on the supplied information. | ||
77 | + * | ||
78 | + * @param number port number | ||
79 | + * @param isEnabled port enabled state | ||
80 | + * @param signalType ODU signal type | ||
81 | + * @param isTunable tunable wavelength capability | ||
82 | + * @param lambda OCh signal | ||
83 | + * @param annotationsIn key/value annotations map | ||
84 | + * @return OCh port DefaultPortDescription with OCh annotations | ||
85 | + */ | ||
86 | + public static PortDescription ochPortDescription(PortNumber number, | ||
87 | + boolean isEnabled, | ||
88 | + OduSignalType signalType, | ||
89 | + boolean isTunable, | ||
90 | + OchSignal lambda, | ||
91 | + SparseAnnotations annotationsIn) { | ||
92 | + | ||
93 | + Builder builder = DefaultAnnotations.builder(); | ||
94 | + builder.putAll(annotationsIn); | ||
95 | + | ||
96 | + builder.set(TUNABLE, String.valueOf(isTunable)); | ||
97 | + builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString()); | ||
98 | + builder.set(SIGNAL_TYPE, signalType.toString()); | ||
99 | + | ||
100 | + DefaultAnnotations annotations = builder.build(); | ||
101 | + long portSpeed = 0; // FIXME assign appropriate value | ||
102 | + return new DefaultPortDescription(number, isEnabled, Port.Type.OCH, portSpeed, annotations); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Creates OCh port DefaultPortDescription based on the supplied information. | ||
107 | + * | ||
108 | + * @param base PortDescription to get basic information from | ||
109 | + * @param signalType ODU signal type | ||
110 | + * @param isTunable tunable wavelength capability | ||
111 | + * @param lambda OCh signal | ||
112 | + * @param annotations key/value annotations map | ||
113 | + * @return OCh port DefaultPortDescription with OCh annotations | ||
114 | + */ | ||
115 | + public static PortDescription ochPortDescription(PortDescription base, | ||
116 | + OduSignalType signalType, | ||
117 | + boolean isTunable, | ||
118 | + OchSignal lambda, | ||
119 | + SparseAnnotations annotations) { | ||
120 | + return ochPortDescription(base.portNumber(), base.isEnabled(), signalType, isTunable, lambda, annotations); | ||
121 | + } | ||
122 | + | ||
123 | + | ||
124 | + public static Optional<OchPort> asOchPort(Port port) { | ||
125 | + if (port instanceof OchPort) { | ||
126 | + return Optional.of((OchPort) port); | ||
127 | + } | ||
128 | + | ||
129 | + try { | ||
130 | + Annotations an = port.annotations(); | ||
131 | + | ||
132 | + OduSignalType signalType = Enum.valueOf(OduSignalType.class, | ||
133 | + an.value(SIGNAL_TYPE)); | ||
134 | + | ||
135 | + boolean isTunable = Boolean.valueOf(an.value(TUNABLE)); | ||
136 | + | ||
137 | + ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA)); | ||
138 | + OchSignal lambda = OchSignalCodec.decode(obj); | ||
139 | + | ||
140 | + // Note: OCh specific annotations is not filtered-out here. | ||
141 | + // DefaultOchPort should filter them, if necessary. | ||
142 | + return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda)); | ||
143 | + | ||
144 | + // TODO: it'll be better to verify each inputs properly | ||
145 | + // instead of catching all these Exceptions. | ||
146 | + } catch (IOException | NullPointerException | ||
147 | + | IllegalArgumentException | ClassCastException e) { | ||
148 | + | ||
149 | + log.warn("{} was not well-formed OCh port.", port, e); | ||
150 | + return Optional.empty(); | ||
151 | + } | ||
152 | + } | ||
153 | + | ||
154 | + // not meant to be instantiated | ||
155 | + private OchPortHelper() {} | ||
156 | +} |
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.optical.device; | ||
17 | + | ||
18 | +import static org.slf4j.LoggerFactory.getLogger; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | +import java.util.Map; | ||
22 | +import java.util.Optional; | ||
23 | + | ||
24 | +import org.onosproject.net.device.DeviceEvent; | ||
25 | +import org.onosproject.net.device.DeviceListener; | ||
26 | +import org.onosproject.net.device.DeviceService; | ||
27 | +import org.onosproject.net.optical.OpticalDevice; | ||
28 | +import org.onosproject.net.optical.utils.ForwardingDeviceService; | ||
29 | +import org.slf4j.Logger; | ||
30 | + | ||
31 | +import com.google.common.annotations.Beta; | ||
32 | +import com.google.common.cache.CacheBuilder; | ||
33 | +import com.google.common.cache.CacheLoader; | ||
34 | +import com.google.common.cache.LoadingCache; | ||
35 | +import com.google.common.collect.Lists; | ||
36 | +import com.google.common.collect.Maps; | ||
37 | + | ||
38 | +import org.apache.commons.lang3.tuple.Pair; | ||
39 | +import org.onosproject.net.DeviceId; | ||
40 | +import org.onosproject.net.Element; | ||
41 | +import org.onosproject.net.Port; | ||
42 | +import org.onosproject.net.PortNumber; | ||
43 | + | ||
44 | + | ||
45 | +// TODO replace places using DeviceService expecting Optical specific ports. | ||
46 | +// with this | ||
47 | + | ||
48 | +/** | ||
49 | + * Decorator, which provides a DeviceService view, which returns | ||
50 | + * Ports in optical specific ports. | ||
51 | + */ | ||
52 | +@Beta | ||
53 | +public class OpticalDeviceServiceView | ||
54 | + extends ForwardingDeviceService | ||
55 | + implements DeviceService { | ||
56 | + | ||
57 | + private static final Logger log = getLogger(OpticalDeviceServiceView.class); | ||
58 | + | ||
59 | + /** | ||
60 | + * DeviceListener to wrapped DeviceListener map. | ||
61 | + * <p> | ||
62 | + * {@literal original listener -> wrapped listener} | ||
63 | + */ | ||
64 | + private final Map<DeviceListener, DeviceListener> wrapped = Maps.newIdentityHashMap(); | ||
65 | + | ||
66 | + // May need a way to monitor Drivers loaded on ONOS and | ||
67 | + // invalidate this Cache if a driver was added/updated | ||
68 | + /** | ||
69 | + * Device to {@link OpticalDevice} map cache. | ||
70 | + */ | ||
71 | + private final LoadingCache<Element, Optional<OpticalDevice>> optdev | ||
72 | + = CacheBuilder.newBuilder() | ||
73 | + .weakKeys() // == for Key comparison | ||
74 | + .maximumSize(100) | ||
75 | + .build(CacheLoader.from(elm -> { | ||
76 | + if (elm.is(OpticalDevice.class)) { | ||
77 | + return Optional.of(elm.as(OpticalDevice.class)); | ||
78 | + } else { | ||
79 | + return Optional.empty(); | ||
80 | + } | ||
81 | + })); | ||
82 | + | ||
83 | + // Not intended to be instantiated directly | ||
84 | + protected OpticalDeviceServiceView(DeviceService base) { | ||
85 | + super(base); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Wraps the given DeviceService to provide a view, | ||
90 | + * which returns port as optical specific Port class. | ||
91 | + * | ||
92 | + * @param base {@link DeviceService} view to use as baseline. | ||
93 | + * @return Decorated view of {@code base} | ||
94 | + */ | ||
95 | + public static OpticalDeviceServiceView opticalView(DeviceService base) { | ||
96 | + // TODO might make sense to track and assign an instance for each `base` | ||
97 | + return new OpticalDeviceServiceView(base); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Transform Port instance on the event to Optical specific port, if it is well-formed. | ||
102 | + * | ||
103 | + * @param event original event to transform | ||
104 | + * @return transformed {@link DeviceEvent} | ||
105 | + */ | ||
106 | + public DeviceEvent augment(DeviceEvent event) { | ||
107 | + final Port port = augment(event.port()); | ||
108 | + if (port == event.port()) { | ||
109 | + // If the Port not changed, pass through | ||
110 | + return event; | ||
111 | + } | ||
112 | + return new DeviceEvent(event.type(), event.subject(), port, event.time()); | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * Transform Port instance to Optical specific port, if it is well-formed. | ||
117 | + * | ||
118 | + * @param port Port instance to translate | ||
119 | + * @return Optical specific port instance or original {@code port}. | ||
120 | + */ | ||
121 | + public Port augment(Port port) { | ||
122 | + if (port == null) { | ||
123 | + return null; | ||
124 | + } | ||
125 | + return optdev.getUnchecked(port.element()) | ||
126 | + .map(odev -> odev.port(port)) | ||
127 | + .orElse(port); | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public void addListener(DeviceListener listener) { | ||
132 | + super.addListener(wrapped.computeIfAbsent(listener, OpticalDeviceListener::new)); | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public void removeListener(DeviceListener listener) { | ||
137 | + DeviceListener wrappedListener = wrapped.remove(listener); | ||
138 | + if (wrappedListener != null) { | ||
139 | + super.removeListener(wrappedListener); | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + | ||
144 | + @Override | ||
145 | + public List<Port> getPorts(DeviceId deviceId) { | ||
146 | + return Lists.transform(super.getPorts(deviceId), | ||
147 | + this::augment); | ||
148 | + } | ||
149 | + | ||
150 | + @Override | ||
151 | + public Port getPort(DeviceId deviceId, PortNumber portNumber) { | ||
152 | + return augment(super.getPort(deviceId, portNumber)); | ||
153 | + } | ||
154 | + | ||
155 | + | ||
156 | + /** | ||
157 | + * DeviceListener, which translates generic Port to optical specific Port | ||
158 | + * before passing. | ||
159 | + */ | ||
160 | + class OpticalDeviceListener implements DeviceListener { | ||
161 | + | ||
162 | + private final DeviceListener listener; | ||
163 | + | ||
164 | + // shallow cache to reuse transformed event in isRelevant and event call | ||
165 | + private Pair<DeviceEvent, DeviceEvent> cache; | ||
166 | + | ||
167 | + public OpticalDeviceListener(DeviceListener listener) { | ||
168 | + this.listener = listener; | ||
169 | + } | ||
170 | + | ||
171 | + private DeviceEvent opticalEvent(DeviceEvent event) { | ||
172 | + | ||
173 | + Pair<DeviceEvent, DeviceEvent> entry = cache; | ||
174 | + if (entry != null && entry.getLeft() == event) { | ||
175 | + return entry.getRight(); | ||
176 | + } | ||
177 | + | ||
178 | + DeviceEvent opticalEvent = augment(event); | ||
179 | + cache = Pair.of(event, opticalEvent); | ||
180 | + return opticalEvent; | ||
181 | + } | ||
182 | + | ||
183 | + @Override | ||
184 | + public boolean isRelevant(DeviceEvent event) { | ||
185 | + return listener.isRelevant(opticalEvent(event)); | ||
186 | + } | ||
187 | + | ||
188 | + @Override | ||
189 | + public void event(DeviceEvent event) { | ||
190 | + listener.event(opticalEvent(event)); | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | +} |
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 | +/** | ||
18 | + * Optical device models. | ||
19 | + */ | ||
20 | +package org.onosproject.net.optical.device; |
1 | +/* | ||
2 | + * Copyright 2016-present 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.optical.device.port; | ||
17 | + | ||
18 | +import java.util.Optional; | ||
19 | + | ||
20 | +import org.onosproject.net.Port; | ||
21 | + | ||
22 | +import com.google.common.annotations.Beta; | ||
23 | +import com.google.common.cache.CacheBuilder; | ||
24 | +import com.google.common.cache.CacheLoader; | ||
25 | +import com.google.common.cache.LoadingCache; | ||
26 | + | ||
27 | +/** | ||
28 | + * PortMapper which caches mapped Port instance. | ||
29 | + */ | ||
30 | +@Beta | ||
31 | +public abstract class AbstractPortMapper<P extends Port> implements PortMapper<P> { | ||
32 | + | ||
33 | + private final LoadingCache<Port, Optional<P>> cache | ||
34 | + = CacheBuilder.newBuilder() | ||
35 | + .weakKeys() // use == to compare keys | ||
36 | + .maximumSize(100) | ||
37 | + .build(CacheLoader.from(this::mapPort)); | ||
38 | + | ||
39 | + /** | ||
40 | + * {@inheritDoc} | ||
41 | + * | ||
42 | + * <p> | ||
43 | + * Note: Subclasses should override and implement short-cut conditions | ||
44 | + * and call {@code super.is(port)}. | ||
45 | + */ | ||
46 | + @Override | ||
47 | + public boolean is(Port port) { | ||
48 | + return as(port).isPresent(); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * {@inheritDoc} | ||
53 | + * | ||
54 | + * <p> | ||
55 | + * Note: Subclasses should override and check if {@code port} is | ||
56 | + * already of type {@code P} and directly return {@code Optional.of((P) port)}, | ||
57 | + * if not call {@code super.as(port)}. | ||
58 | + */ | ||
59 | + @Override | ||
60 | + public Optional<P> as(Port port) { | ||
61 | + if (port == null) { | ||
62 | + return Optional.empty(); | ||
63 | + } | ||
64 | + return cache.getUnchecked(port); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Returns {@code port} mapped to {@code <P>}. | ||
69 | + * | ||
70 | + * @param port Port to map | ||
71 | + * @return {@code port} mapped to {@code <P>} | ||
72 | + */ | ||
73 | + protected abstract Optional<P> mapPort(Port port); | ||
74 | + | ||
75 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.optical.device.port; | ||
17 | + | ||
18 | +import java.util.Optional; | ||
19 | + | ||
20 | +import org.onosproject.net.Port; | ||
21 | + | ||
22 | +import com.google.common.annotations.Beta; | ||
23 | + | ||
24 | +/** | ||
25 | + * {@link PortMapper} which simply return given input. | ||
26 | + */ | ||
27 | +@Beta | ||
28 | +public class IdentityMapper implements PortMapper<Port> { | ||
29 | + | ||
30 | + @Override | ||
31 | + public boolean is(Port port) { | ||
32 | + return true; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public Optional<Port> as(Port port) { | ||
37 | + return Optional.of(port); | ||
38 | + } | ||
39 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.optical.device.port; | ||
17 | + | ||
18 | +import java.util.Optional; | ||
19 | + | ||
20 | +import org.onosproject.net.Port; | ||
21 | +import org.onosproject.net.optical.OchPort; | ||
22 | +import org.onosproject.net.optical.device.OchPortHelper; | ||
23 | +import org.onosproject.net.optical.impl.DefaultOchPort; | ||
24 | + | ||
25 | +import com.google.common.annotations.Beta; | ||
26 | + | ||
27 | +/** | ||
28 | + * {@link PortMapper} to handler {@link OchPort} translation. | ||
29 | + */ | ||
30 | +@Beta | ||
31 | +public class OchPortMapper extends AbstractPortMapper<OchPort> { | ||
32 | + | ||
33 | + @Override | ||
34 | + public boolean is(Port port) { | ||
35 | + return port != null && | ||
36 | + port.type() == Port.Type.OCH && | ||
37 | + super.is(port); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public Optional<OchPort> as(Port port) { | ||
42 | + if (port instanceof OchPort) { | ||
43 | + return Optional.of((OchPort) port); | ||
44 | + } | ||
45 | + return super.as(port); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + protected Optional<OchPort> mapPort(Port port) { | ||
50 | + if (port instanceof OchPort) { | ||
51 | + return Optional.of((OchPort) port); | ||
52 | + } else if (port instanceof org.onosproject.net.OchPort) { | ||
53 | + // TODO remove after deprecation of old OchPort is complete | ||
54 | + | ||
55 | + // translate to new OchPort | ||
56 | + org.onosproject.net.OchPort old = (org.onosproject.net.OchPort) port; | ||
57 | + return Optional.of(new DefaultOchPort(old, | ||
58 | + old.signalType(), | ||
59 | + old.isTunable(), | ||
60 | + old.lambda())); | ||
61 | + } | ||
62 | + | ||
63 | + return OchPortHelper.asOchPort(port); | ||
64 | + } | ||
65 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.optical.device.port; | ||
17 | + | ||
18 | +import java.util.Optional; | ||
19 | + | ||
20 | +import org.onosproject.net.Port; | ||
21 | + | ||
22 | +import com.google.common.annotations.Beta; | ||
23 | + | ||
24 | +/** | ||
25 | + * Abstraction of a class capable of translating generic-Port object | ||
26 | + * as another domain-specific Port of type {@code P}. | ||
27 | + * | ||
28 | + * @param <P> Port type to map generic Port to | ||
29 | + */ | ||
30 | +@Beta | ||
31 | +public interface PortMapper<P extends Port> { | ||
32 | + | ||
33 | + /** | ||
34 | + * Returns true if this port is capable of being projected as {@code <P>}. | ||
35 | + */ | ||
36 | + boolean is(Port port); | ||
37 | + | ||
38 | + /** | ||
39 | + * Returns {@code port} mapped to {@code <P>}. | ||
40 | + * | ||
41 | + * @param port Port to map | ||
42 | + * @return {@code port} mapped to {@code <P>} | ||
43 | + */ | ||
44 | + Optional<P> as(Port port); | ||
45 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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 | + * Optical device port related utilities. | ||
18 | + */ | ||
19 | +package org.onosproject.net.optical.device.port; |
1 | +/* | ||
2 | + * Copyright 2015 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.optical.impl; | ||
17 | + | ||
18 | +import org.onosproject.net.Annotations; | ||
19 | +import org.onosproject.net.OchSignal; | ||
20 | +import org.onosproject.net.OduSignalType; | ||
21 | +import org.onosproject.net.Port; | ||
22 | +import org.onosproject.net.optical.OchPort; | ||
23 | +import org.onosproject.net.optical.utils.ForwardingPort; | ||
24 | + | ||
25 | +import com.google.common.annotations.Beta; | ||
26 | + | ||
27 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
28 | + | ||
29 | +import java.util.Objects; | ||
30 | + | ||
31 | +/** | ||
32 | + * Implementation of OCh port (Optical Channel). | ||
33 | + * Also referred to as a line side port (L-port) or narrow band port. | ||
34 | + * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" | ||
35 | + */ | ||
36 | +@Beta | ||
37 | +public class DefaultOchPort extends ForwardingPort implements OchPort { | ||
38 | + | ||
39 | + // Note: try to avoid direct access to the field, use accessor. | ||
40 | + // We might want to lazily parse annotation in the future | ||
41 | + private final OduSignalType signalType; | ||
42 | + private final boolean isTunable; | ||
43 | + private final OchSignal lambda; | ||
44 | + | ||
45 | + /** | ||
46 | + * Creates an OCh port in the specified network element. | ||
47 | + * | ||
48 | + * @param base Port | ||
49 | + * @param signalType ODU signal type | ||
50 | + * @param isTunable tunable wavelength capability | ||
51 | + * @param lambda OCh signal | ||
52 | + */ | ||
53 | + public DefaultOchPort(Port base, | ||
54 | + OduSignalType signalType, | ||
55 | + boolean isTunable, | ||
56 | + OchSignal lambda) { | ||
57 | + super(base); | ||
58 | + // TODO should this class be parsing annotation to instantiate signalType? | ||
59 | + this.signalType = checkNotNull(signalType); | ||
60 | + this.isTunable = isTunable; | ||
61 | + this.lambda = checkNotNull(lambda); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public Type type() { | ||
66 | + return Type.OCH; | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public long portSpeed() { | ||
71 | + return signalType.bitRate(); | ||
72 | + } | ||
73 | + | ||
74 | + | ||
75 | + @Override | ||
76 | + public Annotations annotations() { | ||
77 | + // FIXME Filter OCh annotations, after confirming that | ||
78 | + // it'll not result in information-loss | ||
79 | + return super.annotations(); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * Returns ODU signal type. | ||
84 | + * | ||
85 | + * @return ODU signal type | ||
86 | + */ | ||
87 | + @Override | ||
88 | + public OduSignalType signalType() { | ||
89 | + return signalType; | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * Returns true if port is wavelength tunable. | ||
94 | + * | ||
95 | + * @return tunable wavelength capability | ||
96 | + */ | ||
97 | + @Override | ||
98 | + public boolean isTunable() { | ||
99 | + return isTunable; | ||
100 | + } | ||
101 | + | ||
102 | + /** | ||
103 | + * Returns OCh signal. | ||
104 | + * | ||
105 | + * @return OCh signal | ||
106 | + */ | ||
107 | + @Override | ||
108 | + public OchSignal lambda() { | ||
109 | + return lambda; | ||
110 | + } | ||
111 | + | ||
112 | + @Override | ||
113 | + public int hashCode() { | ||
114 | + return Objects.hash(super.hashCode(), | ||
115 | + signalType(), | ||
116 | + isTunable(), | ||
117 | + lambda()); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public boolean equals(Object obj) { | ||
122 | + if (this == obj) { | ||
123 | + return true; | ||
124 | + } | ||
125 | + | ||
126 | + if (obj != null && getClass() == obj.getClass()) { | ||
127 | + final DefaultOchPort that = (DefaultOchPort) obj; | ||
128 | + return super.toEqualsBuilder(that) | ||
129 | + .append(this.signalType(), that.signalType()) | ||
130 | + .append(this.isTunable(), that.isTunable()) | ||
131 | + .append(this.lambda(), that.lambda()) | ||
132 | + .isEquals(); | ||
133 | + } | ||
134 | + return false; | ||
135 | + } | ||
136 | + | ||
137 | + @Override | ||
138 | + public String toString() { | ||
139 | + return super.toStringHelper() | ||
140 | + .add("signalType", signalType()) | ||
141 | + .add("isTunable", isTunable()) | ||
142 | + .add("lambda", lambda()) | ||
143 | + .toString(); | ||
144 | + } | ||
145 | +} |
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 | +// Note: All classes in this package is expected to be instance local, and | ||
18 | +// are not expected to be serialized (by Kryo, etc.) | ||
19 | +/** | ||
20 | + * Implementation of Optical augmentation classes. | ||
21 | + */ | ||
22 | +package org.onosproject.net.optical.impl; |
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.optical.json; | ||
17 | + | ||
18 | +import static com.google.common.base.Preconditions.checkArgument; | ||
19 | + | ||
20 | +import org.onosproject.net.ChannelSpacing; | ||
21 | +import org.onosproject.net.GridType; | ||
22 | +import org.onosproject.net.OchSignal; | ||
23 | + | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
26 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
27 | +import com.google.common.annotations.Beta; | ||
28 | + | ||
29 | +// TODO define common interface for JsonCodec for annotation? | ||
30 | +// unlike existing JsonCodec, this use-case requires that encode/decode is | ||
31 | +// reversible. (e.g., obj.equals(decode(encode(obj)))) | ||
32 | +/** | ||
33 | + * JSON codec for OchSignal. | ||
34 | + */ | ||
35 | +@Beta | ||
36 | +public abstract class OchSignalCodec { | ||
37 | + | ||
38 | + // TODO should probably use shared mapper across optical codecs. | ||
39 | + private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates an instance of {@link OchSignal} from JSON representation. | ||
43 | + * | ||
44 | + * @param obj JSON Object representing OchSignal | ||
45 | + * @return OchSignal | ||
46 | + * @throws IllegalArgumentException - if JSON object is ill-formed | ||
47 | + * @see OchSignalCodec#encode(OchSignal) | ||
48 | + */ | ||
49 | + public static OchSignal decode(ObjectNode obj) { | ||
50 | + final GridType gridType; | ||
51 | + final ChannelSpacing channelSpacing; | ||
52 | + final int spacingMultiplier; | ||
53 | + final int slotGranularity; | ||
54 | + | ||
55 | + String s; | ||
56 | + s = obj.get("channelSpacing").textValue(); | ||
57 | + checkArgument(s != null, "ill-formed channelSpacing"); | ||
58 | + channelSpacing = Enum.valueOf(ChannelSpacing.class, s); | ||
59 | + | ||
60 | + s = obj.get("gridType").textValue(); | ||
61 | + checkArgument(s != null, "ill-formed gridType"); | ||
62 | + gridType = Enum.valueOf(GridType.class, s); | ||
63 | + | ||
64 | + JsonNode node; | ||
65 | + node = obj.get("spacingMultiplier"); | ||
66 | + checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier"); | ||
67 | + spacingMultiplier = node.asInt(); | ||
68 | + | ||
69 | + node = obj.get("slotGranularity"); | ||
70 | + checkArgument(node.canConvertToInt(), "ill-formed slotGranularity"); | ||
71 | + slotGranularity = node.asInt(); | ||
72 | + | ||
73 | + return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Returns a JSON Object representation of this instance. | ||
78 | + * | ||
79 | + * @return JSON Object representing OchSignal | ||
80 | + */ | ||
81 | + public static ObjectNode encode(OchSignal j) { | ||
82 | + ObjectNode obj = MAPPER.createObjectNode(); | ||
83 | + obj.put("channelSpacing", j.channelSpacing().toString()); | ||
84 | + obj.put("gridType", j.gridType().toString()); | ||
85 | + obj.put("slotGranularity", j.slotGranularity()); | ||
86 | + obj.put("spacingMultiplier", j.spacingMultiplier()); | ||
87 | + return obj; | ||
88 | + } | ||
89 | + | ||
90 | +} |
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 | +/** | ||
18 | + * JSON related utilities. | ||
19 | + */ | ||
20 | +package org.onosproject.net.optical.json; |
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 | +// Note: this package sub-tree will be moved out from onos-api bundle soon. | ||
18 | +/** | ||
19 | + * Optical augmentation classes. | ||
20 | + */ | ||
21 | +package org.onosproject.net.optical; |
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.optical.utils; | ||
17 | + | ||
18 | +import org.onlab.packet.ChassisId; | ||
19 | +import org.onosproject.net.Annotations; | ||
20 | +import org.onosproject.net.Device; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | +import org.onosproject.net.driver.Behaviour; | ||
23 | +import org.onosproject.net.provider.ProviderId; | ||
24 | + | ||
25 | +import com.google.common.annotations.Beta; | ||
26 | + | ||
27 | +/** | ||
28 | + * A Device which forwards all its method calls to another Device. | ||
29 | + */ | ||
30 | +@Beta | ||
31 | +public interface ForwardingDevice extends Device { | ||
32 | + | ||
33 | + Device delegate(); | ||
34 | + | ||
35 | + @Override | ||
36 | + default Annotations annotations() { | ||
37 | + return delegate().annotations(); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + default ProviderId providerId() { | ||
42 | + return delegate().providerId(); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + default <B extends Behaviour> B as(Class<B> projectionClass) { | ||
47 | + return delegate().as(projectionClass); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + default DeviceId id() { | ||
52 | + return delegate().id(); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + default Type type() { | ||
57 | + return delegate().type(); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + default <B extends Behaviour> boolean is(Class<B> projectionClass) { | ||
62 | + return delegate().is(projectionClass); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + default String manufacturer() { | ||
67 | + return delegate().manufacturer(); | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + default String hwVersion() { | ||
72 | + return delegate().hwVersion(); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + default String swVersion() { | ||
77 | + return delegate().swVersion(); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + default String serialNumber() { | ||
82 | + return delegate().serialNumber(); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + default ChassisId chassisId() { | ||
87 | + return delegate().chassisId(); | ||
88 | + } | ||
89 | +} |
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.optical.utils; | ||
17 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import java.util.List; | ||
21 | + | ||
22 | +import org.onosproject.net.Device; | ||
23 | +import org.onosproject.net.Device.Type; | ||
24 | +import org.onosproject.net.DeviceId; | ||
25 | +import org.onosproject.net.MastershipRole; | ||
26 | +import org.onosproject.net.Port; | ||
27 | +import org.onosproject.net.PortNumber; | ||
28 | +import org.onosproject.net.device.DeviceListener; | ||
29 | +import org.onosproject.net.device.DeviceService; | ||
30 | +import org.onosproject.net.device.PortStatistics; | ||
31 | + | ||
32 | +import com.google.common.annotations.Beta; | ||
33 | + | ||
34 | +/** | ||
35 | + * A DeviceService which forwards all its method calls to another DeviceService. | ||
36 | + */ | ||
37 | +@Beta | ||
38 | +public abstract class ForwardingDeviceService implements DeviceService { | ||
39 | + | ||
40 | + private final DeviceService delegate; | ||
41 | + | ||
42 | + protected ForwardingDeviceService(DeviceService delegate) { | ||
43 | + this.delegate = checkNotNull(delegate); | ||
44 | + } | ||
45 | + | ||
46 | + protected final DeviceService delegate() { | ||
47 | + return delegate; | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public void addListener(DeviceListener listener) { | ||
52 | + delegate.addListener(listener); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public void removeListener(DeviceListener listener) { | ||
57 | + delegate.removeListener(listener); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public int getDeviceCount() { | ||
62 | + return delegate.getDeviceCount(); | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public Iterable<Device> getDevices() { | ||
67 | + return delegate.getDevices(); | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public Iterable<Device> getDevices(Type type) { | ||
72 | + return delegate.getDevices(type); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public Iterable<Device> getAvailableDevices() { | ||
77 | + return delegate.getAvailableDevices(); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public Iterable<Device> getAvailableDevices(Type type) { | ||
82 | + return delegate.getAvailableDevices(type); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public Device getDevice(DeviceId deviceId) { | ||
87 | + return delegate.getDevice(deviceId); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public MastershipRole getRole(DeviceId deviceId) { | ||
92 | + return delegate.getRole(deviceId); | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public List<Port> getPorts(DeviceId deviceId) { | ||
97 | + return delegate.getPorts(deviceId); | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public List<PortStatistics> getPortStatistics(DeviceId deviceId) { | ||
102 | + return delegate.getPortStatistics(deviceId); | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) { | ||
107 | + return delegate.getPortDeltaStatistics(deviceId); | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public Port getPort(DeviceId deviceId, PortNumber portNumber) { | ||
112 | + return delegate.getPort(deviceId, portNumber); | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public boolean isAvailable(DeviceId deviceId) { | ||
117 | + return delegate.isAvailable(deviceId); | ||
118 | + } | ||
119 | + | ||
120 | +} |
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.optical.utils; | ||
17 | + | ||
18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
19 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import org.apache.commons.lang3.builder.EqualsBuilder; | ||
23 | +import org.onosproject.net.Annotations; | ||
24 | +import org.onosproject.net.Element; | ||
25 | +import org.onosproject.net.Port; | ||
26 | +import org.onosproject.net.PortNumber; | ||
27 | + | ||
28 | +import com.google.common.annotations.Beta; | ||
29 | +import com.google.common.base.MoreObjects; | ||
30 | +import com.google.common.base.MoreObjects.ToStringHelper; | ||
31 | + | ||
32 | +/** | ||
33 | + * A Port which forwards all its method calls to another Port. | ||
34 | + */ | ||
35 | +@Beta | ||
36 | +public abstract class ForwardingPort implements Port { | ||
37 | + | ||
38 | + private final Port delegate; | ||
39 | + | ||
40 | + protected ForwardingPort(Port delegate) { | ||
41 | + this.delegate = checkNotNull(delegate); | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public int hashCode() { | ||
46 | + return Objects.hash(element().id(), | ||
47 | + number(), | ||
48 | + isEnabled(), | ||
49 | + type(), | ||
50 | + portSpeed(), | ||
51 | + annotations()); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Returns {@link EqualsBuilder} comparing all Port attributes | ||
56 | + * including annotations. | ||
57 | + * <p> | ||
58 | + * To add extra fields to equality, | ||
59 | + * call {@code super.toEqualsBuilder(..)} and append fields. | ||
60 | + * To remove field from comparison, override this method | ||
61 | + * or manually implement equals(). | ||
62 | + */ | ||
63 | + protected EqualsBuilder toEqualsBuilder(Port that) { | ||
64 | + if (that == null) { | ||
65 | + return new EqualsBuilder().appendSuper(false); | ||
66 | + } | ||
67 | + return new EqualsBuilder() | ||
68 | + .append(this.element().id(), that.element().id()) | ||
69 | + .append(this.number(), that.number()) | ||
70 | + .append(this.isEnabled(), that.isEnabled()) | ||
71 | + .append(this.type(), that.type()) | ||
72 | + .append(this.portSpeed(), that.portSpeed()) | ||
73 | + .append(this.annotations(), that.annotations()); | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public boolean equals(Object obj) { | ||
78 | + if (this == obj) { | ||
79 | + return true; | ||
80 | + } | ||
81 | + | ||
82 | + if (obj != null && getClass() == obj.getClass()) { | ||
83 | + final ForwardingPort that = (ForwardingPort) obj; | ||
84 | + return toEqualsBuilder(that) | ||
85 | + .isEquals(); | ||
86 | + } | ||
87 | + return false; | ||
88 | + } | ||
89 | + | ||
90 | + /** | ||
91 | + * Returns {@link ToStringHelper} with Port attributes excluding annotations. | ||
92 | + * | ||
93 | + * @return {@link ToStringHelper} | ||
94 | + */ | ||
95 | + protected ToStringHelper toStringHelper() { | ||
96 | + return MoreObjects.toStringHelper(this) | ||
97 | + .add("element", element().id()) | ||
98 | + .add("number", number()) | ||
99 | + .add("isEnabled", isEnabled()) | ||
100 | + .add("type", type()) | ||
101 | + .add("portSpeed", portSpeed()); | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public String toString() { | ||
106 | + return toStringHelper() | ||
107 | + .toString(); | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public Annotations annotations() { | ||
112 | + return delegate.annotations(); | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public Element element() { | ||
117 | + return delegate.element(); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public PortNumber number() { | ||
122 | + return delegate.number(); | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public boolean isEnabled() { | ||
127 | + return delegate.isEnabled(); | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public Port.Type type() { | ||
132 | + return delegate.type(); | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public long portSpeed() { | ||
137 | + return delegate.portSpeed(); | ||
138 | + } | ||
139 | + | ||
140 | +} |
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 | +/** | ||
18 | + * Utility classes. | ||
19 | + */ | ||
20 | +package org.onosproject.net.optical.utils; |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.device.impl; | 16 | package org.onosproject.net.device.impl; |
17 | 17 | ||
18 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
18 | import static org.slf4j.LoggerFactory.getLogger; | 19 | import static org.slf4j.LoggerFactory.getLogger; |
19 | import static com.google.common.base.Preconditions.checkNotNull; | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
20 | 21 | ||
... | @@ -22,7 +23,6 @@ import org.onosproject.net.config.ConfigOperator; | ... | @@ -22,7 +23,6 @@ import org.onosproject.net.config.ConfigOperator; |
22 | import org.onosproject.net.config.basics.OpticalPortConfig; | 23 | import org.onosproject.net.config.basics.OpticalPortConfig; |
23 | import org.onosproject.net.AnnotationKeys; | 24 | import org.onosproject.net.AnnotationKeys; |
24 | import org.onosproject.net.DefaultAnnotations; | 25 | import org.onosproject.net.DefaultAnnotations; |
25 | -import org.onosproject.net.OchPort; | ||
26 | import org.onosproject.net.OtuPort; | 26 | import org.onosproject.net.OtuPort; |
27 | import org.onosproject.net.OduCltPort; | 27 | import org.onosproject.net.OduCltPort; |
28 | import org.onosproject.net.OmsPort; | 28 | import org.onosproject.net.OmsPort; |
... | @@ -35,6 +35,8 @@ import org.onosproject.net.device.OduCltPortDescription; | ... | @@ -35,6 +35,8 @@ import org.onosproject.net.device.OduCltPortDescription; |
35 | import org.onosproject.net.device.OmsPortDescription; | 35 | import org.onosproject.net.device.OmsPortDescription; |
36 | import org.onosproject.net.device.OtuPortDescription; | 36 | import org.onosproject.net.device.OtuPortDescription; |
37 | import org.onosproject.net.device.PortDescription; | 37 | import org.onosproject.net.device.PortDescription; |
38 | +import org.onosproject.net.optical.OchPort; | ||
39 | +import org.onosproject.net.optical.OpticalDevice; | ||
38 | import org.slf4j.Logger; | 40 | import org.slf4j.Logger; |
39 | 41 | ||
40 | /** | 42 | /** |
... | @@ -105,16 +107,21 @@ public final class OpticalPortOperator implements ConfigOperator { | ... | @@ -105,16 +107,21 @@ public final class OpticalPortOperator implements ConfigOperator { |
105 | return new OmsPortDescription(port, oms.isEnabled(), oms.minFrequency(), | 107 | return new OmsPortDescription(port, oms.isEnabled(), oms.minFrequency(), |
106 | oms.maxFrequency(), oms.grid(), sa); | 108 | oms.maxFrequency(), oms.grid(), sa); |
107 | case OCH: | 109 | case OCH: |
108 | - // We might need to update lambda below with STATIC_LAMBDA. | 110 | + // We might need to update lambda below with STATIC_LAMBDA. |
109 | - OchPortDescription och = (OchPortDescription) descr; | 111 | + if (descr instanceof OchPortDescription) { |
110 | - return new OchPortDescription(port, och.isEnabled(), och.signalType(), | 112 | + // TODO This block can go away once deprecation is complete. |
111 | - och.isTunable(), och.lambda(), sa); | 113 | + OchPortDescription och = (OchPortDescription) descr; |
114 | + return ochPortDescription(port, och.isEnabled(), och.signalType(), | ||
115 | + och.isTunable(), och.lambda(), sa); | ||
116 | + } | ||
117 | + return descr; | ||
112 | case ODUCLT: | 118 | case ODUCLT: |
113 | OduCltPortDescription odu = (OduCltPortDescription) descr; | 119 | OduCltPortDescription odu = (OduCltPortDescription) descr; |
114 | return new OduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa); | 120 | return new OduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa); |
115 | case PACKET: | 121 | case PACKET: |
116 | case FIBER: | 122 | case FIBER: |
117 | case COPPER: | 123 | case COPPER: |
124 | + // TODO: it should be safe to just return descr. confirm and fix | ||
118 | return new DefaultPortDescription(port, descr.isEnabled(), descr.type(), | 125 | return new DefaultPortDescription(port, descr.isEnabled(), descr.type(), |
119 | descr.portSpeed(), sa); | 126 | descr.portSpeed(), sa); |
120 | case OTU: | 127 | case OTU: |
... | @@ -182,9 +189,22 @@ public final class OpticalPortOperator implements ConfigOperator { | ... | @@ -182,9 +189,22 @@ public final class OpticalPortOperator implements ConfigOperator { |
182 | return new OmsPortDescription(ptn, isup, oms.minFrequency(), | 189 | return new OmsPortDescription(ptn, isup, oms.minFrequency(), |
183 | oms.maxFrequency(), oms.grid(), an); | 190 | oms.maxFrequency(), oms.grid(), an); |
184 | case OCH: | 191 | case OCH: |
185 | - OchPort och = (OchPort) port; | 192 | + if (port instanceof org.onosproject.net.OchPort) { |
186 | - return new OchPortDescription(ptn, isup, och.signalType(), | 193 | + // remove if-block once old OchPort deprecation is complete |
187 | - och.isTunable(), och.lambda(), an); | 194 | + org.onosproject.net.OchPort och = (org.onosproject.net.OchPort) port; |
195 | + return ochPortDescription(ptn, isup, och.signalType(), | ||
196 | + och.isTunable(), och.lambda(), an); | ||
197 | + } | ||
198 | + if (port.element().is(OpticalDevice.class)) { | ||
199 | + OpticalDevice optDevice = port.element().as(OpticalDevice.class); | ||
200 | + if (optDevice.portIs(port, OchPort.class)) { | ||
201 | + OchPort och = optDevice.portAs(port, OchPort.class).get(); | ||
202 | + return ochPortDescription(ptn, isup, och.signalType(), | ||
203 | + och.isTunable(), och.lambda(), an); | ||
204 | + } | ||
205 | + } | ||
206 | + return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an); | ||
207 | + | ||
188 | case ODUCLT: | 208 | case ODUCLT: |
189 | OduCltPort odu = (OduCltPort) port; | 209 | OduCltPort odu = (OduCltPort) port; |
190 | return new OduCltPortDescription(ptn, isup, odu.signalType(), an); | 210 | return new OduCltPortDescription(ptn, isup, odu.signalType(), an); | ... | ... |
... | @@ -32,7 +32,6 @@ import org.onosproject.core.CoreService; | ... | @@ -32,7 +32,6 @@ import org.onosproject.core.CoreService; |
32 | import org.onosproject.net.AnnotationKeys; | 32 | import org.onosproject.net.AnnotationKeys; |
33 | import org.onosproject.net.CltSignalType; | 33 | import org.onosproject.net.CltSignalType; |
34 | import org.onosproject.net.ConnectPoint; | 34 | import org.onosproject.net.ConnectPoint; |
35 | -import org.onosproject.net.OchPort; | ||
36 | import org.onosproject.net.OduCltPort; | 35 | import org.onosproject.net.OduCltPort; |
37 | import org.onosproject.net.OduSignalId; | 36 | import org.onosproject.net.OduSignalId; |
38 | import org.onosproject.net.OduSignalType; | 37 | import org.onosproject.net.OduSignalType; |
... | @@ -60,6 +59,7 @@ import org.onosproject.net.intent.IntentService; | ... | @@ -60,6 +59,7 @@ import org.onosproject.net.intent.IntentService; |
60 | import org.onosproject.net.intent.OpticalCircuitIntent; | 59 | import org.onosproject.net.intent.OpticalCircuitIntent; |
61 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 60 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
62 | import org.onosproject.net.intent.impl.IntentCompilationException; | 61 | import org.onosproject.net.intent.impl.IntentCompilationException; |
62 | +import org.onosproject.net.optical.OchPort; | ||
63 | import org.onosproject.net.intent.IntentSetMultimap; | 63 | import org.onosproject.net.intent.IntentSetMultimap; |
64 | import org.onosproject.net.resource.ResourceAllocation; | 64 | import org.onosproject.net.resource.ResourceAllocation; |
65 | import org.onosproject.net.resource.Resource; | 65 | import org.onosproject.net.resource.Resource; |
... | @@ -82,6 +82,7 @@ import java.util.stream.Collectors; | ... | @@ -82,6 +82,7 @@ import java.util.stream.Collectors; |
82 | import java.util.stream.Stream; | 82 | import java.util.stream.Stream; |
83 | 83 | ||
84 | import static com.google.common.base.Preconditions.checkArgument; | 84 | import static com.google.common.base.Preconditions.checkArgument; |
85 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
85 | 86 | ||
86 | /** | 87 | /** |
87 | * An intent compiler for {@link org.onosproject.net.intent.OpticalCircuitIntent}. | 88 | * An intent compiler for {@link org.onosproject.net.intent.OpticalCircuitIntent}. |
... | @@ -156,6 +157,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -156,6 +157,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
156 | 157 | ||
157 | @Activate | 158 | @Activate |
158 | public void activate(ComponentContext context) { | 159 | public void activate(ComponentContext context) { |
160 | + deviceService = opticalView(deviceService); | ||
159 | appId = coreService.registerApplication("org.onosproject.net.intent"); | 161 | appId = coreService.registerApplication("org.onosproject.net.intent"); |
160 | intentManager.registerCompiler(OpticalCircuitIntent.class, this); | 162 | intentManager.registerCompiler(OpticalCircuitIntent.class, this); |
161 | cfgService.registerProperties(getClass()); | 163 | cfgService.registerProperties(getClass()); | ... | ... |
... | @@ -31,7 +31,6 @@ import org.onosproject.net.ConnectPoint; | ... | @@ -31,7 +31,6 @@ import org.onosproject.net.ConnectPoint; |
31 | import org.onosproject.net.DefaultOchSignalComparator; | 31 | import org.onosproject.net.DefaultOchSignalComparator; |
32 | import org.onosproject.net.DeviceId; | 32 | import org.onosproject.net.DeviceId; |
33 | import org.onosproject.net.Link; | 33 | import org.onosproject.net.Link; |
34 | -import org.onosproject.net.OchPort; | ||
35 | import org.onosproject.net.OchSignal; | 34 | import org.onosproject.net.OchSignal; |
36 | import org.onosproject.net.OchSignalType; | 35 | import org.onosproject.net.OchSignalType; |
37 | import org.onosproject.net.Path; | 36 | import org.onosproject.net.Path; |
... | @@ -43,6 +42,7 @@ import org.onosproject.net.intent.IntentExtensionService; | ... | @@ -43,6 +42,7 @@ import org.onosproject.net.intent.IntentExtensionService; |
43 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 42 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
44 | import org.onosproject.net.intent.OpticalPathIntent; | 43 | import org.onosproject.net.intent.OpticalPathIntent; |
45 | import org.onosproject.net.intent.impl.IntentCompilationException; | 44 | import org.onosproject.net.intent.impl.IntentCompilationException; |
45 | +import org.onosproject.net.optical.OchPort; | ||
46 | import org.onosproject.net.resource.ResourceAllocation; | 46 | import org.onosproject.net.resource.ResourceAllocation; |
47 | import org.onosproject.net.resource.Resource; | 47 | import org.onosproject.net.resource.Resource; |
48 | import org.onosproject.net.resource.ResourceService; | 48 | import org.onosproject.net.resource.ResourceService; |
... | @@ -63,6 +63,7 @@ import java.util.stream.Collectors; | ... | @@ -63,6 +63,7 @@ import java.util.stream.Collectors; |
63 | import java.util.stream.Stream; | 63 | import java.util.stream.Stream; |
64 | 64 | ||
65 | import static com.google.common.base.Preconditions.checkArgument; | 65 | import static com.google.common.base.Preconditions.checkArgument; |
66 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
66 | 67 | ||
67 | /** | 68 | /** |
68 | * An intent compiler for {@link org.onosproject.net.intent.OpticalConnectivityIntent}. | 69 | * An intent compiler for {@link org.onosproject.net.intent.OpticalConnectivityIntent}. |
... | @@ -88,6 +89,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical | ... | @@ -88,6 +89,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical |
88 | 89 | ||
89 | @Activate | 90 | @Activate |
90 | public void activate() { | 91 | public void activate() { |
92 | + deviceService = opticalView(deviceService); | ||
91 | intentManager.registerCompiler(OpticalConnectivityIntent.class, this); | 93 | intentManager.registerCompiler(OpticalConnectivityIntent.class, this); |
92 | } | 94 | } |
93 | 95 | ... | ... |
... | @@ -31,9 +31,9 @@ import org.onosproject.net.DefaultAnnotations; | ... | @@ -31,9 +31,9 @@ import org.onosproject.net.DefaultAnnotations; |
31 | import org.onosproject.net.CltSignalType; | 31 | import org.onosproject.net.CltSignalType; |
32 | import org.onosproject.net.ConnectPoint; | 32 | import org.onosproject.net.ConnectPoint; |
33 | import org.onosproject.net.DefaultDevice; | 33 | import org.onosproject.net.DefaultDevice; |
34 | +import org.onosproject.net.DefaultPort; | ||
34 | import org.onosproject.net.Device; | 35 | import org.onosproject.net.Device; |
35 | import org.onosproject.net.DeviceId; | 36 | import org.onosproject.net.DeviceId; |
36 | -import org.onosproject.net.OchPort; | ||
37 | import org.onosproject.net.OchSignal; | 37 | 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; |
... | @@ -57,6 +57,8 @@ import org.onosproject.net.intent.IntentServiceAdapter; | ... | @@ -57,6 +57,8 @@ import org.onosproject.net.intent.IntentServiceAdapter; |
57 | import org.onosproject.net.intent.Key; | 57 | import org.onosproject.net.intent.Key; |
58 | import org.onosproject.net.intent.MockIdGenerator; | 58 | import org.onosproject.net.intent.MockIdGenerator; |
59 | import org.onosproject.net.intent.OpticalCircuitIntent; | 59 | import org.onosproject.net.intent.OpticalCircuitIntent; |
60 | +import org.onosproject.net.optical.OchPort; | ||
61 | +import org.onosproject.net.optical.impl.DefaultOchPort; | ||
60 | import org.onosproject.net.provider.ProviderId; | 62 | import org.onosproject.net.provider.ProviderId; |
61 | import org.onosproject.net.intent.IntentSetMultimap; | 63 | import org.onosproject.net.intent.IntentSetMultimap; |
62 | import org.onosproject.net.behaviour.TributarySlotQuery; | 64 | import org.onosproject.net.behaviour.TributarySlotQuery; |
... | @@ -128,11 +130,13 @@ public class OpticalCircuitIntentCompilerTest { | ... | @@ -128,11 +130,13 @@ public class OpticalCircuitIntentCompilerTest { |
128 | 130 | ||
129 | // Och ports with signalType=ODU2 | 131 | // Och ports with signalType=ODU2 |
130 | private static final OchPort D1P2 = | 132 | private static final OchPort D1P2 = |
131 | - new OchPort(device1, PortNumber.portNumber(2), true, OduSignalType.ODU2, | 133 | + new DefaultOchPort(new DefaultPort(device1, PortNumber.portNumber(2), true, annotations2), |
132 | - true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1), annotations2); | 134 | + OduSignalType.ODU2, |
135 | + true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1)); | ||
133 | private static final OchPort D2P2 = | 136 | private static final OchPort D2P2 = |
134 | - new OchPort(device2, PortNumber.portNumber(2), true, OduSignalType.ODU2, | 137 | + new DefaultOchPort(new DefaultPort(device2, PortNumber.portNumber(2), true, annotations2), |
135 | - true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1), annotations2); | 138 | + OduSignalType.ODU2, |
139 | + true, OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1)); | ||
136 | 140 | ||
137 | // OduClt ports with signalType=10GBE | 141 | // OduClt ports with signalType=10GBE |
138 | private static final OduCltPort D1P3 = | 142 | private static final OduCltPort D1P3 = |
... | @@ -169,11 +173,11 @@ public class OpticalCircuitIntentCompilerTest { | ... | @@ -169,11 +173,11 @@ public class OpticalCircuitIntentCompilerTest { |
169 | if (deviceId.equals(deviceId(DEV1))) { | 173 | if (deviceId.equals(deviceId(DEV1))) { |
170 | switch (portNumber.toString()) { | 174 | switch (portNumber.toString()) { |
171 | case "1": | 175 | case "1": |
172 | - return (Port) D1P1; | 176 | + return D1P1; |
173 | case "2": | 177 | case "2": |
174 | - return (Port) D1P2; | 178 | + return D1P2; |
175 | case "3": | 179 | case "3": |
176 | - return (Port) D1P3; | 180 | + return D1P3; |
177 | default: | 181 | default: |
178 | return null; | 182 | return null; |
179 | } | 183 | } |
... | @@ -181,11 +185,11 @@ public class OpticalCircuitIntentCompilerTest { | ... | @@ -181,11 +185,11 @@ public class OpticalCircuitIntentCompilerTest { |
181 | if (deviceId.equals(deviceId(DEV2))) { | 185 | if (deviceId.equals(deviceId(DEV2))) { |
182 | switch (portNumber.toString()) { | 186 | switch (portNumber.toString()) { |
183 | case "1": | 187 | case "1": |
184 | - return (Port) D2P1; | 188 | + return D2P1; |
185 | case "2": | 189 | case "2": |
186 | - return (Port) D2P2; | 190 | + return D2P2; |
187 | case "3": | 191 | case "3": |
188 | - return (Port) D2P3; | 192 | + return D2P3; |
189 | default: | 193 | default: |
190 | return null; | 194 | return null; |
191 | } | 195 | } | ... | ... |
... | @@ -17,6 +17,7 @@ package org.onosproject.store.device.impl; | ... | @@ -17,6 +17,7 @@ package org.onosproject.store.device.impl; |
17 | 17 | ||
18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
19 | import static org.onosproject.net.DefaultAnnotations.union; | 19 | import static org.onosproject.net.DefaultAnnotations.union; |
20 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
20 | 21 | ||
21 | import java.util.Collections; | 22 | import java.util.Collections; |
22 | import java.util.Map; | 23 | import java.util.Map; |
... | @@ -111,11 +112,21 @@ class DeviceDescriptions { | ... | @@ -111,11 +112,21 @@ class DeviceDescriptions { |
111 | newDesc.timestamp()); | 112 | newDesc.timestamp()); |
112 | break; | 113 | break; |
113 | case OCH: | 114 | case OCH: |
114 | - OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); | 115 | + if (newDesc.value() instanceof OchPortDescription) { |
115 | - newOne = new Timestamped<>( | 116 | + // remove if-block after Och related deprecation is complete |
116 | - new OchPortDescription( | 117 | + OchPortDescription ochDesc = (OchPortDescription) (newDesc.value()); |
117 | - ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged), | 118 | + newOne = new Timestamped<>( |
118 | - newDesc.timestamp()); | 119 | + ochPortDescription(ochDesc, |
120 | + ochDesc.signalType(), | ||
121 | + ochDesc.isTunable(), | ||
122 | + ochDesc.lambda(), merged), | ||
123 | + newDesc.timestamp()); | ||
124 | + } else { | ||
125 | + // same as default case | ||
126 | + newOne = new Timestamped<>( | ||
127 | + new DefaultPortDescription(newDesc.value(), merged), | ||
128 | + newDesc.timestamp()); | ||
129 | + } | ||
119 | break; | 130 | break; |
120 | case ODUCLT: | 131 | case ODUCLT: |
121 | OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); | 132 | OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value()); | ... | ... |
... | @@ -527,15 +527,21 @@ public class ECDeviceStore | ... | @@ -527,15 +527,21 @@ public class ECDeviceStore |
527 | 527 | ||
528 | private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled, | 528 | private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled, |
529 | PortDescription description, Annotations annotations) { | 529 | PortDescription description, Annotations annotations) { |
530 | + // FIXME this switch need to go away once all ports are done. | ||
530 | switch (description.type()) { | 531 | switch (description.type()) { |
531 | case OMS: | 532 | case OMS: |
532 | OmsPortDescription omsDesc = (OmsPortDescription) description; | 533 | OmsPortDescription omsDesc = (OmsPortDescription) description; |
533 | return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), | 534 | return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), |
534 | omsDesc.maxFrequency(), omsDesc.grid(), annotations); | 535 | omsDesc.maxFrequency(), omsDesc.grid(), annotations); |
535 | case OCH: | 536 | case OCH: |
536 | - OchPortDescription ochDesc = (OchPortDescription) description; | 537 | + if (description instanceof OchPortDescription) { |
537 | - return new OchPort(device, number, isEnabled, ochDesc.signalType(), | 538 | + // remove if-block once Och deprecation is complete |
538 | - ochDesc.isTunable(), ochDesc.lambda(), annotations); | 539 | + OchPortDescription ochDesc = (OchPortDescription) description; |
540 | + return new OchPort(device, number, isEnabled, ochDesc.signalType(), | ||
541 | + ochDesc.isTunable(), ochDesc.lambda(), annotations); | ||
542 | + } | ||
543 | + return new DefaultPort(device, number, isEnabled, description.type(), | ||
544 | + description.portSpeed(), annotations); | ||
539 | case ODUCLT: | 545 | case ODUCLT: |
540 | OduCltPortDescription oduDesc = (OduCltPortDescription) description; | 546 | OduCltPortDescription oduDesc = (OduCltPortDescription) description; |
541 | return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations); | 547 | return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations); | ... | ... |
... | @@ -1085,15 +1085,21 @@ public class GossipDeviceStore | ... | @@ -1085,15 +1085,21 @@ public class GossipDeviceStore |
1085 | 1085 | ||
1086 | private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled, | 1086 | private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled, |
1087 | PortDescription description, Annotations annotations) { | 1087 | PortDescription description, Annotations annotations) { |
1088 | + // FIXME this switch need to go away once all ports are done. | ||
1088 | switch (description.type()) { | 1089 | switch (description.type()) { |
1089 | case OMS: | 1090 | case OMS: |
1090 | OmsPortDescription omsDesc = (OmsPortDescription) description; | 1091 | OmsPortDescription omsDesc = (OmsPortDescription) description; |
1091 | return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), | 1092 | return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(), |
1092 | omsDesc.maxFrequency(), omsDesc.grid(), annotations); | 1093 | omsDesc.maxFrequency(), omsDesc.grid(), annotations); |
1093 | case OCH: | 1094 | case OCH: |
1094 | - OchPortDescription ochDesc = (OchPortDescription) description; | 1095 | + if (description instanceof OchPortDescription) { |
1095 | - return new OchPort(device, number, isEnabled, ochDesc.signalType(), | 1096 | + // remove if-block once Och deprecation is complete |
1096 | - ochDesc.isTunable(), ochDesc.lambda(), annotations); | 1097 | + OchPortDescription ochDesc = (OchPortDescription) description; |
1098 | + return new OchPort(device, number, isEnabled, ochDesc.signalType(), | ||
1099 | + ochDesc.isTunable(), ochDesc.lambda(), annotations); | ||
1100 | + } | ||
1101 | + return new DefaultPort(device, number, isEnabled, description.type(), | ||
1102 | + description.portSpeed(), annotations); | ||
1097 | case ODUCLT: | 1103 | case ODUCLT: |
1098 | OduCltPortDescription oduDesc = (OduCltPortDescription) description; | 1104 | OduCltPortDescription oduDesc = (OduCltPortDescription) description; |
1099 | return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations); | 1105 | return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations); | ... | ... |
... | @@ -18,12 +18,21 @@ package org.onosproject.drivers.ciena; | ... | @@ -18,12 +18,21 @@ package org.onosproject.drivers.ciena; |
18 | 18 | ||
19 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
20 | import org.onosproject.net.driver.AbstractDriverLoader; | 20 | import org.onosproject.net.driver.AbstractDriverLoader; |
21 | +import org.onosproject.net.optical.OpticalDevice; | ||
22 | +import org.onosproject.net.optical.device.DefaultOpticalDevice; | ||
21 | 23 | ||
22 | /** | 24 | /** |
23 | * Loader for Ciena device drivers. | 25 | * Loader for Ciena device drivers. |
24 | */ | 26 | */ |
25 | @Component(immediate = true) | 27 | @Component(immediate = true) |
26 | public class CienaDriversLoader extends AbstractDriverLoader { | 28 | public class CienaDriversLoader extends AbstractDriverLoader { |
29 | + | ||
30 | + // OSGI: help bundle plugin discover runtime package dependency. | ||
31 | + @SuppressWarnings("unused") | ||
32 | + private OpticalDevice optical; | ||
33 | + @SuppressWarnings("unused") | ||
34 | + private DefaultOpticalDevice driver; | ||
35 | + | ||
27 | public CienaDriversLoader() { | 36 | public CienaDriversLoader() { |
28 | super("/ciena-drivers.xml"); | 37 | super("/ciena-drivers.xml"); |
29 | } | 38 | } | ... | ... |
... | @@ -18,6 +18,8 @@ | ... | @@ -18,6 +18,8 @@ |
18 | <driver name="restCiena" manufacturer="Ciena" hwVersion="1.0.0" swVersion="1.0.0"> | 18 | <driver name="restCiena" manufacturer="Ciena" hwVersion="1.0.0" swVersion="1.0.0"> |
19 | <behaviour api="org.onosproject.net.behaviour.PortDiscovery" | 19 | <behaviour api="org.onosproject.net.behaviour.PortDiscovery" |
20 | impl="org.onosproject.drivers.ciena.PortDiscoveryCienaWaveserverImpl"/> | 20 | impl="org.onosproject.drivers.ciena.PortDiscoveryCienaWaveserverImpl"/> |
21 | + <behaviour api="org.onosproject.net.optical.OpticalDevice" | ||
22 | + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/> | ||
21 | </driver> | 23 | </driver> |
22 | </drivers> | 24 | </drivers> |
23 | 25 | ... | ... |
... | @@ -47,4 +47,23 @@ | ... | @@ -47,4 +47,23 @@ |
47 | <artifactId>openflowj</artifactId> | 47 | <artifactId>openflowj</artifactId> |
48 | </dependency> | 48 | </dependency> |
49 | </dependencies> | 49 | </dependencies> |
50 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
50 | + <build> | ||
51 | + <plugins> | ||
52 | + <plugin> | ||
53 | + <groupId>org.apache.felix</groupId> | ||
54 | + <artifactId>maven-bundle-plugin</artifactId> | ||
55 | + <extensions>true</extensions> | ||
56 | + <configuration> | ||
57 | + <niceManifest>true</niceManifest> | ||
58 | + <instructions> | ||
59 | + <!-- TODO this can be removed once optical package | ||
60 | + has been separated out from the default drivers --> | ||
61 | + <Import-Package> | ||
62 | + *,org.onosproject.net.optical.device | ||
63 | + </Import-Package> | ||
64 | + </instructions> | ||
65 | + </configuration> | ||
66 | + </plugin> | ||
67 | + </plugins> | ||
68 | + </build> | ||
69 | +</project> | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.driver.query; | 16 | package org.onosproject.driver.query; |
17 | 17 | ||
18 | import org.onlab.util.GuavaCollectors; | 18 | import org.onlab.util.GuavaCollectors; |
19 | -import org.onosproject.net.OchPort; | ||
20 | import org.onosproject.net.OduSignalType; | 19 | import org.onosproject.net.OduSignalType; |
21 | import org.onosproject.net.OtuPort; | 20 | import org.onosproject.net.OtuPort; |
22 | import org.onosproject.net.OtuSignalType; | 21 | import org.onosproject.net.OtuSignalType; |
... | @@ -25,10 +24,13 @@ import org.onosproject.net.PortNumber; | ... | @@ -25,10 +24,13 @@ import org.onosproject.net.PortNumber; |
25 | import org.onosproject.net.TributarySlot; | 24 | import org.onosproject.net.TributarySlot; |
26 | import org.onosproject.net.device.DeviceService; | 25 | import org.onosproject.net.device.DeviceService; |
27 | import org.onosproject.net.driver.AbstractHandlerBehaviour; | 26 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
27 | +import org.onosproject.net.optical.OchPort; | ||
28 | import org.onosproject.net.behaviour.TributarySlotQuery; | 28 | import org.onosproject.net.behaviour.TributarySlotQuery; |
29 | import org.slf4j.Logger; | 29 | import org.slf4j.Logger; |
30 | import org.slf4j.LoggerFactory; | 30 | import org.slf4j.LoggerFactory; |
31 | 31 | ||
32 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
33 | + | ||
32 | import java.util.Collections; | 34 | import java.util.Collections; |
33 | import java.util.Set; | 35 | import java.util.Set; |
34 | import java.util.stream.IntStream; | 36 | import java.util.stream.IntStream; |
... | @@ -61,12 +63,12 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen | ... | @@ -61,12 +63,12 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen |
61 | @Override | 63 | @Override |
62 | public Set<TributarySlot> queryTributarySlots(PortNumber port) { | 64 | public Set<TributarySlot> queryTributarySlots(PortNumber port) { |
63 | // currently return all slots by default. | 65 | // currently return all slots by default. |
64 | - DeviceService deviceService = this.handler().get(DeviceService.class); | 66 | + DeviceService deviceService = opticalView(this.handler().get(DeviceService.class)); |
65 | Port p = deviceService.getPort(this.data().deviceId(), port); | 67 | Port p = deviceService.getPort(this.data().deviceId(), port); |
66 | 68 | ||
67 | switch (p.type()) { | 69 | switch (p.type()) { |
68 | case OCH: | 70 | case OCH: |
69 | - return queryOchTributarySlots((OchPort) p); | 71 | + return queryOchTributarySlots(p); |
70 | case OTU: | 72 | case OTU: |
71 | return queryOtuTributarySlots((OtuPort) p); | 73 | return queryOtuTributarySlots((OtuPort) p); |
72 | default: | 74 | default: |
... | @@ -74,8 +76,21 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen | ... | @@ -74,8 +76,21 @@ public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implemen |
74 | } | 76 | } |
75 | } | 77 | } |
76 | 78 | ||
77 | - private Set<TributarySlot> queryOchTributarySlots(OchPort ochPort) { | 79 | + private Set<TributarySlot> queryOchTributarySlots(Port ochPort) { |
78 | - OduSignalType signalType = ochPort.signalType(); | 80 | + OduSignalType signalType = null; |
81 | + if (ochPort instanceof org.onosproject.net.OchPort) { | ||
82 | + // remove once deprecation of old OchPort model is done | ||
83 | + signalType = ((org.onosproject.net.OchPort) ochPort).signalType(); | ||
84 | + } | ||
85 | + if (ochPort instanceof OchPort) { | ||
86 | + signalType = ((OchPort) ochPort).signalType(); | ||
87 | + } | ||
88 | + | ||
89 | + if (signalType == null) { | ||
90 | + log.warn("{} was not an OchPort", ochPort); | ||
91 | + return Collections.emptySet(); | ||
92 | + } | ||
93 | + | ||
79 | switch (signalType) { | 94 | switch (signalType) { |
80 | case ODU2: | 95 | case ODU2: |
81 | return ENTIRE_ODU2_TRIBUTARY_SLOTS; | 96 | return ENTIRE_ODU2_TRIBUTARY_SLOTS; | ... | ... |
... | @@ -61,6 +61,8 @@ | ... | @@ -61,6 +61,8 @@ |
61 | impl="org.onosproject.driver.handshaker.OfOpticalSwitchImplLinc13"/> | 61 | impl="org.onosproject.driver.handshaker.OfOpticalSwitchImplLinc13"/> |
62 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" | 62 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" |
63 | impl="org.onosproject.driver.query.LincOELambdaQuery"/> | 63 | impl="org.onosproject.driver.query.LincOELambdaQuery"/> |
64 | + <behaviour api="org.onosproject.net.optical.OpticalDevice" | ||
65 | + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/> | ||
64 | </driver> | 66 | </driver> |
65 | <driver name="ofdpa" extends="default" | 67 | <driver name="ofdpa" extends="default" |
66 | manufacturer="Broadcom Corp." hwVersion="OF-DPA.*" swVersion="OF-DPA.*"> | 68 | manufacturer="Broadcom Corp." hwVersion="OF-DPA.*" swVersion="OF-DPA.*"> |
... | @@ -165,6 +167,8 @@ | ... | @@ -165,6 +167,8 @@ |
165 | impl="org.onosproject.driver.query.DefaultTributarySlotQuery" /> | 167 | impl="org.onosproject.driver.query.DefaultTributarySlotQuery" /> |
166 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" | 168 | <behaviour api="org.onosproject.net.behaviour.LambdaQuery" |
167 | impl="org.onosproject.driver.query.OFOpticalSwitch13LambdaQuery"/> | 169 | impl="org.onosproject.driver.query.OFOpticalSwitch13LambdaQuery"/> |
170 | + <behaviour api="org.onosproject.net.optical.OpticalDevice" | ||
171 | + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/> | ||
168 | </driver> | 172 | </driver> |
169 | <driver name="aos" extends="ofdpa" | 173 | <driver name="aos" extends="ofdpa" |
170 | manufacturer="Accton" hwVersion=".*" swVersion="1.*"> | 174 | manufacturer="Accton" hwVersion=".*" swVersion="1.*"> |
... | @@ -179,6 +183,8 @@ | ... | @@ -179,6 +183,8 @@ |
179 | swVersion="of-agent"> | 183 | swVersion="of-agent"> |
180 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" | 184 | <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver" |
181 | impl="org.onosproject.driver.handshaker.OplinkRoadmHandshaker"/> | 185 | impl="org.onosproject.driver.handshaker.OplinkRoadmHandshaker"/> |
186 | + <behaviour api="org.onosproject.net.optical.OpticalDevice" | ||
187 | + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/> | ||
182 | </driver> | 188 | </driver> |
183 | <driver name="hp" extends="default" | 189 | <driver name="hp" extends="default" |
184 | manufacturer="HP" hwVersion="Switch 3500yl-48G" swVersion="K.16.01.0004"> | 190 | manufacturer="HP" hwVersion="Switch 3500yl-48G" swVersion="K.16.01.0004"> | ... | ... |
... | @@ -18,12 +18,21 @@ package org.onosproject.drivers.fujitsu; | ... | @@ -18,12 +18,21 @@ package org.onosproject.drivers.fujitsu; |
18 | 18 | ||
19 | import org.apache.felix.scr.annotations.Component; | 19 | import org.apache.felix.scr.annotations.Component; |
20 | import org.onosproject.net.driver.AbstractDriverLoader; | 20 | import org.onosproject.net.driver.AbstractDriverLoader; |
21 | +import org.onosproject.net.optical.OpticalDevice; | ||
22 | +import org.onosproject.net.optical.device.DefaultOpticalDevice; | ||
21 | 23 | ||
22 | /** | 24 | /** |
23 | * Loader for Fujitsu device drivers. | 25 | * Loader for Fujitsu device drivers. |
24 | */ | 26 | */ |
25 | @Component(immediate = true) | 27 | @Component(immediate = true) |
26 | public class FujitsuDriversLoader extends AbstractDriverLoader { | 28 | public class FujitsuDriversLoader extends AbstractDriverLoader { |
29 | + | ||
30 | + // OSGI: help bundle plugin discover runtime package dependency. | ||
31 | + @SuppressWarnings("unused") | ||
32 | + private OpticalDevice optical; | ||
33 | + @SuppressWarnings("unused") | ||
34 | + private DefaultOpticalDevice driver; | ||
35 | + | ||
27 | public FujitsuDriversLoader() { | 36 | public FujitsuDriversLoader() { |
28 | super("/fujitsu-drivers.xml"); | 37 | super("/fujitsu-drivers.xml"); |
29 | } | 38 | } | ... | ... |
... | @@ -18,6 +18,8 @@ | ... | @@ -18,6 +18,8 @@ |
18 | <driver name="fujitsu-netconf" manufacturer="Fujitsu" hwVersion="T100" swVersion="01-01-X"> | 18 | <driver name="fujitsu-netconf" manufacturer="Fujitsu" hwVersion="T100" swVersion="01-01-X"> |
19 | <behaviour api="org.onosproject.net.behaviour.PortDiscovery" | 19 | <behaviour api="org.onosproject.net.behaviour.PortDiscovery" |
20 | impl="org.onosproject.drivers.fujitsu.PortGetterFujitsuImpl"/> | 20 | impl="org.onosproject.drivers.fujitsu.PortGetterFujitsuImpl"/> |
21 | + <behaviour api="org.onosproject.net.optical.OpticalDevice" | ||
22 | + impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/> | ||
21 | </driver> | 23 | </driver> |
22 | </drivers> | 24 | </drivers> |
23 | 25 | ... | ... |
... | @@ -32,12 +32,13 @@ import org.onosproject.net.OduSignalType; | ... | @@ -32,12 +32,13 @@ import org.onosproject.net.OduSignalType; |
32 | import org.onosproject.net.PortNumber; | 32 | import org.onosproject.net.PortNumber; |
33 | import org.onosproject.net.SparseAnnotations; | 33 | import org.onosproject.net.SparseAnnotations; |
34 | import org.onosproject.net.behaviour.ControllerInfo; | 34 | import org.onosproject.net.behaviour.ControllerInfo; |
35 | -import org.onosproject.net.device.OchPortDescription; | ||
36 | import org.onosproject.net.device.OduCltPortDescription; | 35 | import org.onosproject.net.device.OduCltPortDescription; |
37 | import org.onosproject.net.device.PortDescription; | 36 | import org.onosproject.net.device.PortDescription; |
38 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
39 | import org.slf4j.LoggerFactory; | 38 | import org.slf4j.LoggerFactory; |
40 | 39 | ||
40 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
41 | + | ||
41 | import java.io.InputStream; | 42 | import java.io.InputStream; |
42 | import java.io.StringWriter; | 43 | import java.io.StringWriter; |
43 | import java.util.ArrayList; | 44 | import java.util.ArrayList; |
... | @@ -104,7 +105,7 @@ public final class XmlConfigParser { | ... | @@ -104,7 +105,7 @@ public final class XmlConfigParser { |
104 | return portDescriptions; | 105 | return portDescriptions; |
105 | } | 106 | } |
106 | 107 | ||
107 | - private static OchPortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) { | 108 | + private static PortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) { |
108 | PortNumber portNumber = PortNumber.portNumber(count); | 109 | PortNumber portNumber = PortNumber.portNumber(count); |
109 | HierarchicalConfiguration otuConfig = cfg.configurationAt("otu"); | 110 | HierarchicalConfiguration otuConfig = cfg.configurationAt("otu"); |
110 | boolean enabled = otuConfig.getString("administrative-state").equals("up"); | 111 | boolean enabled = otuConfig.getString("administrative-state").equals("up"); |
... | @@ -115,7 +116,7 @@ public final class XmlConfigParser { | ... | @@ -115,7 +116,7 @@ public final class XmlConfigParser { |
115 | DefaultAnnotations annotations = DefaultAnnotations.builder(). | 116 | DefaultAnnotations annotations = DefaultAnnotations.builder(). |
116 | set(AnnotationKeys.PORT_NAME, cfg.getString("name")). | 117 | set(AnnotationKeys.PORT_NAME, cfg.getString("name")). |
117 | build(); | 118 | build(); |
118 | - return new OchPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations); | 119 | + return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations); |
119 | } | 120 | } |
120 | 121 | ||
121 | private static OduCltPortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) { | 122 | private static OduCltPortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) { |
... | @@ -213,7 +214,7 @@ public final class XmlConfigParser { | ... | @@ -213,7 +214,7 @@ public final class XmlConfigParser { |
213 | int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) - | 214 | int spacingMult = (int) (toGbps((Integer.parseInt(config.getString(frequencyPath)) - |
214 | baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ? | 215 | baseFrequency)) / toGbpsFromHz(chSpacing.frequency().asHz())); //FIXME is there a better way ? |
215 | 216 | ||
216 | - return new OchPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable, | 217 | + return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, oduSignalType, isTunable, |
217 | new OchSignal(gridType, chSpacing, spacingMult, 1), annotations); | 218 | new OchSignal(gridType, chSpacing, spacingMult, 1), annotations); |
218 | } | 219 | } |
219 | 220 | ... | ... |
... | @@ -650,6 +650,9 @@ | ... | @@ -650,6 +650,9 @@ |
650 | <artifactId>maven-bundle-plugin</artifactId> | 650 | <artifactId>maven-bundle-plugin</artifactId> |
651 | <version>3.0.1</version> | 651 | <version>3.0.1</version> |
652 | <extensions>true</extensions> | 652 | <extensions>true</extensions> |
653 | + <configuration> | ||
654 | + <niceManifest>true</niceManifest> | ||
655 | + </configuration> | ||
653 | </plugin> | 656 | </plugin> |
654 | 657 | ||
655 | <plugin> | 658 | <plugin> | ... | ... |
... | @@ -15,10 +15,24 @@ | ... | @@ -15,10 +15,24 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.provider.of.device.impl; | 16 | package org.onosproject.provider.of.device.impl; |
17 | 17 | ||
18 | -import com.google.common.base.Strings; | 18 | +import static com.google.common.base.Preconditions.checkArgument; |
19 | -import com.google.common.collect.Lists; | 19 | +import static com.google.common.base.Strings.isNullOrEmpty; |
20 | -import com.google.common.collect.Maps; | 20 | +import static org.onlab.util.Tools.get; |
21 | -import com.google.common.collect.Sets; | 21 | +import static org.onosproject.net.DeviceId.deviceId; |
22 | +import static org.onosproject.net.Port.Type.COPPER; | ||
23 | +import static org.onosproject.net.Port.Type.FIBER; | ||
24 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
25 | +import static org.onosproject.openflow.controller.Dpid.dpid; | ||
26 | +import static org.onosproject.openflow.controller.Dpid.uri; | ||
27 | +import static org.slf4j.LoggerFactory.getLogger; | ||
28 | + | ||
29 | +import java.util.ArrayList; | ||
30 | +import java.util.Collection; | ||
31 | +import java.util.Collections; | ||
32 | +import java.util.Dictionary; | ||
33 | +import java.util.HashMap; | ||
34 | +import java.util.HashSet; | ||
35 | +import java.util.List; | ||
22 | 36 | ||
23 | import org.apache.felix.scr.annotations.Activate; | 37 | import org.apache.felix.scr.annotations.Activate; |
24 | import org.apache.felix.scr.annotations.Component; | 38 | import org.apache.felix.scr.annotations.Component; |
... | @@ -52,7 +66,6 @@ import org.onosproject.net.device.DeviceDescription; | ... | @@ -52,7 +66,6 @@ import org.onosproject.net.device.DeviceDescription; |
52 | import org.onosproject.net.device.DeviceProvider; | 66 | import org.onosproject.net.device.DeviceProvider; |
53 | import org.onosproject.net.device.DeviceProviderRegistry; | 67 | import org.onosproject.net.device.DeviceProviderRegistry; |
54 | import org.onosproject.net.device.DeviceProviderService; | 68 | import org.onosproject.net.device.DeviceProviderService; |
55 | -import org.onosproject.net.device.OchPortDescription; | ||
56 | import org.onosproject.net.device.OduCltPortDescription; | 69 | import org.onosproject.net.device.OduCltPortDescription; |
57 | import org.onosproject.net.device.OmsPortDescription; | 70 | import org.onosproject.net.device.OmsPortDescription; |
58 | import org.onosproject.net.device.OtuPortDescription; | 71 | import org.onosproject.net.device.OtuPortDescription; |
... | @@ -101,23 +114,10 @@ import org.projectfloodlight.openflow.types.OFPort; | ... | @@ -101,23 +114,10 @@ import org.projectfloodlight.openflow.types.OFPort; |
101 | import org.projectfloodlight.openflow.types.PortSpeed; | 114 | import org.projectfloodlight.openflow.types.PortSpeed; |
102 | import org.slf4j.Logger; | 115 | import org.slf4j.Logger; |
103 | 116 | ||
104 | -import java.util.ArrayList; | 117 | +import com.google.common.base.Strings; |
105 | -import java.util.Collection; | 118 | +import com.google.common.collect.Lists; |
106 | -import java.util.Collections; | 119 | +import com.google.common.collect.Maps; |
107 | -import java.util.Dictionary; | 120 | +import com.google.common.collect.Sets; |
108 | -import java.util.HashMap; | ||
109 | -import java.util.HashSet; | ||
110 | -import java.util.List; | ||
111 | - | ||
112 | -import static com.google.common.base.Preconditions.checkArgument; | ||
113 | -import static com.google.common.base.Strings.isNullOrEmpty; | ||
114 | -import static org.onlab.util.Tools.get; | ||
115 | -import static org.onosproject.net.DeviceId.deviceId; | ||
116 | -import static org.onosproject.net.Port.Type.COPPER; | ||
117 | -import static org.onosproject.net.Port.Type.FIBER; | ||
118 | -import static org.onosproject.openflow.controller.Dpid.dpid; | ||
119 | -import static org.onosproject.openflow.controller.Dpid.uri; | ||
120 | -import static org.slf4j.LoggerFactory.getLogger; | ||
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Provider which uses an OpenFlow controller to detect network | 123 | * Provider which uses an OpenFlow controller to detect network |
... | @@ -579,7 +579,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -579,7 +579,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
579 | OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0); | 579 | OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0); |
580 | OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType(); | 580 | OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType(); |
581 | 581 | ||
582 | - DefaultPortDescription portDes = null; | 582 | + PortDescription portDes = null; |
583 | switch (sigType) { | 583 | switch (sigType) { |
584 | case OMSN: | 584 | case OMSN: |
585 | portDes = new OmsPortDescription(portNo, enabled, | 585 | portDes = new OmsPortDescription(portNo, enabled, |
... | @@ -600,8 +600,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -600,8 +600,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
600 | //yet not relevant for tunable OCH port, creating with default parameters | 600 | //yet not relevant for tunable OCH port, creating with default parameters |
601 | OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1); | 601 | OchSignal signalId = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 1, 1); |
602 | 602 | ||
603 | - portDes = new OchPortDescription(portNo, enabled, | 603 | + portDes = ochPortDescription(portNo, enabled, |
604 | - oduSignalType, true, signalId, annotations); | 604 | + oduSignalType, true, |
605 | + signalId, annotations); | ||
605 | 606 | ||
606 | break; | 607 | break; |
607 | case OTU2: | 608 | case OTU2: |
... | @@ -706,7 +707,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -706,7 +707,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
706 | Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); | 707 | Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations); |
707 | case 5: // OCH port | 708 | case 5: // OCH port |
708 | OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); | 709 | OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4); |
709 | - return new OchPortDescription(portNo, enabled, OduSignalType.ODU4, | 710 | + return ochPortDescription(portNo, enabled, OduSignalType.ODU4, |
710 | true, signal, annotations); | 711 | true, signal, annotations); |
711 | default: | 712 | default: |
712 | break; | 713 | break; | ... | ... |
... | @@ -38,7 +38,6 @@ import org.onosproject.net.HostId; | ... | @@ -38,7 +38,6 @@ import org.onosproject.net.HostId; |
38 | import org.onosproject.net.HostLocation; | 38 | import org.onosproject.net.HostLocation; |
39 | import org.onosproject.net.Link; | 39 | import org.onosproject.net.Link; |
40 | import org.onosproject.net.MastershipRole; | 40 | import org.onosproject.net.MastershipRole; |
41 | -import org.onosproject.net.OchPort; | ||
42 | import org.onosproject.net.OchSignal; | 41 | import org.onosproject.net.OchSignal; |
43 | import org.onosproject.net.OduCltPort; | 42 | import org.onosproject.net.OduCltPort; |
44 | import org.onosproject.net.OduSignalType; | 43 | import org.onosproject.net.OduSignalType; |
... | @@ -55,7 +54,6 @@ import org.onosproject.net.device.DeviceProvider; | ... | @@ -55,7 +54,6 @@ import org.onosproject.net.device.DeviceProvider; |
55 | import org.onosproject.net.device.DeviceProviderRegistry; | 54 | import org.onosproject.net.device.DeviceProviderRegistry; |
56 | import org.onosproject.net.device.DeviceProviderService; | 55 | import org.onosproject.net.device.DeviceProviderService; |
57 | import org.onosproject.net.device.DeviceService; | 56 | import org.onosproject.net.device.DeviceService; |
58 | -import org.onosproject.net.device.OchPortDescription; | ||
59 | import org.onosproject.net.device.OduCltPortDescription; | 57 | import org.onosproject.net.device.OduCltPortDescription; |
60 | import org.onosproject.net.device.OmsPortDescription; | 58 | import org.onosproject.net.device.OmsPortDescription; |
61 | import org.onosproject.net.device.PortDescription; | 59 | import org.onosproject.net.device.PortDescription; |
... | @@ -67,6 +65,7 @@ import org.onosproject.net.link.DefaultLinkDescription; | ... | @@ -67,6 +65,7 @@ import org.onosproject.net.link.DefaultLinkDescription; |
67 | import org.onosproject.net.link.LinkProvider; | 65 | import org.onosproject.net.link.LinkProvider; |
68 | import org.onosproject.net.link.LinkProviderRegistry; | 66 | import org.onosproject.net.link.LinkProviderRegistry; |
69 | import org.onosproject.net.link.LinkProviderService; | 67 | import org.onosproject.net.link.LinkProviderService; |
68 | +import org.onosproject.net.optical.OchPort; | ||
70 | import org.onosproject.net.provider.ProviderId; | 69 | import org.onosproject.net.provider.ProviderId; |
71 | import org.slf4j.Logger; | 70 | import org.slf4j.Logger; |
72 | import org.slf4j.LoggerFactory; | 71 | import org.slf4j.LoggerFactory; |
... | @@ -88,6 +87,8 @@ import static org.onosproject.net.DeviceId.deviceId; | ... | @@ -88,6 +87,8 @@ import static org.onosproject.net.DeviceId.deviceId; |
88 | import static org.onosproject.net.PortNumber.portNumber; | 87 | import static org.onosproject.net.PortNumber.portNumber; |
89 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; | 88 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; |
90 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; | 89 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; |
90 | +import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription; | ||
91 | +import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView; | ||
91 | 92 | ||
92 | /** | 93 | /** |
93 | * Provider of devices and links parsed from a JSON configuration structure. | 94 | * Provider of devices and links parsed from a JSON configuration structure. |
... | @@ -139,7 +140,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -139,7 +140,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
139 | LinkProviderRegistry linkProviderRegistry, | 140 | LinkProviderRegistry linkProviderRegistry, |
140 | HostProviderRegistry hostProviderRegistry) { | 141 | HostProviderRegistry hostProviderRegistry) { |
141 | this.cfg = checkNotNull(cfg, "Configuration cannot be null"); | 142 | this.cfg = checkNotNull(cfg, "Configuration cannot be null"); |
142 | - this.deviceService = checkNotNull(deviceService, "Device service cannot be null"); | 143 | + this.deviceService = opticalView(checkNotNull(deviceService, "Device service cannot be null")); |
143 | this.deviceProviderRegistry = checkNotNull(deviceProviderRegistry, "Device provider registry cannot be null"); | 144 | this.deviceProviderRegistry = checkNotNull(deviceProviderRegistry, "Device provider registry cannot be null"); |
144 | this.linkProviderRegistry = checkNotNull(linkProviderRegistry, "Link provider registry cannot be null"); | 145 | this.linkProviderRegistry = checkNotNull(linkProviderRegistry, "Link provider registry cannot be null"); |
145 | this.hostProviderRegistry = checkNotNull(hostProviderRegistry, "Host provider registry cannot be null"); | 146 | this.hostProviderRegistry = checkNotNull(hostProviderRegistry, "Host provider registry cannot be null"); |
... | @@ -269,7 +270,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -269,7 +270,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
269 | case OCH: | 270 | case OCH: |
270 | annotations = annotations(node.get("annotations")); | 271 | annotations = annotations(node.get("annotations")); |
271 | OchPort ochPort = (OchPort) deviceService.getPort(deviceId, port); | 272 | OchPort ochPort = (OchPort) deviceService.getPort(deviceId, port); |
272 | - return new OchPortDescription(port, node.path("enabled").asBoolean(true), | 273 | + return ochPortDescription(port, node.path("enabled").asBoolean(true), |
273 | ochPort.signalType(), ochPort.isTunable(), | 274 | ochPort.signalType(), ochPort.isTunable(), |
274 | ochPort.lambda(), annotations); | 275 | ochPort.lambda(), annotations); |
275 | case OMS: | 276 | case OMS: |
... | @@ -363,13 +364,13 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -363,13 +364,13 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
363 | } | 364 | } |
364 | OchSignal signal = new OchSignal(GridType.DWDM, chsp, 1, 1); | 365 | OchSignal signal = new OchSignal(GridType.DWDM, chsp, 1, 1); |
365 | if (src.type() == Device.Type.ROADM) { | 366 | if (src.type() == Device.Type.ROADM) { |
366 | - PortDescription portDesc = new OchPortDescription(srcCp.port(), true, | 367 | + PortDescription portDesc = ochPortDescription(srcCp.port(), true, |
367 | OduSignalType.ODU4, true, signal); | 368 | OduSignalType.ODU4, true, signal); |
368 | descriptions.put(srcCp, portDesc); | 369 | descriptions.put(srcCp, portDesc); |
369 | deviceProviderService.portStatusChanged(srcCp.deviceId(), portDesc); | 370 | deviceProviderService.portStatusChanged(srcCp.deviceId(), portDesc); |
370 | } | 371 | } |
371 | if (dst.type() == Device.Type.ROADM) { | 372 | if (dst.type() == Device.Type.ROADM) { |
372 | - PortDescription portDesc = new OchPortDescription(dstCp.port(), true, | 373 | + PortDescription portDesc = ochPortDescription(dstCp.port(), true, |
373 | OduSignalType.ODU4, true, signal); | 374 | OduSignalType.ODU4, true, signal); |
374 | descriptions.put(dstCp, portDesc); | 375 | descriptions.put(dstCp, portDesc); |
375 | deviceProviderService.portStatusChanged(dstCp.deviceId(), portDesc); | 376 | deviceProviderService.portStatusChanged(dstCp.deviceId(), portDesc); |
... | @@ -482,7 +483,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -482,7 +483,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
482 | op.number(), op.isEnabled(), op.minFrequency(), op.maxFrequency(), op.grid()); | 483 | op.number(), op.isEnabled(), op.minFrequency(), op.maxFrequency(), op.grid()); |
483 | case OCH: | 484 | case OCH: |
484 | OchPort ochp = (OchPort) p; | 485 | OchPort ochp = (OchPort) p; |
485 | - return new OchPortDescription( | 486 | + return ochPortDescription( |
486 | ochp.number(), ochp.isEnabled(), ochp.signalType(), ochp.isTunable(), ochp.lambda()); | 487 | ochp.number(), ochp.isEnabled(), ochp.signalType(), ochp.isTunable(), ochp.lambda()); |
487 | case ODUCLT: | 488 | case ODUCLT: |
488 | OduCltPort odup = (OduCltPort) p; | 489 | OduCltPort odup = (OduCltPort) p; | ... | ... |
-
Please register or login to post a comment