HIGUCHI Yuta
Committed by Yuta HIGUCHI

ONOS-4415 Remove OmsPort out of core.

Change-Id: Ic796c4e715789ba18f350f28e29db04dd537822f
Showing 21 changed files with 737 additions and 48 deletions
......@@ -26,12 +26,12 @@ import org.onlab.util.Frequency;
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 @@ public class DevicePortsListCommand extends DevicesListCommand {
((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,
......
......@@ -28,7 +28,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
* 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
......
......@@ -23,7 +23,10 @@ import org.onosproject.net.SparseAnnotations;
/**
* 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 @@ public class OmsPortDescription extends DefaultPortDescription {
* @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 @@ public class OmsPortDescription extends DefaultPortDescription {
* @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);
......
/*
* 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();
}
......@@ -28,8 +28,10 @@ import org.onosproject.net.device.DeviceService;
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 @@ public class DefaultOpticalDevice
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();
......
/*
* 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() {}
}
/*
* 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);
}
}
/*
* 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();
}
}
/*
* 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));
}
}
/*
* 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));
}
}
......@@ -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.AnnotationKeys;
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.OmsPortDescription;
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 @@ public final class OpticalPortOperator implements ConfigOperator {
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 @@ public final class OpticalPortOperator implements ConfigOperator {
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
......
......@@ -18,6 +18,7 @@ package org.onosproject.store.device.impl;
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 @@ class DeviceDescriptions {
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) {
......
......@@ -530,9 +530,15 @@ public class ECDeviceStore
// 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
......
......@@ -1088,9 +1088,15 @@ public class GossipDeviceStore
// 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
......
......@@ -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>
......
......@@ -17,12 +17,14 @@ package org.onosproject.driver.query;
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 @@ public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour imple
@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
......
......@@ -18,6 +18,8 @@ package org.onosproject.drivers.lumentum;
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 @@ import org.onosproject.net.driver.AbstractDriverLoader;
@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");
}
......
......@@ -27,7 +27,6 @@ import org.onosproject.net.device.DefaultDeviceDescription;
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.Collections;
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 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
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 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
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 @@ public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour imp
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,
......
......@@ -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>
......
......@@ -22,6 +22,7 @@ import static org.onosproject.net.DeviceId.deviceId;
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.DeviceProvider;
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 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
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 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
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 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
// 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);
}
......
......@@ -41,7 +41,6 @@ import org.onosproject.net.MastershipRole;
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.DeviceProviderRegistry;
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.LinkProvider;
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.PortNumber.portNumber;
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 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
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 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
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 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
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 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
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;
......