ONOS-4417 Remove OtuPort out of core.
Change-Id: Ibc72ee617b238005585f0bcd873b9123e48ee7fc
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 0acfece..5c994d1 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
@@ -25,7 +25,6 @@
import org.onlab.util.Frequency;
import org.onosproject.utils.Comparators;
import org.onosproject.net.Device;
-import org.onosproject.net.OtuPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
@@ -33,6 +32,8 @@
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.OtuPort;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -227,8 +228,20 @@
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
case OTU:
- print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
- ((OtuPort) port).signalType().toString(), annotations);
+ if (port instanceof org.onosproject.net.OtuPort) {
+ org.onosproject.net.OtuPort otu = (org.onosproject.net.OtuPort) port;
+ print("WARN: OtuPort in old model");
+ print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
+ otu.signalType().toString(), annotations);
+ break;
+ }
+ if (port instanceof OtuPort) {
+ print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
+ ((OtuPort) port).signalType().toString(), annotations);
+ break;
+ }
+ print("WARN: OtuPort but not on OpticalDevice or ill-formed");
+ print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
default:
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
diff --git a/core/api/src/main/java/org/onosproject/net/OtuPort.java b/core/api/src/main/java/org/onosproject/net/OtuPort.java
index 25c7295..60456cd 100644
--- a/core/api/src/main/java/org/onosproject/net/OtuPort.java
+++ b/core/api/src/main/java/org/onosproject/net/OtuPort.java
@@ -21,8 +21,10 @@
/**
* Implementation of OTU port (Optical channel Transport Unit).
+ *
+ * @deprecated in Goldeneye (1.6.0)
*/
-
+@Deprecated
public class OtuPort extends DefaultPort {
private final OtuSignalType signalType;
diff --git a/core/api/src/main/java/org/onosproject/net/device/OtuPortDescription.java b/core/api/src/main/java/org/onosproject/net/device/OtuPortDescription.java
index ac5d855..5495524 100644
--- a/core/api/src/main/java/org/onosproject/net/device/OtuPortDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/OtuPortDescription.java
@@ -24,7 +24,10 @@
/**
* Default implementation of immutable OTU port description.
+ *
+ * @deprecated in Goldeneye (1.6.0)
*/
+@Deprecated
public class OtuPortDescription extends DefaultPortDescription {
private final OtuSignalType signalType;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java b/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java
new file mode 100644
index 0000000..15f284d
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/OtuPort.java
@@ -0,0 +1,39 @@
+/*
+ * 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 gcd ~/Dooverning permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical;
+
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OTU port (Optical channel Transport Unit).
+ * <p>
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and
+ * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
+ */
+@Beta
+public interface OtuPort extends Port {
+
+ /**
+ * Returns OTU signal type.
+ *
+ * @return OTU signal type
+ */
+ public OtuSignalType 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 0015cf9..d7608b9 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
@@ -31,9 +31,11 @@
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.OtuPort;
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.OtuPortMapper;
import org.onosproject.net.optical.device.port.PortMapper;
import org.onosproject.net.optical.utils.ForwardingDevice;
import org.slf4j.Logger;
@@ -66,6 +68,7 @@
.put(OchPort.class, new OchPortMapper())
.put(OmsPort.class, new OmsPortMapper())
.put(OduCltPort.class, new OduCltPortMapper())
+ .put(OtuPort.class, new OtuPortMapper())
// TODO add other optical port type here
.build();
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
new file mode 100644
index 0000000..aeac4f9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
@@ -0,0 +1,129 @@
+/*
+ * 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.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.OtuSignalType;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.optical.impl.DefaultOtuPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OTU port related helpers.
+ */
+@Beta
+public final class OtuPortHelper {
+
+ private static final Logger log = getLogger(OtuPortHelper.class);
+
+ // Annotation keys
+ /**
+ * {@link OtuSignalType} as String.
+ */
+ private static final String SIGNAL_TYPE = "signalType";
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType OTU client signal type
+ */
+ public static PortDescription otuPortDescription(PortNumber number,
+ boolean isEnabled,
+ OtuSignalType signalType) {
+ return otuPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType OTU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription otuPortDescription(PortNumber number,
+ boolean isEnabled,
+ OtuSignalType signalType,
+ SparseAnnotations annotations) {
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotations);
+
+ builder.set(SIGNAL_TYPE, signalType.toString());
+
+ long portSpeed = 0; // TODO specify appropriate value?
+ return new DefaultPortDescription(number,
+ isEnabled,
+ Port.Type.OTU,
+ portSpeed,
+ builder.build());
+ }
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param signalType OTU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription otuPortDescription(PortDescription base,
+ OtuSignalType signalType,
+ SparseAnnotations annotations) {
+ return otuPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
+ }
+
+ public static Optional<OtuPort> asOtuPort(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ OtuSignalType signalType = Enum.valueOf(OtuSignalType.class,
+ an.value(SIGNAL_TYPE));
+
+
+ // Note: OTU specific annotations is not filtered-out here.
+ // DefaultOtuPort should filter them, if necessary.
+ return Optional.of(new DefaultOtuPort(port, signalType));
+
+ } catch (NullPointerException | IllegalArgumentException e) {
+
+ log.warn("{} was not well-formed Otu port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+
+ // not meant to be instantiated
+ private OtuPortHelper() {}
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
new file mode 100644
index 0000000..c70033a
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
@@ -0,0 +1,65 @@
+/*
+ * 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.OtuPort;
+import org.onosproject.net.optical.device.OtuPortHelper;
+import org.onosproject.net.optical.impl.DefaultOtuPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OtuPort} translation.
+ */
+@Beta
+public class OtuPortMapper extends AbstractPortMapper<OtuPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.OTU &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OtuPort> as(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OtuPort> mapPort(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ } else if (port instanceof org.onosproject.net.OtuPort) {
+ // TODO remove after deprecation of old OtuPort is complete
+
+ // translate to new OtuPort
+ org.onosproject.net.OtuPort old = (org.onosproject.net.OtuPort) port;
+ return Optional.of(new DefaultOtuPort(old,
+ old.signalType()));
+ }
+
+ return OtuPortHelper.asOtuPort(port);
+ }
+
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
new file mode 100644
index 0000000..4a5a79b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
@@ -0,0 +1,92 @@
+/*
+ * 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.OtuSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.optical.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of OTU port (Optical channel Transport Unit).
+ *
+ */
+@Beta
+public class DefaultOtuPort extends ForwardingPort implements OtuPort {
+
+ private final OtuSignalType signalType;
+
+ /**
+ * Creates an ODU client port.
+ *
+ * @param delegate Port
+ * @param signalType OTU signal type
+ */
+ public DefaultOtuPort(Port delegate, OtuSignalType signalType) {
+ super(delegate);
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.OTU;
+ }
+
+// @Override
+// public long portSpeed() {
+// return signalType().bitRate();
+// }
+
+ @Override
+ public OtuSignalType 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 DefaultOtuPort that = (DefaultOtuPort) 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 51000a9..0bf45b3 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
@@ -18,6 +18,7 @@
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.OtuPortHelper.otuPortDescription;
import static org.slf4j.LoggerFactory.getLogger;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -25,7 +26,6 @@
import org.onosproject.net.config.basics.OpticalPortConfig;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.OtuPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
@@ -39,6 +39,7 @@
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.OtuPort;
import org.slf4j.Logger;
/**
@@ -135,8 +136,12 @@
return new DefaultPortDescription(port, descr.isEnabled(), descr.type(),
descr.portSpeed(), sa);
case OTU:
- OtuPortDescription otu = (OtuPortDescription) descr;
- return new OtuPortDescription(port, otu.isEnabled(), otu.signalType(), sa);
+ if (descr instanceof OtuPortDescription) {
+ // TODO This block can go away once deprecation is complete.
+ OtuPortDescription otu = (OtuPortDescription) descr;
+ return otuPortDescription(port, otu.isEnabled(), otu.signalType(), sa);
+ }
+ return descr;
default:
log.warn("Unsupported optical port type {} - can't update", descr.type());
return descr;
@@ -242,8 +247,19 @@
}
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
case OTU:
- OtuPort otu = (OtuPort) port;
- return new OtuPortDescription(ptn, isup, otu.signalType(), an);
+ if (port instanceof org.onosproject.net.OtuPort) {
+ // remove if-block once deprecation is complete
+ org.onosproject.net.OtuPort otu = (org.onosproject.net.OtuPort) port;
+ return otuPortDescription(ptn, isup, otu.signalType(), an);
+ }
+ if (port.element().is(OpticalDevice.class)) {
+ OpticalDevice optDevice = port.element().as(OpticalDevice.class);
+ if (optDevice.portIs(port, OtuPort.class)) {
+ OtuPort otu = (OtuPort) port;
+ return otuPortDescription(ptn, isup, otu.signalType(), an);
+ }
+ }
+ return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
default:
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
}
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 18a8f17..d89cf1e 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
@@ -30,7 +30,6 @@
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
-import org.onosproject.net.OtuPort;
import org.onosproject.net.Path;
import org.onosproject.net.Port;
import org.onosproject.net.TributarySlot;
@@ -50,6 +49,7 @@
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.OtuPort;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.ResourceAllocation;
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 5f45ae4..a6ba3fe 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
@@ -38,7 +38,6 @@
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
-import org.onosproject.net.OtuPort;
import org.onosproject.net.OtuSignalType;
import org.onosproject.net.Path;
import org.onosproject.net.Port;
@@ -58,7 +57,9 @@
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.OtuPort;
import org.onosproject.net.optical.impl.DefaultOduCltPort;
+import org.onosproject.net.optical.impl.DefaultOtuPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
@@ -129,13 +130,17 @@
// Otu ports with signalType=ODU2
private static final OtuPort D1P2 =
- new OtuPort(device1, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2);
+ new DefaultOtuPort(new DefaultPort(device1, PortNumber.portNumber(2), true, annotations2),
+ OtuSignalType.OTU2);
private static final OtuPort D2P1 =
- new OtuPort(device2, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2);
+ new DefaultOtuPort(new DefaultPort(device2, PortNumber.portNumber(1), true, annotations2),
+ OtuSignalType.OTU2);
private static final OtuPort D2P2 =
- new OtuPort(device2, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2);
+ new DefaultOtuPort(new DefaultPort(device2, PortNumber.portNumber(2), true, annotations2),
+ OtuSignalType.OTU2);
private static final OtuPort D3P1 =
- new OtuPort(device3, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2);
+ new DefaultOtuPort(new DefaultPort(device3, PortNumber.portNumber(1), true, annotations2),
+ OtuSignalType.OTU2);
// OduClt ports with signalType=10GBE
private static final OduCltPort D1P3 =
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 12eaa36..c0bd97b 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
@@ -20,6 +20,7 @@
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.OtuPortHelper.otuPortDescription;
import java.util.Collections;
import java.util.Map;
@@ -157,11 +158,19 @@
}
break;
case OTU:
- OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value());
- newOne = new Timestamped<>(
- new OtuPortDescription(
- otuDesc, otuDesc.signalType(), merged),
- newDesc.timestamp());
+ if (newDesc.value() instanceof OtuPortDescription) {
+ // remove if-block after deprecation is complete
+ OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value());
+ newOne = new Timestamped<>(
+ otuPortDescription(
+ otuDesc, otuDesc.signalType(), merged),
+ newDesc.timestamp());
+ } else {
+ // same as default case
+ newOne = new Timestamped<>(
+ new DefaultPortDescription(newDesc.value(), merged),
+ newDesc.timestamp());
+ }
break;
default:
newOne = new Timestamped<>(
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 ea25e8c..3af8945 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
@@ -1116,8 +1116,14 @@
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);
+ if (description instanceof OtuPortDescription) {
+ // remove if-block once deprecation is complete
+ OtuPortDescription otuDesc = (OtuPortDescription) description;
+ return new OtuPort(device, number, isEnabled, otuDesc.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/drivers/default/src/main/java/org/onosproject/driver/query/DefaultTributarySlotQuery.java b/drivers/default/src/main/java/org/onosproject/driver/query/DefaultTributarySlotQuery.java
index 4129fd5..f3a7cb3 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/query/DefaultTributarySlotQuery.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/query/DefaultTributarySlotQuery.java
@@ -17,7 +17,6 @@
import org.onlab.util.GuavaCollectors;
import org.onosproject.net.OduSignalType;
-import org.onosproject.net.OtuPort;
import org.onosproject.net.OtuSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
@@ -25,6 +24,7 @@
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OtuPort;
import org.onosproject.net.behaviour.TributarySlotQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,7 +70,7 @@
case OCH:
return queryOchTributarySlots(p);
case OTU:
- return queryOtuTributarySlots((OtuPort) p);
+ return queryOtuTributarySlots(p);
default:
return Collections.emptySet();
}
@@ -102,8 +102,21 @@
}
}
- private Set<TributarySlot> queryOtuTributarySlots(OtuPort otuPort) {
- OtuSignalType signalType = otuPort.signalType();
+ private Set<TributarySlot> queryOtuTributarySlots(Port otuPort) {
+ OtuSignalType signalType = null;
+ if (otuPort instanceof org.onosproject.net.OtuPort) {
+ // remove once deprecation of old OtuPort model is done
+ signalType = ((org.onosproject.net.OtuPort) otuPort).signalType();
+ }
+ if (otuPort instanceof OtuPort) {
+ signalType = ((OtuPort) otuPort).signalType();
+ }
+
+ if (signalType == null) {
+ log.warn("{} was not an OtuPort", otuPort);
+ return Collections.emptySet();
+ }
+
switch (signalType) {
case OTU2:
return ENTIRE_ODU2_TRIBUTARY_SLOTS;
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 33ae4c2..bd4ecc0 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
@@ -24,6 +24,7 @@
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.OtuPortHelper.otuPortDescription;
import static org.onosproject.openflow.controller.Dpid.dpid;
import static org.onosproject.openflow.controller.Dpid.uri;
import static org.slf4j.LoggerFactory.getLogger;
@@ -68,7 +69,6 @@
import org.onosproject.net.device.DeviceProvider;
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.provider.AbstractProvider;
@@ -624,7 +624,7 @@
OtuSignalType otuSignalType =
((sigType == OFPortOpticalTransportSignalType.OTU2) ? OtuSignalType.OTU2 :
OtuSignalType.OTU4);
- portDes = new OtuPortDescription(portNo, enabled, otuSignalType, annotations);
+ portDes = otuPortDescription(portNo, enabled, otuSignalType, annotations);
break;
default:
break;