ONOS-4415 Remove OmsPort out of core.

Change-Id: Ic796c4e715789ba18f350f28e29db04dd537822f
diff --git a/core/api/src/main/java/org/onosproject/net/OmsPort.java b/core/api/src/main/java/org/onosproject/net/OmsPort.java
index 206a0c8..e1e54ca 100644
--- a/core/api/src/main/java/org/onosproject/net/OmsPort.java
+++ b/core/api/src/main/java/org/onosproject/net/OmsPort.java
@@ -28,7 +28,10 @@
  * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
  *
  * Assumes we only support fixed grid for now.
+ *
+ * @deprecated in Goldeneye (1.6.0)
  */
+@Deprecated
 public class OmsPort extends DefaultPort {
 
     private final Frequency minFrequency;     // Minimum frequency
diff --git a/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java b/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java
index 74c040f..4d88476 100644
--- a/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/OmsPortDescription.java
@@ -23,7 +23,10 @@
 
 /**
  * Default implementation of immutable OMS port description.
+ *
+ * @deprecated in Goldeneye (1.6.0)
  */
+@Deprecated
 public class OmsPortDescription extends DefaultPortDescription {
 
     private final Frequency minFrequency;
@@ -39,7 +42,10 @@
      * @param maxFrequency  maximum frequency
      * @param grid          grid spacing frequency
      * @param annotations   optional key/value annotations map
+     *
+     * @deprecated in Goldeneye (1.6.0)
      */
+    @Deprecated
     public OmsPortDescription(PortNumber number, boolean isEnabled, Frequency minFrequency, Frequency maxFrequency,
                               Frequency grid, SparseAnnotations... annotations) {
         super(number, isEnabled, Port.Type.OMS, 0, annotations);
@@ -56,7 +62,10 @@
      * @param maxFrequency  maximum frequency
      * @param grid          grid spacing frequency
      * @param annotations   optional key/value annotations map
+     *
+     * @deprecated in Goldeneye (1.6.0)
      */
+    @Deprecated
     public OmsPortDescription(PortDescription base, Frequency minFrequency, Frequency maxFrequency,
                               Frequency grid, SparseAnnotations annotations) {
         super(base, annotations);
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OmsPort.java b/core/api/src/main/java/org/onosproject/net/optical/OmsPort.java
new file mode 100644
index 0000000..a08ab5f
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/OmsPort.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;
+
+import org.onlab.util.Frequency;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OMS port (Optical Multiplexing Section).
+ * Also referred to as a WDM port or W-port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * Assumes we only support fixed grid for now.
+ */
+@Beta
+public interface OmsPort extends Port {
+
+    /**
+     * Returns the total number of channels on the port.
+     *
+     * @return total number of channels
+     */
+    default short totalChannels() {
+        Frequency diff = maxFrequency().subtract(minFrequency());
+        return (short) (diff.asHz() / grid().asHz());
+    }
+
+    /**
+     * Returns the minimum frequency.
+     *
+     * @return minimum frequency
+     */
+    Frequency minFrequency();
+
+    /**
+     * Returns the maximum frequency.
+     *
+     * @return maximum frequency
+     */
+    Frequency maxFrequency();
+
+    /**
+     * Returns the grid spacing frequency.
+     *
+     * @return grid spacing frequency
+     */
+    Frequency grid();
+
+}
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 5a30cf7..0b4ff68 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,8 +28,10 @@
 import org.onosproject.net.driver.AbstractBehaviour;
 import org.onosproject.net.driver.DriverData;
 import org.onosproject.net.optical.OchPort;
+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.OmsPortMapper;
 import org.onosproject.net.optical.device.port.PortMapper;
 import org.onosproject.net.optical.utils.ForwardingDevice;
 import org.slf4j.Logger;
@@ -60,6 +62,7 @@
     private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS
         = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
             .put(OchPort.class, new OchPortMapper())
+            .put(OmsPort.class, new OmsPortMapper())
             // TODO add other optical port type here
             .build();
 
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
new file mode 100644
index 0000000..2c99c53
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
@@ -0,0 +1,147 @@
+/*
+ * 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.onlab.util.Frequency;
+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.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.optical.impl.DefaultOmsPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OMS port related helpers.
+ */
+@Beta
+public final class OmsPortHelper {
+
+    private static final Logger log = getLogger(OmsPortHelper.class);
+
+    // Annotation keys
+    /**
+     * minFrequency in Hz.
+     */
+    private static final String MIN_FREQ_HZ = "minFrequency";
+    /**
+     * maxFrequency in Hz.
+     */
+    private static final String MAX_FREQ_HZ = "maxFrequency";
+    /**
+     * grid in Hz.
+     */
+    private static final String GRID_HZ = "grid";
+
+    /**
+     * Creates OMS port description based on the supplied information.
+     *
+     * @param number        port number
+     * @param isEnabled     port enabled state
+     * @param minFrequency  minimum frequency
+     * @param maxFrequency  maximum frequency
+     * @param grid          grid spacing frequency
+     * @param annotations   key/value annotations map
+     */
+    public static PortDescription omsPortDescription(PortNumber number,
+                                              boolean isEnabled,
+                                              Frequency minFrequency,
+                                              Frequency maxFrequency,
+                                              Frequency grid,
+                                              SparseAnnotations annotations) {
+
+        Builder builder = DefaultAnnotations.builder();
+        builder.putAll(annotations);
+
+        builder.set(MIN_FREQ_HZ, String.valueOf(minFrequency.asHz()));
+        builder.set(MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz()));
+        builder.set(GRID_HZ, String.valueOf(grid.asHz()));
+
+        long portSpeed = 0;
+        return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build());
+    }
+
+    /**
+     * Creates OMS port description based on the supplied information.
+     *
+     * @param number        port number
+     * @param isEnabled     port enabled state
+     * @param minFrequency  minimum frequency
+     * @param maxFrequency  maximum frequency
+     * @param grid          grid spacing frequency
+     */
+    public static PortDescription omsPortDescription(PortNumber number,
+                                              boolean isEnabled,
+                                              Frequency minFrequency,
+                                              Frequency maxFrequency,
+                                              Frequency grid) {
+        return omsPortDescription(number, isEnabled, minFrequency, maxFrequency, grid, DefaultAnnotations.EMPTY);
+    }
+
+    /**
+     * Creates OMS port description based on the supplied information.
+     *
+     * @param base          PortDescription to get basic information from
+     * @param minFrequency  minimum frequency
+     * @param maxFrequency  maximum frequency
+     * @param grid          grid spacing frequency
+     * @param annotations   key/value annotations map
+     */
+    public static PortDescription omsPortDescription(PortDescription base,
+                                              Frequency minFrequency,
+                                              Frequency maxFrequency,
+                                              Frequency grid,
+                                              SparseAnnotations annotations) {
+
+        return omsPortDescription(base.portNumber(), base.isEnabled(),
+                                  minFrequency, maxFrequency, grid,
+                                  annotations);
+    }
+
+    public static Optional<OmsPort> asOmsPort(Port port) {
+        if (port instanceof OmsPort) {
+            return Optional.of((OmsPort) port);
+        }
+
+        try {
+            Annotations an = port.annotations();
+
+            Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(MIN_FREQ_HZ)));
+            Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(MAX_FREQ_HZ)));
+            Frequency grid = Frequency.ofHz(Long.parseLong(an.value(GRID_HZ)));
+
+            return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
+
+        } catch (NumberFormatException e) {
+
+            log.warn("{} was not well-formed OMS port.", port, e);
+            return Optional.empty();
+        }
+    }
+
+    // not meant to be instantiated
+    private OmsPortHelper() {}
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
new file mode 100644
index 0000000..70a8aa9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
@@ -0,0 +1,66 @@
+/*
+ * 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.OmsPort;
+import org.onosproject.net.optical.device.OmsPortHelper;
+import org.onosproject.net.optical.impl.DefaultOmsPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OmsPort} translation.
+ */
+@Beta
+public class OmsPortMapper extends AbstractPortMapper<OmsPort> {
+
+    @Override
+    public boolean is(Port port) {
+        return port != null &&
+               port.type() == Port.Type.OMS &&
+               super.is(port);
+    }
+
+    @Override
+    public Optional<OmsPort> as(Port port) {
+        if (port instanceof OmsPort) {
+            return Optional.of((OmsPort) port);
+        }
+        return super.as(port);
+    }
+
+    @Override
+    protected Optional<OmsPort> mapPort(Port port) {
+        if (port instanceof OmsPort) {
+            return Optional.of((OmsPort) port);
+        } else if (port instanceof org.onosproject.net.OmsPort) {
+            // TODO remove after deprecation of old OmsPort is complete
+
+            // translate to new OmsPort
+            org.onosproject.net.OmsPort old = (org.onosproject.net.OmsPort) port;
+            return Optional.of(new DefaultOmsPort(old,
+                                                  old.minFrequency(),
+                                                  old.maxFrequency(),
+                                                  old.grid()));
+        }
+
+        return OmsPortHelper.asOmsPort(port);
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
new file mode 100644
index 0000000..4c1c7e3
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
@@ -0,0 +1,118 @@
+/*
+ * 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.onlab.util.Frequency;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.optical.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of OMS port (Optical Multiplexing Section).
+ * Also referred to as a WDM port or W-port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * Assumes we only support fixed grid for now.
+ */
+@Beta
+public class DefaultOmsPort extends ForwardingPort implements OmsPort {
+
+    private final Frequency minFrequency;     // Minimum frequency
+    private final Frequency maxFrequency;     // Maximum frequency
+    private final Frequency grid;             // Grid spacing frequency
+
+    /**
+     * Creates an OMS port.
+     *
+     * @param delegate      Port
+     * @param minFrequency  minimum frequency
+     * @param maxFrequency  maximum frequency
+     * @param grid          grid spacing frequency
+     */
+    public DefaultOmsPort(Port delegate, Frequency minFrequency, Frequency maxFrequency, Frequency grid) {
+        super(delegate);
+
+        this.minFrequency = checkNotNull(minFrequency);
+        this.maxFrequency = checkNotNull(maxFrequency);
+        this.grid = checkNotNull(grid);
+    }
+
+    @Override
+    public Type type() {
+        return Type.OMS;
+    }
+
+    @Override
+    public long portSpeed() {
+        return 0;
+    }
+
+    @Override
+    public Frequency minFrequency() {
+        return minFrequency;
+    }
+
+    @Override
+    public Frequency maxFrequency() {
+        return maxFrequency;
+    }
+
+    @Override
+    public Frequency grid() {
+        return grid;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(),
+                            minFrequency(),
+                            maxFrequency(),
+                            grid());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj != null && getClass() == obj.getClass()) {
+            final DefaultOmsPort that = (DefaultOmsPort) obj;
+            return super.toEqualsBuilder(that)
+                    .append(this.minFrequency(), that.minFrequency())
+                    .append(this.maxFrequency(), that.maxFrequency())
+                    .append(this.grid(), that.grid())
+                    .isEquals();
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return super.toStringHelper()
+                .add("minFrequency", minFrequency())
+                .add("maxFrequency", maxFrequency())
+                .add("grid", grid())
+                .toString();
+    }
+
+}
diff --git a/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java b/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
new file mode 100644
index 0000000..c8c68f4
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.Optional;
+
+import org.junit.Test;
+import org.onlab.packet.ChassisId;
+import org.onlab.util.Frequency;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.provider.ProviderId;
+
+/**
+ * Tests for {@link OmsPortHelper}.
+ */
+public class OmsPortHelperTest {
+
+    private static final ProviderId PID = new ProviderId("test", "id");
+    private static final DeviceId DID = DeviceId.deviceId("test:00123");
+    private static final String MFC = "MFC";
+    private static final String HW = "HW V";
+    private static final String SW = "SW V";
+    private static final String SER = "SER";
+    private static final ChassisId CHS = new ChassisId(42);
+    private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
+    private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
+
+
+    @Test
+    public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
+        PortNumber pn = PortNumber.portNumber(4900);
+
+        boolean isEnabled = true;
+        String anKey = "Base";
+        String anValue = "value";
+        SparseAnnotations an = DefaultAnnotations.builder()
+                .set(anKey, anValue)
+                .build();
+
+        Frequency minF = Frequency.ofGHz(3);
+        Frequency maxF = Frequency.ofGHz(33);
+        Frequency grid = Frequency.ofGHz(2);
+
+        PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
+        Port port = new DefaultPort(DEV,
+                                    portDescription.portNumber(),
+                                    portDescription.isEnabled(),
+                                    portDescription.type(),
+                                    portDescription.portSpeed(),
+                                    portDescription.annotations());
+
+        Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
+        assertTrue(maybeOms.isPresent());
+
+        OmsPort oms = maybeOms.get();
+
+        assertThat(oms.isEnabled(), is(isEnabled));
+        assertThat(oms.number(), is(pn));
+        assertThat(oms.annotations().value(anKey), is(anValue));
+
+        assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
+        assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
+
+        assertThat(oms.maxFrequency(), is(maxF));
+        assertThat(oms.minFrequency(), is(minF));
+        assertThat(oms.grid(), is(grid));
+        assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15));
+    }
+
+}
diff --git a/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java b/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
new file mode 100644
index 0000000..4f32afc
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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 org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.onosproject.net.PortNumber.portNumber;
+
+import org.junit.Test;
+import org.onlab.packet.ChassisId;
+import org.onlab.util.Frequency;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.provider.ProviderId;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Tests for {@link DefaultOmsPort}.
+ */
+public class DefaultOmsPortTest {
+
+    private static final ProviderId PID = new ProviderId("test", "id");
+    private static final DeviceId DID = DeviceId.deviceId("test:00123");
+    private static final String MFC = "MFC";
+    private static final String HW = "HW V";
+    private static final String SW = "SW V";
+    private static final String SER = "SER";
+    private static final ChassisId CHS = new ChassisId(42);
+    private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
+    private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
+
+    @Test
+    public void testEquality() {
+        PortNumber pn = PortNumber.portNumber(4900);
+        Annotations an = DefaultAnnotations.builder()
+                .set("Base", "value")
+                .build();
+        Annotations an2 = DefaultAnnotations.builder()
+                .set("Base", "value2")
+                .build();
+
+        Port base = new DefaultPort(DEV, pn, true, Port.Type.VIRTUAL, 2, an);
+        Frequency minF = Frequency.ofGHz(3);
+        Frequency maxF = Frequency.ofGHz(33);
+        Frequency grid = Frequency.ofGHz(2);
+
+        // reference OMS port
+        OmsPort oms = new DefaultOmsPort(base, minF, maxF, grid);
+
+        new EqualsTester()
+          .addEqualityGroup(oms,
+                            // different base port type or portspeed is ignored
+                            new DefaultOmsPort(new DefaultPort(DEV, pn, true, an), minF, maxF, grid))
+          // different port number
+          .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, portNumber(1), true, an), minF, maxF, grid))
+          // different isEnabled
+          .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, false, an), minF, maxF, grid))
+          // different annotation
+          .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, true, an2), minF, maxF, grid))
+          // different minFreq
+          .addEqualityGroup(new DefaultOmsPort(base, Frequency.ofKHz(3), maxF, grid))
+          // different maxFreq
+          .addEqualityGroup(new DefaultOmsPort(base, minF, Frequency.ofKHz(33), grid))
+          // different grid
+          .addEqualityGroup(new DefaultOmsPort(base, minF, maxF, Frequency.ofKHz(2)))
+          .testEquals();
+
+    }
+
+    @Test
+    public void basicTests() {
+        PortNumber pn = PortNumber.portNumber(4900);
+        Annotations annotations = DefaultAnnotations.builder()
+                                .set("Base", "value")
+                                .build();
+
+        boolean isEnabled = true;
+        Port base = new DefaultPort(DEV, pn, isEnabled, Port.Type.VIRTUAL, 2, annotations);
+        Frequency minFrequency = Frequency.ofGHz(3);
+        Frequency maxFrequency = Frequency.ofGHz(33);
+        Frequency grid = Frequency.ofGHz(2);
+        OmsPort oms = new DefaultOmsPort(base, minFrequency, maxFrequency, grid);
+
+        // basic attributes and annotations are inherited from base
+        assertThat(oms.element(), is(DEV));
+        assertThat(oms.isEnabled(), is(isEnabled));
+        assertThat(oms.number(), is(pn));
+        assertThat(oms.annotations(), is(annotations));
+
+        assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
+        assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
+
+        assertThat(oms.maxFrequency(), is(maxFrequency));
+        assertThat(oms.minFrequency(), is(minFrequency));
+        assertThat(oms.grid(), is(grid));
+        assertThat("(33-3)/2 = 15", oms.totalChannels(), is((short) 15));
+    }
+
+}
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 fdd1f5d..14f6aeb 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.OmsPortHelper.omsPortDescription;
 import static org.slf4j.LoggerFactory.getLogger;
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -25,7 +26,6 @@
 import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.OtuPort;
 import org.onosproject.net.OduCltPort;
-import org.onosproject.net.OmsPort;
 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.OmsPort;
 import org.onosproject.net.optical.OpticalDevice;
 import org.slf4j.Logger;
 
@@ -103,9 +104,13 @@
             PortNumber port, SparseAnnotations sa, PortDescription descr) {
         switch (descr.type()) {
             case OMS:
-                OmsPortDescription oms = (OmsPortDescription) descr;
-                return new OmsPortDescription(port, oms.isEnabled(), oms.minFrequency(),
-                        oms.maxFrequency(), oms.grid(), sa);
+                if (descr instanceof OmsPortDescription) {
+                    // TODO This block can go away once deprecation is complete.
+                    OmsPortDescription oms = (OmsPortDescription) descr;
+                    return omsPortDescription(port, oms.isEnabled(), oms.minFrequency(),
+                                                  oms.maxFrequency(), oms.grid(), sa);
+                }
+                return descr;
             case OCH:
                 // We might need to update lambda below with STATIC_LAMBDA.
                 if (descr instanceof OchPortDescription) {
@@ -185,9 +190,21 @@
         final SparseAnnotations an = (SparseAnnotations) port.annotations();
         switch (port.type()) {
             case OMS:
-                OmsPort oms = (OmsPort) port;
-                return new OmsPortDescription(ptn, isup, oms.minFrequency(),
-                        oms.maxFrequency(), oms.grid(), an);
+                if (port instanceof org.onosproject.net.OmsPort) {
+                    // remove if-block once deprecation is complete
+                    org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
+                    return omsPortDescription(ptn, isup, oms.minFrequency(),
+                                              oms.maxFrequency(), oms.grid(), an);
+                }
+                if (port.element().is(OpticalDevice.class)) {
+                    OpticalDevice optDevice = port.element().as(OpticalDevice.class);
+                    if (optDevice.portIs(port, OmsPort.class)) {
+                        OmsPort oms = optDevice.portAs(port, OmsPort.class).get();
+                        return omsPortDescription(ptn, isup, oms.minFrequency(),
+                                                  oms.maxFrequency(), oms.grid(), an);
+                    }
+                }
+                return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
             case OCH:
                 if (port instanceof org.onosproject.net.OchPort) {
                     // remove if-block once old OchPort deprecation is complete
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 2eea2c2..ed3b44e 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.OmsPortHelper.omsPortDescription;
 
 import java.util.Collections;
 import java.util.Map;
@@ -105,11 +106,21 @@
             newOne = null;
             switch (newDesc.value().type()) {
                 case OMS:
-                    OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value());
-                    newOne = new Timestamped<>(
-                            new OmsPortDescription(
-                                    omsDesc, omsDesc.minFrequency(), omsDesc.maxFrequency(), omsDesc.grid(), merged),
-                            newDesc.timestamp());
+                    if (newDesc.value() instanceof OmsPortDescription) {
+                        // remove if-block after deprecation is complete
+                        OmsPortDescription omsDesc = (OmsPortDescription) (newDesc.value());
+                        newOne = new Timestamped<>(
+                                omsPortDescription(omsDesc,
+                                                   omsDesc.minFrequency(),
+                                                   omsDesc.maxFrequency(),
+                                                   omsDesc.grid(), merged),
+                                newDesc.timestamp());
+                    } else {
+                        // same as default case
+                        newOne = new Timestamped<>(
+                                new DefaultPortDescription(newDesc.value(), merged),
+                                newDesc.timestamp());
+                    }
                     break;
                 case OCH:
                     if (newDesc.value() instanceof OchPortDescription) {
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 480e973..fad232e 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
@@ -530,9 +530,15 @@
         // 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);
+            if (description instanceof OmsPortDescription) {
+                // remove if-block once deprecation is complete
+                OmsPortDescription omsDesc = (OmsPortDescription) description;
+                return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
+                        omsDesc.maxFrequency(), omsDesc.grid(), annotations);
+            }
+            // same as default
+            return new DefaultPort(device, number, isEnabled, description.type(),
+                                   description.portSpeed(), annotations);
         case OCH:
             if (description instanceof OchPortDescription) {
                 // remove if-block once Och deprecation is complete
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 d29b72a..e6d645f 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
@@ -1088,9 +1088,15 @@
         // 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);
+                if (description instanceof OmsPortDescription) {
+                    // remove if-block once deprecation is complete
+                    OmsPortDescription omsDesc = (OmsPortDescription) description;
+                    return new OmsPort(device, number, isEnabled, omsDesc.minFrequency(),
+                            omsDesc.maxFrequency(), omsDesc.grid(), annotations);
+                }
+                // same as default
+                return new DefaultPort(device, number, isEnabled, description.type(),
+                                       description.portSpeed(), annotations);
             case OCH:
                 if (description instanceof OchPortDescription) {
                     // remove if-block once Och deprecation is complete