ONOS-4416 Remove OduCltPort out of core.
Change-Id: I04324a72e48af84afdbfa32b84c8e57f39411000
diff --git a/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java b/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java
index 273e0bb..de1b28d 100644
--- a/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java
+++ b/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java
@@ -30,7 +30,6 @@
import org.onosproject.net.Device;
import org.onosproject.net.Host;
import org.onosproject.net.Link;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Path;
import org.onosproject.net.Port;
@@ -46,6 +45,7 @@
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyEdge;
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
index 001c273..105c53e 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
@@ -21,7 +21,6 @@
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.DeviceId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Port;
@@ -32,6 +31,7 @@
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import java.util.List;
diff --git a/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
index 99e8e11..0acfece 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
@@ -25,12 +25,12 @@
import org.onlab.util.Frequency;
import org.onosproject.utils.Comparators;
import org.onosproject.net.Device;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OtuPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import java.util.ArrayList;
@@ -187,9 +187,22 @@
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
case ODUCLT:
- print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
- ((OduCltPort) port).signalType().toString(), annotations);
- break;
+ if (port instanceof org.onosproject.net.OduCltPort) {
+ // old OduCltPort model
+ org.onosproject.net.OduCltPort oPort = (org.onosproject.net.OduCltPort) port;
+ print("WARN: OduCltPort in old model");
+ print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
+ oPort.signalType().toString(), annotations);
+ break;
+ }
+ if (port instanceof OduCltPort) {
+ print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
+ ((OduCltPort) port).signalType().toString(), annotations);
+ break;
+ }
+ print("WARN: OduCltPort but not on OpticalDevice or ill-formed");
+ print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
+ break;
case OMS:
if (port instanceof org.onosproject.net.OmsPort) {
org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
diff --git a/core/api/src/main/java/org/onosproject/net/OduCltPort.java b/core/api/src/main/java/org/onosproject/net/OduCltPort.java
index 0f3a729..4af663c 100644
--- a/core/api/src/main/java/org/onosproject/net/OduCltPort.java
+++ b/core/api/src/main/java/org/onosproject/net/OduCltPort.java
@@ -24,8 +24,10 @@
* Implementation of ODU client port (Optical channel Data Unit).
* Also referred to as a T-port or wide band port.
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * @deprecated in Goldeneye (1.6.0)
*/
-
+@Deprecated
public class OduCltPort extends DefaultPort {
private final CltSignalType signalType;
diff --git a/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java b/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java
index 379f54e..e601a9f 100644
--- a/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/OduCltPortDescription.java
@@ -23,7 +23,10 @@
/**
* Default implementation of immutable ODU client port description.
+ *
+ * @deprecated in Goldeneye (1.6.0)
*/
+@Deprecated
public class OduCltPortDescription extends DefaultPortDescription {
private final CltSignalType signalType;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java b/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java
new file mode 100644
index 0000000..b4342f4
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/OduCltPort.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical;
+
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * ODU client port (Optical channel Data Unit).
+ * Also referred to as a T-port or wide band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public interface OduCltPort extends Port {
+
+ /**
+ * Returns ODU client signal type.
+ *
+ * @return ODU client signal type
+ */
+ CltSignalType signalType();
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java
index 0b4ff68..0015cf9 100644
--- a/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java
@@ -28,9 +28,11 @@
import org.onosproject.net.driver.AbstractBehaviour;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import org.onosproject.net.optical.device.port.OchPortMapper;
+import org.onosproject.net.optical.device.port.OduCltPortMapper;
import org.onosproject.net.optical.device.port.OmsPortMapper;
import org.onosproject.net.optical.device.port.PortMapper;
import org.onosproject.net.optical.utils.ForwardingDevice;
@@ -63,6 +65,7 @@
= ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
.put(OchPort.class, new OchPortMapper())
.put(OmsPort.class, new OmsPortMapper())
+ .put(OduCltPort.class, new OduCltPortMapper())
// TODO add other optical port type here
.build();
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
new file mode 100644
index 0000000..efda401
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Optional;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * ODU client port related helpers.
+ */
+@Beta
+public final class OduCltPortHelper {
+
+ private static final Logger log = getLogger(OduCltPortHelper.class);
+
+ // Annotation keys
+ /**
+ * {@link CltSignalType} as String.
+ */
+ private static final String SIGNAL_TYPE = "signalType";
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU client signal type
+ */
+ public static PortDescription oduCltPortDescription(PortNumber number,
+ boolean isEnabled,
+ CltSignalType signalType) {
+ return oduCltPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription oduCltPortDescription(PortNumber number,
+ boolean isEnabled,
+ CltSignalType signalType,
+ SparseAnnotations annotations) {
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotations);
+
+ builder.set(SIGNAL_TYPE, signalType.toString());
+
+ long portSpeed = signalType.bitRate();
+ return new DefaultPortDescription(number,
+ isEnabled,
+ Port.Type.ODUCLT,
+ portSpeed,
+ builder.build());
+ }
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param signalType ODU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription oduCltPortDescription(PortDescription base,
+ CltSignalType signalType,
+ SparseAnnotations annotations) {
+ return oduCltPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
+ }
+
+ public static Optional<OduCltPort> asOduCltPort(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ CltSignalType signalType = Enum.valueOf(CltSignalType.class,
+ an.value(SIGNAL_TYPE));
+
+
+ // Note: ODU specific annotations is not filtered-out here.
+ // DefaultOduCltPort should filter them, if necessary.
+ return Optional.of(new DefaultOduCltPort(port, signalType));
+
+ } catch (NullPointerException | IllegalArgumentException e) {
+
+ log.warn("{} was not well-formed OduClt port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+ // not meant to be instantiated
+ private OduCltPortHelper() {}
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
new file mode 100644
index 0000000..6eeb631
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.device.OduCltPortHelper;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OduCltPort} translation.
+ */
+@Beta
+public class OduCltPortMapper extends AbstractPortMapper<OduCltPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.ODUCLT &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OduCltPort> as(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OduCltPort> mapPort(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ } else if (port instanceof org.onosproject.net.OduCltPort) {
+ // TODO remove after deprecation of old OduCltPort is complete
+
+ // translate to new OduCltPort
+ org.onosproject.net.OduCltPort old = (org.onosproject.net.OduCltPort) port;
+ return Optional.of(new DefaultOduCltPort(old,
+ old.signalType()));
+ }
+
+ return OduCltPortHelper.asOduCltPort(port);
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
new file mode 100644
index 0000000..f98becd
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of ODU client port (Optical channel Data Unit).
+ * Also referred to as a T-port or wide band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public class DefaultOduCltPort extends ForwardingPort implements OduCltPort {
+
+ private final CltSignalType signalType;
+
+ /**
+ * Creates an ODU client port.
+ *
+ * @param delegate Port
+ * @param signalType ODU client signal type
+ */
+ public DefaultOduCltPort(Port delegate, CltSignalType signalType) {
+ super(delegate);
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODUCLT;
+ }
+
+ @Override
+ public long portSpeed() {
+ return signalType().bitRate();
+ }
+
+ @Override
+ public CltSignalType signalType() {
+ return signalType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(),
+ signalType());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj != null && getClass() == obj.getClass()) {
+ final DefaultOduCltPort that = (DefaultOduCltPort) obj;
+ return super.toEqualsBuilder(that)
+ .append(this.signalType(), that.signalType())
+ .isEquals();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toStringHelper()
+ .add("signalType", signalType())
+ .toString();
+ }
+
+}
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java b/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
index 14f6aeb..51000a9 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/OpticalPortOperator.java
@@ -16,6 +16,7 @@
package org.onosproject.net.device.impl;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import static org.slf4j.LoggerFactory.getLogger;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -25,7 +26,6 @@
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.OtuPort;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
@@ -36,6 +36,7 @@
import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import org.slf4j.Logger;
@@ -121,8 +122,12 @@
}
return descr;
case ODUCLT:
- OduCltPortDescription odu = (OduCltPortDescription) descr;
- return new OduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa);
+ if (descr instanceof OduCltPortDescription) {
+ // TODO This block can go away once deprecation is complete.
+ OduCltPortDescription odu = (OduCltPortDescription) descr;
+ return oduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa);
+ }
+ return descr;
case PACKET:
case FIBER:
case COPPER:
@@ -223,8 +228,19 @@
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
case ODUCLT:
- OduCltPort odu = (OduCltPort) port;
- return new OduCltPortDescription(ptn, isup, odu.signalType(), an);
+ if (port instanceof org.onosproject.net.OduCltPort) {
+ // remove if-block once deprecation is complete
+ org.onosproject.net.OduCltPort odu = (org.onosproject.net.OduCltPort) port;
+ return oduCltPortDescription(ptn, isup, odu.signalType(), an);
+ }
+ if (port.element().is(OpticalDevice.class)) {
+ OpticalDevice optDevice = port.element().as(OpticalDevice.class);
+ if (optDevice.portIs(port, OduCltPort.class)) {
+ OduCltPort odu = (OduCltPort) port;
+ return oduCltPortDescription(ptn, isup, odu.signalType(), an);
+ }
+ }
+ return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
case OTU:
OtuPort otu = (OtuPort) port;
return new OtuPortDescription(ptn, isup, otu.signalType(), an);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index bf8152e..baa5260 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -32,7 +32,6 @@
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
@@ -60,6 +59,7 @@
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.intent.IntentSetMultimap;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.Resource;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
index 918438c..18a8f17 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -27,7 +27,6 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
@@ -50,6 +49,7 @@
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.ResourceAllocation;
@@ -77,6 +77,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.onosproject.net.LinkKey.linkKey;
+import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
/**
* An intent compiler for {@link org.onosproject.net.intent.OpticalOduIntent}.
@@ -105,6 +106,7 @@
@Activate
public void activate() {
+ deviceService = opticalView(deviceService);
appId = coreService.registerApplication("org.onosproject.net.intent");
intentManager.registerCompiler(OpticalOduIntent.class, this);
}
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
index 9d72cd0..1a7f778 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
@@ -35,7 +35,6 @@
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.OchSignal;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
@@ -58,7 +57,9 @@
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.impl.DefaultOchPort;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.intent.IntentSetMultimap;
import org.onosproject.net.behaviour.TributarySlotQuery;
@@ -124,9 +125,11 @@
// OduClt ports with signalType=1GBE
private static final OduCltPort D1P1 =
- new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(1), true, annotations1),
+ CltSignalType.CLT_1GBE);
private static final OduCltPort D2P1 =
- new OduCltPort(device2, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device2, PortNumber.portNumber(1), true, annotations1),
+ CltSignalType.CLT_1GBE);
// Och ports with signalType=ODU2
private static final OchPort D1P2 =
@@ -140,9 +143,11 @@
// OduClt ports with signalType=10GBE
private static final OduCltPort D1P3 =
- new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(3), true, annotations1),
+ CltSignalType.CLT_10GBE);
private static final OduCltPort D2P3 =
- new OduCltPort(device2, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device2, PortNumber.portNumber(3), true, annotations1),
+ CltSignalType.CLT_10GBE);
private OpticalCircuitIntent intent;
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
index 62182eb..5f45ae4 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
@@ -23,6 +23,7 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
+import org.onosproject.net.AbstractProjectableModel;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.CltSignalType;
@@ -30,10 +31,10 @@
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
+import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
@@ -56,11 +57,15 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalOduIntent;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyServiceAdapter;
import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.net.driver.DriverServiceAdapter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
@@ -116,9 +121,11 @@
// OduClt ports with signalType=1GBE
private static final OduCltPort D1P1 =
- new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(1), true, annotations1),
+ CltSignalType.CLT_1GBE);
private static final OduCltPort D3P2 =
- new OduCltPort(device3, PortNumber.portNumber(2), true, CltSignalType.CLT_1GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device3, PortNumber.portNumber(2), true, annotations1),
+ CltSignalType.CLT_1GBE);
// Otu ports with signalType=ODU2
private static final OtuPort D1P2 =
@@ -132,9 +139,11 @@
// OduClt ports with signalType=10GBE
private static final OduCltPort D1P3 =
- new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(3), true, annotations1),
+ CltSignalType.CLT_10GBE);
private static final OduCltPort D3P3 =
- new OduCltPort(device3, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+ new DefaultOduCltPort(new DefaultPort(device3, PortNumber.portNumber(3), true, annotations1),
+ CltSignalType.CLT_10GBE);
// OduCltPort ConnectPoints
private final ConnectPoint d1p1 = new ConnectPoint(device1.id(), D1P1.number());
@@ -204,11 +213,11 @@
if (deviceId.equals(deviceId(DEV1))) {
switch (portNumber.toString()) {
case "1":
- return (Port) D1P1;
+ return D1P1;
case "2":
- return (Port) D1P2;
+ return D1P2;
case "3":
- return (Port) D1P3;
+ return D1P3;
default:
return null;
}
@@ -216,9 +225,9 @@
if (deviceId.equals(deviceId(DEV2))) {
switch (portNumber.toString()) {
case "1":
- return (Port) D2P1;
+ return D2P1;
case "2":
- return (Port) D2P2;
+ return D2P2;
default:
return null;
}
@@ -226,11 +235,11 @@
if (deviceId.equals(deviceId(DEV3))) {
switch (portNumber.toString()) {
case "1":
- return (Port) D3P1;
+ return D3P1;
case "2":
- return (Port) D3P2;
+ return D3P2;
case "3":
- return (Port) D3P3;
+ return D3P3;
default:
return null;
}
@@ -239,8 +248,15 @@
}
}
+ private static class MockDriverService extends DriverServiceAdapter
+ implements DriverService {
+ // TODO override to return appropriate driver,
+ // with DefaultOpticalDevice support, etc.
+ }
+
@Before
public void setUp() {
+ AbstractProjectableModel.setDriverService(null, new MockDriverService());
sut = new OpticalOduIntentCompiler();
coreService = createMock(CoreService.class);
expect(coreService.registerApplication("org.onosproject.net.intent"))
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java
index ed3b44e..12eaa36 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/DeviceDescriptions.java
@@ -18,6 +18,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.DefaultAnnotations.union;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import java.util.Collections;
@@ -140,11 +141,20 @@
}
break;
case ODUCLT:
- OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
- newOne = new Timestamped<>(
- new OduCltPortDescription(
- ocDesc, ocDesc.signalType(), merged),
- newDesc.timestamp());
+ if (newDesc.value() instanceof OduCltPortDescription) {
+ // remove if-block after deprecation is complete
+ OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
+ newOne = new Timestamped<>(
+ oduCltPortDescription(ocDesc,
+ ocDesc.signalType(),
+ merged),
+ newDesc.timestamp());
+ } else {
+ // same as default case
+ newOne = new Timestamped<>(
+ new DefaultPortDescription(newDesc.value(), merged),
+ newDesc.timestamp());
+ }
break;
case OTU:
OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value());
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
index fad232e..cf9e23c 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/ECDeviceStore.java
@@ -549,8 +549,14 @@
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
case ODUCLT:
- OduCltPortDescription oduDesc = (OduCltPortDescription) description;
- return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
+ if (description instanceof OduCltPortDescription) {
+ // remove if-block once deprecation is complete
+ OduCltPortDescription oduDesc = (OduCltPortDescription) description;
+ return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
+ }
+ // same as default
+ return new DefaultPort(device, number, isEnabled, description.type(),
+ description.portSpeed(), annotations);
default:
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index e6d645f..ea25e8c 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -1107,8 +1107,14 @@
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
case ODUCLT:
- OduCltPortDescription oduDesc = (OduCltPortDescription) description;
- return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
+ if (description instanceof OduCltPortDescription) {
+ // remove if-block once deprecation is complete
+ OduCltPortDescription oduDesc = (OduCltPortDescription) description;
+ return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
+ }
+ // same as default
+ return new DefaultPort(device, number, isEnabled, description.type(),
+ description.portSpeed(), annotations);
case OTU:
OtuPortDescription otuDesc = (OtuPortDescription) description;
return new OtuPort(device, number, isEnabled, otuDesc.signalType(), annotations);
diff --git a/drivers/ciena/src/main/java/org/onosproject/drivers/ciena/PortDiscoveryCienaWaveserverImpl.java b/drivers/ciena/src/main/java/org/onosproject/drivers/ciena/PortDiscoveryCienaWaveserverImpl.java
index 4e80e57..8946a92 100644
--- a/drivers/ciena/src/main/java/org/onosproject/drivers/ciena/PortDiscoveryCienaWaveserverImpl.java
+++ b/drivers/ciena/src/main/java/org/onosproject/drivers/ciena/PortDiscoveryCienaWaveserverImpl.java
@@ -27,7 +27,6 @@
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.PortDiscovery;
-import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.driver.DriverHandler;
@@ -37,6 +36,7 @@
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
/**
* Discovers the ports from a Ciena WaveServer Rest device.
@@ -114,7 +114,7 @@
sub.getString(SPEED).replace(GBPS, EMPTY_STRING)
.replace(" ", EMPTY_STRING))) == speed100GbpsinMbps ?
CltSignalType.CLT_100GBE : null;
- ports.add(new OduCltPortDescription(PortNumber.portNumber(sub.getLong(PORT_ID)),
+ ports.add(oduCltPortDescription(PortNumber.portNumber(sub.getLong(PORT_ID)),
sub.getString(ADMIN_STATE).equals(ENABLED),
cltType, annotations.build()));
}
diff --git a/drivers/utilities/src/main/java/org/onosproject/drivers/utilities/XmlConfigParser.java b/drivers/utilities/src/main/java/org/onosproject/drivers/utilities/XmlConfigParser.java
index dd46629..7c88fde 100644
--- a/drivers/utilities/src/main/java/org/onosproject/drivers/utilities/XmlConfigParser.java
+++ b/drivers/utilities/src/main/java/org/onosproject/drivers/utilities/XmlConfigParser.java
@@ -32,12 +32,12 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.behaviour.ControllerInfo;
-import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.PortDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import java.io.InputStream;
import java.io.StringWriter;
@@ -119,7 +119,7 @@
return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations);
}
- private static OduCltPortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
+ private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
PortNumber portNumber = PortNumber.portNumber(count);
HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
boolean enabled = ethernetConfig.getString("administrative-state").equals("up");
@@ -129,7 +129,7 @@
DefaultAnnotations annotations = DefaultAnnotations.builder().
set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
build();
- return new OduCltPortDescription(portNumber, enabled, signalType, annotations);
+ return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
protected static String parseSwitchId(HierarchicalConfiguration cfg) {
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index b2748ef..33ae4c2 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -22,6 +22,7 @@
import static org.onosproject.net.Port.Type.COPPER;
import static org.onosproject.net.Port.Type.FIBER;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import static org.onosproject.openflow.controller.Dpid.dpid;
import static org.onosproject.openflow.controller.Dpid.uri;
@@ -67,7 +68,6 @@
import org.onosproject.net.device.DeviceProvider;
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.device.PortStatistics;
@@ -523,7 +523,7 @@
}
SparseAnnotations annotations = buildOduCltAnnotation(port);
- return new OduCltPortDescription(portNo, enabled, sigType, annotations);
+ return oduCltPortDescription(portNo, enabled, sigType, annotations);
}
private SparseAnnotations buildOduCltAnnotation(OFPortDesc port) {
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
index fa00969..453f206 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
@@ -39,7 +39,6 @@
import org.onosproject.net.Link;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.OchSignal;
-import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
@@ -53,7 +52,6 @@
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.host.DefaultHostDescription;
import org.onosproject.net.host.HostProvider;
@@ -64,6 +62,7 @@
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
@@ -87,6 +86,7 @@
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED;
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
+import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
@@ -265,7 +265,7 @@
case ODUCLT:
annotations = annotations(node.get("annotations"));
OduCltPort oduCltPort = (OduCltPort) deviceService.getPort(deviceId, port);
- return new OduCltPortDescription(port, node.path("enabled").asBoolean(true),
+ return oduCltPortDescription(port, node.path("enabled").asBoolean(true),
oduCltPort.signalType(), annotations);
case OCH:
annotations = annotations(node.get("annotations"));
@@ -487,7 +487,7 @@
ochp.number(), ochp.isEnabled(), ochp.signalType(), ochp.isTunable(), ochp.lambda());
case ODUCLT:
OduCltPort odup = (OduCltPort) p;
- return new OduCltPortDescription(
+ return oduCltPortDescription(
odup.number(), odup.isEnabled(), odup.signalType());
default:
return new DefaultPortDescription(p.number(), p.isEnabled(), p.type(), p.portSpeed());