ONOS-4415 Remove OmsPort out of core.
Change-Id: Ic796c4e715789ba18f350f28e29db04dd537822f
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 e8413f2..99e8e11 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
@@ -26,12 +26,12 @@
import org.onosproject.utils.Comparators;
import org.onosproject.net.Device;
import org.onosproject.net.OduCltPort;
-import org.onosproject.net.OmsPort;
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.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import java.util.ArrayList;
import java.util.Collections;
@@ -191,11 +191,27 @@
((OduCltPort) port).signalType().toString(), annotations);
break;
case OMS:
- print(FMT_OMS, portName, portIsEnabled, portType,
- ((OmsPort) port).minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).grid().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).totalChannels(), annotations);
+ if (port instanceof org.onosproject.net.OmsPort) {
+ org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
+ print("WARN: OmsPort in old model");
+ print(FMT_OMS, portName, portIsEnabled, portType,
+ oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.grid().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.totalChannels(), annotations);
+ break;
+ }
+ if (port instanceof OmsPort) {
+ OmsPort oms = (OmsPort) port;
+ print(FMT_OMS, portName, portIsEnabled, portType,
+ oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.grid().asHz() / Frequency.ofGHz(1).asHz(),
+ oms.totalChannels(), annotations);
+ break;
+ }
+ print("WARN: OmsPort but not on OpticalDevice or ill-formed");
+ print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
case OTU:
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
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
diff --git a/drivers/default/pom.xml b/drivers/default/pom.xml
index 844289a..73afd90 100644
--- a/drivers/default/pom.xml
+++ b/drivers/default/pom.xml
@@ -55,13 +55,6 @@
<extensions>true</extensions>
<configuration>
<niceManifest>true</niceManifest>
- <instructions>
- <!-- TODO this can be removed once optical package
- has been separated out from the default drivers -->
- <Import-Package>
- *,org.onosproject.net.optical.device
- </Import-Package>
- </instructions>
</configuration>
</plugin>
</plugins>
diff --git a/drivers/default/src/main/java/org/onosproject/driver/query/OFOpticalSwitch13LambdaQuery.java b/drivers/default/src/main/java/org/onosproject/driver/query/OFOpticalSwitch13LambdaQuery.java
index 5c61583..63756a8 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/query/OFOpticalSwitch13LambdaQuery.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/query/OFOpticalSwitch13LambdaQuery.java
@@ -17,12 +17,14 @@
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.OchSignal;
-import org.onosproject.net.OmsPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.LambdaQuery;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.optical.OmsPort;
+
+import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
import java.util.Collections;
import java.util.Set;
@@ -46,7 +48,7 @@
@Override
public Set<OchSignal> queryLambdas(PortNumber port) {
- DeviceService deviceService = this.handler().get(DeviceService.class);
+ DeviceService deviceService = opticalView(this.handler().get(DeviceService.class));
Port p = deviceService.getPort(this.data().deviceId(), port);
// Only OMS ports expose lambda resources
diff --git a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumDriversLoader.java b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumDriversLoader.java
index 76386cf..4b708c7 100644
--- a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumDriversLoader.java
+++ b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumDriversLoader.java
@@ -18,6 +18,8 @@
import org.apache.felix.scr.annotations.Component;
import org.onosproject.net.driver.AbstractDriverLoader;
+import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.device.DefaultOpticalDevice;
/**
* Loader for Lumentum device drivers from specific xml.
@@ -25,6 +27,12 @@
@Component(immediate = true)
public class LumentumDriversLoader extends AbstractDriverLoader {
+ // OSGI: help bundle plugin discover runtime package dependency.
+ @SuppressWarnings("unused")
+ private OpticalDevice optical;
+ @SuppressWarnings("unused")
+ private DefaultOpticalDevice driver;
+
public LumentumDriversLoader() {
super("/lumentum-drivers.xml");
}
diff --git a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
index 1e7a3af..0bf9b13 100644
--- a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
+++ b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
@@ -27,7 +27,6 @@
import org.onosproject.net.device.DeviceDescription;
import org.onosproject.net.device.DeviceDescriptionDiscovery;
import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.slf4j.Logger;
@@ -40,6 +39,7 @@
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -97,7 +97,7 @@
SparseAnnotations ann = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber)
.build();
- PortDescription p = new OmsPortDescription(
+ PortDescription p = omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
@@ -115,7 +115,7 @@
SparseAnnotations annLineIn = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE IN")
.build();
- ports.add(new OmsPortDescription(
+ ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
@@ -127,7 +127,7 @@
SparseAnnotations annLineOut = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, "LINE OUT")
.build();
- ports.add(new OmsPortDescription(
+ ports.add(omsPortDescription(
PortNumber.portNumber(ports.size() + 1),
true,
LumentumSnmpDevice.START_CENTER_FREQ,
diff --git a/drivers/lumentum/src/main/resources/lumentum-drivers.xml b/drivers/lumentum/src/main/resources/lumentum-drivers.xml
index ecdbc3f..e22b85a 100644
--- a/drivers/lumentum/src/main/resources/lumentum-drivers.xml
+++ b/drivers/lumentum/src/main/resources/lumentum-drivers.xml
@@ -24,6 +24,8 @@
impl="org.onosproject.drivers.lumentum.LumentumFlowRuleProgrammable"/>
<behaviour api="org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer"
impl="org.onosproject.drivers.lumentum.LumentumAlarmConsumer"/>
+ <behaviour api="org.onosproject.net.optical.OpticalDevice"
+ impl="org.onosproject.net.optical.device.DefaultOpticalDevice"/>
</driver>
</drivers>
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 d92d540..b2748ef 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.OmsPortHelper.omsPortDescription;
import static org.onosproject.openflow.controller.Dpid.dpid;
import static org.onosproject.openflow.controller.Dpid.uri;
import static org.slf4j.LoggerFactory.getLogger;
@@ -67,7 +68,6 @@
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
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.onosproject.net.device.PortStatistics;
@@ -582,7 +582,7 @@
PortDescription portDes = null;
switch (sigType) {
case OMSN:
- portDes = new OmsPortDescription(portNo, enabled,
+ portDes = omsPortDescription(portNo, enabled,
FREQ191_7, FREQ191_7.add(FREQ4_4), FREQ50, annotations);
break;
case OCH:
@@ -703,7 +703,7 @@
case 2: // OMS port
// Assume complete optical spectrum and 50 GHz grid
// LINC-OE is only supported optical OF device for now
- return new OmsPortDescription(portNo, enabled,
+ return omsPortDescription(portNo, enabled,
Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
case 5: // OCH port
OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
@@ -742,7 +742,7 @@
// S160 data sheet
// Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch
- return new OmsPortDescription(portNo, enabled,
+ return omsPortDescription(portNo, enabled,
Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(100), annotations);
}
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 46e546f..fa00969 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
@@ -41,7 +41,6 @@
import org.onosproject.net.OchSignal;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalType;
-import org.onosproject.net.OmsPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
@@ -55,7 +54,6 @@
import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.device.OduCltPortDescription;
-import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.host.DefaultHostDescription;
import org.onosproject.net.host.HostProvider;
@@ -66,6 +64,7 @@
import org.onosproject.net.link.LinkProviderRegistry;
import org.onosproject.net.link.LinkProviderService;
import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -88,6 +87,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.OmsPortHelper.omsPortDescription;
import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
/**
@@ -259,7 +259,7 @@
case FIBER:
// Currently, assume OMS when FIBER. Provide sane defaults.
annotations = annotations(node.get("annotations"));
- return new OmsPortDescription(port, node.path("enabled").asBoolean(true),
+ return omsPortDescription(port, node.path("enabled").asBoolean(true),
Spectrum.CENTER_FREQUENCY, Spectrum.CENTER_FREQUENCY.add(TOTAL),
Frequency.ofGHz(100), annotations);
case ODUCLT:
@@ -276,7 +276,7 @@
case OMS:
annotations = annotations(node.get("annotations"));
OmsPort omsPort = (OmsPort) deviceService.getPort(deviceId, port);
- return new OmsPortDescription(port, node.path("enabled").asBoolean(true),
+ return omsPortDescription(port, node.path("enabled").asBoolean(true),
omsPort.minFrequency(), omsPort.maxFrequency(), omsPort.grid(), annotations);
default:
log.warn("{}: Unsupported Port Type");
@@ -398,8 +398,8 @@
Frequency min = Spectrum.CENTER_FREQUENCY.add(grid);
Frequency max = Spectrum.CENTER_FREQUENCY.add(grid.multiply(numChls));
- PortDescription srcPortDesc = new OmsPortDescription(srcCp.port(), true, min, max, grid);
- PortDescription dstPortDesc = new OmsPortDescription(dstCp.port(), true, min, max, grid);
+ PortDescription srcPortDesc = omsPortDescription(srcCp.port(), true, min, max, grid);
+ PortDescription dstPortDesc = omsPortDescription(dstCp.port(), true, min, max, grid);
descriptions.put(srcCp, srcPortDesc);
descriptions.put(dstCp, dstPortDesc);
deviceProviderService.portStatusChanged(srcCp.deviceId(), srcPortDesc);
@@ -479,7 +479,7 @@
switch (p.type()) {
case OMS:
OmsPort op = (OmsPort) p;
- return new OmsPortDescription(
+ return omsPortDescription(
op.number(), op.isEnabled(), op.minFrequency(), op.maxFrequency(), op.grid());
case OCH:
OchPort ochp = (OchPort) p;