Add OTN device and ports

Change-Id: I18f3376d1466077e95d7324a27a660302f0123b3
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index 5f6fb04..60fd95a 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -352,7 +352,8 @@
             final Device device = getDevice(deviceId);
 
             List<PortDescription> descs = ports.stream().map(
-              port -> (!(Device.Type.ROADM.equals(device.type()))) ?
+              port -> (!(Device.Type.ROADM.equals(device.type()) ||
+                        (Device.Type.OTN.equals(device.type())))) ?
                   new DefaultPortDescription(port.number(), false,
                           port.type(), port.portSpeed()) :
                       OpticalPortOperator.descriptionOf(port, false)
@@ -439,7 +440,8 @@
                 return;
             }
             Device device = nullIsNotFound(getDevice(deviceId), "Device not found");
-            if ((Device.Type.ROADM.equals(device.type()))) {
+            if ((Device.Type.ROADM.equals(device.type())) ||
+                (Device.Type.OTN.equals(device.type()))) {
                 Port port = getPort(deviceId, portDescription.portNumber());
                 portDescription = OpticalPortOperator.descriptionOf(port, portDescription.isEnabled());
             }
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 8f60149..ca720e2 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
@@ -23,6 +23,7 @@
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.OchPort;
+import org.onosproject.net.OtuPort;
 import org.onosproject.net.OduCltPort;
 import org.onosproject.net.OmsPort;
 import org.onosproject.net.Port;
@@ -32,6 +33,7 @@
 import org.onosproject.net.device.OchPortDescription;
 import org.onosproject.net.device.OduCltPortDescription;
 import org.onosproject.net.device.OmsPortDescription;
+import org.onosproject.net.device.OtuPortDescription;
 import org.onosproject.net.device.PortDescription;
 import org.slf4j.Logger;
 
@@ -115,6 +117,9 @@
             case COPPER:
                 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);
             default:
                 log.warn("Unsupported optical port type {} - can't update", descr.type());
                 return descr;
@@ -183,6 +188,9 @@
             case ODUCLT:
                 OduCltPort odu = (OduCltPort) port;
                 return new OduCltPortDescription(ptn, isup, odu.signalType(), an);
+            case OTU:
+                OtuPort otu = (OtuPort) port;
+                return new OtuPortDescription(ptn, isup, otu.signalType(), an);
             default:
                 return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
         }
diff --git a/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java b/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
index 138283c..54e7a4a 100644
--- a/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
@@ -34,11 +34,13 @@
 import static org.junit.Assert.assertEquals;
 import static org.onosproject.net.Device.Type.ROADM;
 import static org.onosproject.net.Device.Type.SWITCH;
+import static org.onosproject.net.Device.Type.OTN;
 
 public class BasicDeviceOperatorTest {
 
     private static final String NAME1 = "of:foo";
     private static final String NAME2 = "of:bar";
+    private static final String NAME3 = "of:otn";
     private static final String OWNER = "somebody";
     private static final URI DURI = URI.create(NAME1);
     private static final String MFR = "whitebox";
@@ -64,6 +66,7 @@
 
     private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig();
     private static final BasicDeviceConfig RD_BDC = new BasicDeviceConfig();
+    private static final BasicDeviceConfig OT_BDC = new BasicDeviceConfig();
 
     @Before
     public void setUp() {
@@ -72,6 +75,8 @@
         RD_BDC.init(DeviceId.deviceId(NAME2), NAME2, JsonNodeFactory.instance.objectNode(), mapper, delegate);
         RD_BDC.type(ROADM).manufacturer(MANUFACTURER).hwVersion(HW_VERSION)
                 .swVersion(SW_VERSION).serial(SERIAL).managementAddress(MANAGEMENT_ADDRESS).driver(DRIVER).owner(OWNER);
+        OT_BDC.init(DeviceId.deviceId(NAME3), NAME3, JsonNodeFactory.instance.objectNode(), mapper, delegate);
+        OT_BDC.type(OTN);
     }
 
     @Test
@@ -92,5 +97,9 @@
         assertEquals("Wrong serial", SERIAL, desc.serialNumber());
         assertEquals("Wrong management Address", MANAGEMENT_ADDRESS,
                      desc.annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS));
+
+        // override Device type
+        desc = BasicDeviceOperator.combine(OT_BDC, DEV1);
+        assertEquals(OTN, desc.type());
     }
 }