HIGUCHI Yuta
Committed by Yuta HIGUCHI

ONOS-4416 Remove OduCltPort out of core.

Change-Id: I04324a72e48af84afdbfa32b84c8e57f39411000
Showing 22 changed files with 455 additions and 52 deletions
......@@ -30,7 +30,6 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.Host;
import org.onosproject.net.Link;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Path;
import org.onosproject.net.Port;
......@@ -46,6 +45,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.PointToPointIntent;
import org.onosproject.net.optical.OchPort;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.PathService;
import org.onosproject.net.topology.TopologyEdge;
......
......@@ -21,7 +21,6 @@ import org.apache.karaf.shell.commands.Option;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.DeviceId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Port;
......@@ -32,6 +31,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.optical.OchPort;
import org.onosproject.net.optical.OduCltPort;
import java.util.List;
......
......@@ -25,12 +25,12 @@ import org.apache.karaf.shell.commands.Option;
import org.onlab.util.Frequency;
import org.onosproject.utils.Comparators;
import org.onosproject.net.Device;
import org.onosproject.net.OduCltPort;
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.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import java.util.ArrayList;
......@@ -187,9 +187,22 @@ public class DevicePortsListCommand extends DevicesListCommand {
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
case ODUCLT:
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
((OduCltPort) port).signalType().toString(), annotations);
break;
if (port instanceof org.onosproject.net.OduCltPort) {
// old OduCltPort model
org.onosproject.net.OduCltPort oPort = (org.onosproject.net.OduCltPort) port;
print("WARN: OduCltPort in old model");
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
oPort.signalType().toString(), annotations);
break;
}
if (port instanceof OduCltPort) {
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType,
((OduCltPort) port).signalType().toString(), annotations);
break;
}
print("WARN: OduCltPort but not on OpticalDevice or ill-formed");
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
break;
case OMS:
if (port instanceof org.onosproject.net.OmsPort) {
org.onosproject.net.OmsPort oms = (org.onosproject.net.OmsPort) port;
......
......@@ -24,8 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
* Implementation of ODU client port (Optical channel Data Unit).
* Also referred to as a T-port or wide band port.
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
*
* @deprecated in Goldeneye (1.6.0)
*/
@Deprecated
public class OduCltPort extends DefaultPort {
private final CltSignalType signalType;
......
......@@ -23,7 +23,10 @@ import org.onosproject.net.SparseAnnotations;
/**
* Default implementation of immutable ODU client port description.
*
* @deprecated in Goldeneye (1.6.0)
*/
@Deprecated
public class OduCltPortDescription extends DefaultPortDescription {
private final CltSignalType signalType;
......
/*
* 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.onosproject.net.CltSignalType;
import org.onosproject.net.Port;
import com.google.common.annotations.Beta;
/**
* ODU client port (Optical channel Data Unit).
* Also referred to as a T-port or wide band port.
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
*/
@Beta
public interface OduCltPort extends Port {
/**
* Returns ODU client signal type.
*
* @return ODU client signal type
*/
CltSignalType signalType();
}
......@@ -28,9 +28,11 @@ 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.OduCltPort;
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.OduCltPortMapper;
import org.onosproject.net.optical.device.port.OmsPortMapper;
import org.onosproject.net.optical.device.port.PortMapper;
import org.onosproject.net.optical.utils.ForwardingDevice;
......@@ -63,6 +65,7 @@ public class DefaultOpticalDevice
= ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
.put(OchPort.class, new OchPortMapper())
.put(OmsPort.class, new OmsPortMapper())
.put(OduCltPort.class, new OduCltPortMapper())
// 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.onosproject.net.Annotations;
import org.onosproject.net.CltSignalType;
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.OduCltPort;
import org.onosproject.net.optical.impl.DefaultOduCltPort;
import org.slf4j.Logger;
import com.google.common.annotations.Beta;
/**
* ODU client port related helpers.
*/
@Beta
public final class OduCltPortHelper {
private static final Logger log = getLogger(OduCltPortHelper.class);
// Annotation keys
/**
* {@link CltSignalType} as String.
*/
private static final String SIGNAL_TYPE = "signalType";
/**
* Creates ODU client port description based on the supplied information.
*
* @param number port number
* @param isEnabled port enabled state
* @param signalType ODU client signal type
*/
public static PortDescription oduCltPortDescription(PortNumber number,
boolean isEnabled,
CltSignalType signalType) {
return oduCltPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
}
/**
* Creates ODU client port description based on the supplied information.
*
* @param number port number
* @param isEnabled port enabled state
* @param signalType ODU client signal type
* @param annotations key/value annotations map
*/
public static PortDescription oduCltPortDescription(PortNumber number,
boolean isEnabled,
CltSignalType signalType,
SparseAnnotations annotations) {
Builder builder = DefaultAnnotations.builder();
builder.putAll(annotations);
builder.set(SIGNAL_TYPE, signalType.toString());
long portSpeed = signalType.bitRate();
return new DefaultPortDescription(number,
isEnabled,
Port.Type.ODUCLT,
portSpeed,
builder.build());
}
/**
* Creates ODU client port description based on the supplied information.
*
* @param base PortDescription to get basic information from
* @param signalType ODU client signal type
* @param annotations key/value annotations map
*/
public static PortDescription oduCltPortDescription(PortDescription base,
CltSignalType signalType,
SparseAnnotations annotations) {
return oduCltPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
}
public static Optional<OduCltPort> asOduCltPort(Port port) {
if (port instanceof OduCltPort) {
return Optional.of((OduCltPort) port);
}
try {
Annotations an = port.annotations();
CltSignalType signalType = Enum.valueOf(CltSignalType.class,
an.value(SIGNAL_TYPE));
// Note: ODU specific annotations is not filtered-out here.
// DefaultOduCltPort should filter them, if necessary.
return Optional.of(new DefaultOduCltPort(port, signalType));
} catch (NullPointerException | IllegalArgumentException e) {
log.warn("{} was not well-formed OduClt port.", port, e);
return Optional.empty();
}
}
// not meant to be instantiated
private OduCltPortHelper() {}
}
/*
* 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.OduCltPort;
import org.onosproject.net.optical.device.OduCltPortHelper;
import org.onosproject.net.optical.impl.DefaultOduCltPort;
import com.google.common.annotations.Beta;
/**
* {@link PortMapper} to handler {@link OduCltPort} translation.
*/
@Beta
public class OduCltPortMapper extends AbstractPortMapper<OduCltPort> {
@Override
public boolean is(Port port) {
return port != null &&
port.type() == Port.Type.ODUCLT &&
super.is(port);
}
@Override
public Optional<OduCltPort> as(Port port) {
if (port instanceof OduCltPort) {
return Optional.of((OduCltPort) port);
}
return super.as(port);
}
@Override
protected Optional<OduCltPort> mapPort(Port port) {
if (port instanceof OduCltPort) {
return Optional.of((OduCltPort) port);
} else if (port instanceof org.onosproject.net.OduCltPort) {
// TODO remove after deprecation of old OduCltPort is complete
// translate to new OduCltPort
org.onosproject.net.OduCltPort old = (org.onosproject.net.OduCltPort) port;
return Optional.of(new DefaultOduCltPort(old,
old.signalType()));
}
return OduCltPortHelper.asOduCltPort(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.onosproject.net.CltSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.utils.ForwardingPort;
import com.google.common.annotations.Beta;
/**
* Implementation of ODU client port (Optical channel Data Unit).
* Also referred to as a T-port or wide band port.
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
*/
@Beta
public class DefaultOduCltPort extends ForwardingPort implements OduCltPort {
private final CltSignalType signalType;
/**
* Creates an ODU client port.
*
* @param delegate Port
* @param signalType ODU client signal type
*/
public DefaultOduCltPort(Port delegate, CltSignalType signalType) {
super(delegate);
this.signalType = checkNotNull(signalType);
}
@Override
public Type type() {
return Type.ODUCLT;
}
@Override
public long portSpeed() {
return signalType().bitRate();
}
@Override
public CltSignalType signalType() {
return signalType;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(),
signalType());
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && getClass() == obj.getClass()) {
final DefaultOduCltPort that = (DefaultOduCltPort) obj;
return super.toEqualsBuilder(that)
.append(this.signalType(), that.signalType())
.isEquals();
}
return false;
}
@Override
public String toString() {
return super.toStringHelper()
.add("signalType", signalType())
.toString();
}
}
......@@ -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.OduCltPortHelper.oduCltPortDescription;
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.config.basics.OpticalPortConfig;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.OtuPort;
import org.onosproject.net.OduCltPort;
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.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.optical.OpticalDevice;
import org.slf4j.Logger;
......@@ -121,8 +122,12 @@ public final class OpticalPortOperator implements ConfigOperator {
}
return descr;
case ODUCLT:
OduCltPortDescription odu = (OduCltPortDescription) descr;
return new OduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa);
if (descr instanceof OduCltPortDescription) {
// TODO This block can go away once deprecation is complete.
OduCltPortDescription odu = (OduCltPortDescription) descr;
return oduCltPortDescription(port, odu.isEnabled(), odu.signalType(), sa);
}
return descr;
case PACKET:
case FIBER:
case COPPER:
......@@ -223,8 +228,19 @@ public final class OpticalPortOperator implements ConfigOperator {
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
case ODUCLT:
OduCltPort odu = (OduCltPort) port;
return new OduCltPortDescription(ptn, isup, odu.signalType(), an);
if (port instanceof org.onosproject.net.OduCltPort) {
// remove if-block once deprecation is complete
org.onosproject.net.OduCltPort odu = (org.onosproject.net.OduCltPort) port;
return oduCltPortDescription(ptn, isup, odu.signalType(), an);
}
if (port.element().is(OpticalDevice.class)) {
OpticalDevice optDevice = port.element().as(OpticalDevice.class);
if (optDevice.portIs(port, OduCltPort.class)) {
OduCltPort odu = (OduCltPort) port;
return oduCltPortDescription(ptn, isup, odu.signalType(), an);
}
}
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
case OTU:
OtuPort otu = (OtuPort) port;
return new OtuPortDescription(ptn, isup, otu.signalType(), an);
......
......@@ -32,7 +32,6 @@ import org.onosproject.core.CoreService;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
......@@ -60,6 +59,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.intent.OpticalConnectivityIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
import org.onosproject.net.optical.OchPort;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.intent.IntentSetMultimap;
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.Resource;
......
......@@ -27,7 +27,6 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
......@@ -50,6 +49,7 @@ import org.onosproject.net.intent.IntentCompiler;
import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.intent.impl.IntentCompilationException;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.resource.Resource;
import org.onosproject.net.resource.ResourceService;
import org.onosproject.net.resource.ResourceAllocation;
......@@ -77,6 +77,7 @@ import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkArgument;
import static org.onosproject.net.LinkKey.linkKey;
import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
/**
* An intent compiler for {@link org.onosproject.net.intent.OpticalOduIntent}.
......@@ -105,6 +106,7 @@ public class OpticalOduIntentCompiler implements IntentCompiler<OpticalOduIntent
@Activate
public void activate() {
deviceService = opticalView(deviceService);
appId = coreService.registerApplication("org.onosproject.net.intent");
intentManager.registerCompiler(OpticalOduIntent.class, this);
}
......
......@@ -35,7 +35,6 @@ import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.OchSignal;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
......@@ -58,7 +57,9 @@ import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalCircuitIntent;
import org.onosproject.net.optical.OchPort;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.impl.DefaultOchPort;
import org.onosproject.net.optical.impl.DefaultOduCltPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.intent.IntentSetMultimap;
import org.onosproject.net.behaviour.TributarySlotQuery;
......@@ -124,9 +125,11 @@ public class OpticalCircuitIntentCompilerTest {
// OduClt ports with signalType=1GBE
private static final OduCltPort D1P1 =
new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(1), true, annotations1),
CltSignalType.CLT_1GBE);
private static final OduCltPort D2P1 =
new OduCltPort(device2, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device2, PortNumber.portNumber(1), true, annotations1),
CltSignalType.CLT_1GBE);
// Och ports with signalType=ODU2
private static final OchPort D1P2 =
......@@ -140,9 +143,11 @@ public class OpticalCircuitIntentCompilerTest {
// OduClt ports with signalType=10GBE
private static final OduCltPort D1P3 =
new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(3), true, annotations1),
CltSignalType.CLT_10GBE);
private static final OduCltPort D2P3 =
new OduCltPort(device2, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device2, PortNumber.portNumber(3), true, annotations1),
CltSignalType.CLT_10GBE);
private OpticalCircuitIntent intent;
......
......@@ -23,6 +23,7 @@ import org.onosproject.TestApplicationId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.IdGenerator;
import org.onosproject.net.AbstractProjectableModel;
import org.onosproject.net.Annotations;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.CltSignalType;
......@@ -30,10 +31,10 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultDevice;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.DefaultPort;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalId;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.OduSignalUtils;
......@@ -56,11 +57,15 @@ import org.onosproject.net.intent.IntentExtensionService;
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.MockIdGenerator;
import org.onosproject.net.intent.OpticalOduIntent;
import org.onosproject.net.optical.OduCltPort;
import org.onosproject.net.optical.impl.DefaultOduCltPort;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
import org.onosproject.net.topology.TopologyServiceAdapter;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.driver.DriverService;
import org.onosproject.net.driver.DriverServiceAdapter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
......@@ -116,9 +121,11 @@ public class OpticalOduIntentCompilerTest {
// OduClt ports with signalType=1GBE
private static final OduCltPort D1P1 =
new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(1), true, annotations1),
CltSignalType.CLT_1GBE);
private static final OduCltPort D3P2 =
new OduCltPort(device3, PortNumber.portNumber(2), true, CltSignalType.CLT_1GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device3, PortNumber.portNumber(2), true, annotations1),
CltSignalType.CLT_1GBE);
// Otu ports with signalType=ODU2
private static final OtuPort D1P2 =
......@@ -132,9 +139,11 @@ public class OpticalOduIntentCompilerTest {
// OduClt ports with signalType=10GBE
private static final OduCltPort D1P3 =
new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device1, PortNumber.portNumber(3), true, annotations1),
CltSignalType.CLT_10GBE);
private static final OduCltPort D3P3 =
new OduCltPort(device3, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
new DefaultOduCltPort(new DefaultPort(device3, PortNumber.portNumber(3), true, annotations1),
CltSignalType.CLT_10GBE);
// OduCltPort ConnectPoints
private final ConnectPoint d1p1 = new ConnectPoint(device1.id(), D1P1.number());
......@@ -204,11 +213,11 @@ public class OpticalOduIntentCompilerTest {
if (deviceId.equals(deviceId(DEV1))) {
switch (portNumber.toString()) {
case "1":
return (Port) D1P1;
return D1P1;
case "2":
return (Port) D1P2;
return D1P2;
case "3":
return (Port) D1P3;
return D1P3;
default:
return null;
}
......@@ -216,9 +225,9 @@ public class OpticalOduIntentCompilerTest {
if (deviceId.equals(deviceId(DEV2))) {
switch (portNumber.toString()) {
case "1":
return (Port) D2P1;
return D2P1;
case "2":
return (Port) D2P2;
return D2P2;
default:
return null;
}
......@@ -226,11 +235,11 @@ public class OpticalOduIntentCompilerTest {
if (deviceId.equals(deviceId(DEV3))) {
switch (portNumber.toString()) {
case "1":
return (Port) D3P1;
return D3P1;
case "2":
return (Port) D3P2;
return D3P2;
case "3":
return (Port) D3P3;
return D3P3;
default:
return null;
}
......@@ -239,8 +248,15 @@ public class OpticalOduIntentCompilerTest {
}
}
private static class MockDriverService extends DriverServiceAdapter
implements DriverService {
// TODO override to return appropriate driver,
// with DefaultOpticalDevice support, etc.
}
@Before
public void setUp() {
AbstractProjectableModel.setDriverService(null, new MockDriverService());
sut = new OpticalOduIntentCompiler();
coreService = createMock(CoreService.class);
expect(coreService.registerApplication("org.onosproject.net.intent"))
......
......@@ -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.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import java.util.Collections;
......@@ -140,11 +141,20 @@ class DeviceDescriptions {
}
break;
case ODUCLT:
OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
newOne = new Timestamped<>(
new OduCltPortDescription(
ocDesc, ocDesc.signalType(), merged),
newDesc.timestamp());
if (newDesc.value() instanceof OduCltPortDescription) {
// remove if-block after deprecation is complete
OduCltPortDescription ocDesc = (OduCltPortDescription) (newDesc.value());
newOne = new Timestamped<>(
oduCltPortDescription(ocDesc,
ocDesc.signalType(),
merged),
newDesc.timestamp());
} else {
// same as default case
newOne = new Timestamped<>(
new DefaultPortDescription(newDesc.value(), merged),
newDesc.timestamp());
}
break;
case OTU:
OtuPortDescription otuDesc = (OtuPortDescription) (newDesc.value());
......
......@@ -549,8 +549,14 @@ public class ECDeviceStore
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
case ODUCLT:
OduCltPortDescription oduDesc = (OduCltPortDescription) description;
return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
if (description instanceof OduCltPortDescription) {
// remove if-block once deprecation is complete
OduCltPortDescription oduDesc = (OduCltPortDescription) description;
return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
}
// same as default
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
default:
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
......
......@@ -1107,8 +1107,14 @@ public class GossipDeviceStore
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
case ODUCLT:
OduCltPortDescription oduDesc = (OduCltPortDescription) description;
return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
if (description instanceof OduCltPortDescription) {
// remove if-block once deprecation is complete
OduCltPortDescription oduDesc = (OduCltPortDescription) description;
return new OduCltPort(device, number, isEnabled, oduDesc.signalType(), annotations);
}
// same as default
return new DefaultPort(device, number, isEnabled, description.type(),
description.portSpeed(), annotations);
case OTU:
OtuPortDescription otuDesc = (OtuPortDescription) description;
return new OtuPort(device, number, isEnabled, otuDesc.signalType(), annotations);
......
......@@ -27,7 +27,6 @@ import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.PortDiscovery;
import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
import org.onosproject.net.driver.DriverHandler;
......@@ -37,6 +36,7 @@ import java.util.ArrayList;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
/**
* Discovers the ports from a Ciena WaveServer Rest device.
......@@ -114,7 +114,7 @@ public class PortDiscoveryCienaWaveserverImpl extends AbstractHandlerBehaviour
sub.getString(SPEED).replace(GBPS, EMPTY_STRING)
.replace(" ", EMPTY_STRING))) == speed100GbpsinMbps ?
CltSignalType.CLT_100GBE : null;
ports.add(new OduCltPortDescription(PortNumber.portNumber(sub.getLong(PORT_ID)),
ports.add(oduCltPortDescription(PortNumber.portNumber(sub.getLong(PORT_ID)),
sub.getString(ADMIN_STATE).equals(ENABLED),
cltType, annotations.build()));
}
......
......@@ -32,12 +32,12 @@ import org.onosproject.net.OduSignalType;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.PortDescription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.onosproject.net.optical.device.OchPortHelper.ochPortDescription;
import static org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription;
import java.io.InputStream;
import java.io.StringWriter;
......@@ -119,7 +119,7 @@ public final class XmlConfigParser {
return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations);
}
private static OduCltPortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
PortNumber portNumber = PortNumber.portNumber(count);
HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
boolean enabled = ethernetConfig.getString("administrative-state").equals("up");
......@@ -129,7 +129,7 @@ public final class XmlConfigParser {
DefaultAnnotations annotations = DefaultAnnotations.builder().
set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
build();
return new OduCltPortDescription(portNumber, enabled, signalType, annotations);
return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
protected static String parseSwitchId(HierarchicalConfiguration cfg) {
......
......@@ -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.OduCltPortHelper.oduCltPortDescription;
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;
......@@ -67,7 +68,6 @@ import org.onosproject.net.device.DeviceDescription;
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.OtuPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.device.PortStatistics;
......@@ -523,7 +523,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
}
SparseAnnotations annotations = buildOduCltAnnotation(port);
return new OduCltPortDescription(portNo, enabled, sigType, annotations);
return oduCltPortDescription(portNo, enabled, sigType, annotations);
}
private SparseAnnotations buildOduCltAnnotation(OFPortDesc port) {
......
......@@ -39,7 +39,6 @@ import org.onosproject.net.HostLocation;
import org.onosproject.net.Link;
import org.onosproject.net.MastershipRole;
import org.onosproject.net.OchSignal;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.OduSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
......@@ -53,7 +52,6 @@ import org.onosproject.net.device.DeviceProvider;
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.PortDescription;
import org.onosproject.net.host.DefaultHostDescription;
import org.onosproject.net.host.HostProvider;
......@@ -64,6 +62,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.OduCltPort;
import org.onosproject.net.optical.OmsPort;
import org.onosproject.net.provider.ProviderId;
import org.slf4j.Logger;
......@@ -87,6 +86,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.OduCltPortHelper.oduCltPortDescription;
import static org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription;
import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
......@@ -265,7 +265,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
case ODUCLT:
annotations = annotations(node.get("annotations"));
OduCltPort oduCltPort = (OduCltPort) deviceService.getPort(deviceId, port);
return new OduCltPortDescription(port, node.path("enabled").asBoolean(true),
return oduCltPortDescription(port, node.path("enabled").asBoolean(true),
oduCltPort.signalType(), annotations);
case OCH:
annotations = annotations(node.get("annotations"));
......@@ -487,7 +487,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
ochp.number(), ochp.isEnabled(), ochp.signalType(), ochp.isTunable(), ochp.lambda());
case ODUCLT:
OduCltPort odup = (OduCltPort) p;
return new OduCltPortDescription(
return oduCltPortDescription(
odup.number(), odup.isEnabled(), odup.signalType());
default:
return new DefaultPortDescription(p.number(), p.isEnabled(), p.type(), p.portSpeed());
......