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
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 4c391ce..2eea2c2 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
@@ -17,6 +17,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 java.util.Collections;
import java.util.Map;
@@ -111,11 +112,21 @@
newDesc.timestamp());
break;
case OCH:
- OchPortDescription ochDesc = (OchPortDescription) (newDesc.value());
- newOne = new Timestamped<>(
- new OchPortDescription(
- ochDesc, ochDesc.signalType(), ochDesc.isTunable(), ochDesc.lambda(), merged),
- newDesc.timestamp());
+ if (newDesc.value() instanceof OchPortDescription) {
+ // remove if-block after Och related deprecation is complete
+ OchPortDescription ochDesc = (OchPortDescription) (newDesc.value());
+ newOne = new Timestamped<>(
+ ochPortDescription(ochDesc,
+ ochDesc.signalType(),
+ ochDesc.isTunable(),
+ ochDesc.lambda(), merged),
+ newDesc.timestamp());
+ } else {
+ // same as default case
+ newOne = new Timestamped<>(
+ new DefaultPortDescription(newDesc.value(), merged),
+ newDesc.timestamp());
+ }
break;
case ODUCLT:
OduCltPortDescription ocDesc = (OduCltPortDescription) (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 0780859..480e973 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
@@ -527,15 +527,21 @@
private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled,
PortDescription description, Annotations annotations) {
+ // FIXME this switch need to go away once all ports are done.
switch (description.type()) {
case OMS:
OmsPortDescription omsDesc = (OmsPortDescription) description;
return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
omsDesc.maxFrequency(), omsDesc.grid(), annotations);
case OCH:
- OchPortDescription ochDesc = (OchPortDescription) description;
- return new OchPort(device, number, isEnabled, ochDesc.signalType(),
- ochDesc.isTunable(), ochDesc.lambda(), annotations);
+ if (description instanceof OchPortDescription) {
+ // remove if-block once Och deprecation is complete
+ OchPortDescription ochDesc = (OchPortDescription) description;
+ return new OchPort(device, number, isEnabled, ochDesc.signalType(),
+ ochDesc.isTunable(), ochDesc.lambda(), annotations);
+ }
+ 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);
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 5437186..d29b72a 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
@@ -1085,15 +1085,21 @@
private Port buildTypedPort(Device device, PortNumber number, boolean isEnabled,
PortDescription description, Annotations annotations) {
+ // FIXME this switch need to go away once all ports are done.
switch (description.type()) {
case OMS:
OmsPortDescription omsDesc = (OmsPortDescription) description;
return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
omsDesc.maxFrequency(), omsDesc.grid(), annotations);
case OCH:
- OchPortDescription ochDesc = (OchPortDescription) description;
- return new OchPort(device, number, isEnabled, ochDesc.signalType(),
- ochDesc.isTunable(), ochDesc.lambda(), annotations);
+ if (description instanceof OchPortDescription) {
+ // remove if-block once Och deprecation is complete
+ OchPortDescription ochDesc = (OchPortDescription) description;
+ return new OchPort(device, number, isEnabled, ochDesc.signalType(),
+ ochDesc.isTunable(), ochDesc.lambda(), annotations);
+ }
+ 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);