Toru Furusawa
Committed by Yuta HIGUCHI

[ONOS-3730] Populate portSpeed for ODUCLT and OCH ports.

Also move the enum definition of ODU client port signal type outside of OduCltPort class.

Change-Id: Ibdff21d9707ad3d79587f579ad675f673cf9afeb
......@@ -26,6 +26,7 @@ import org.onosproject.cluster.NodeId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.mastership.MastershipService;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Device;
import org.onosproject.net.Host;
......@@ -290,7 +291,7 @@ public class OpticalPathProvisioner {
.appId(appId)
.src(src)
.dst(dst)
.signalType(OduCltPort.SignalType.CLT_10GBE)
.signalType(CltSignalType.CLT_10GBE)
.bidirectional(true)
.build();
intents.add(circuitIntent);
......
......@@ -18,6 +18,7 @@ package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.OchPort;
import org.onosproject.net.OduCltPort;
......@@ -102,7 +103,7 @@ public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
.key(key())
.src(ingress)
.dst(egress)
.signalType(OduCltPort.SignalType.CLT_10GBE)
.signalType(CltSignalType.CLT_10GBE)
.bidirectional(bidirectional)
.build();
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
......
/*
* Copyright 2016 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;
/**
* Represents ODU (Optical channel Data Unit) client port signal type.
*
* <p>
* See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and
* Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
* </p>
*/
public enum CltSignalType {
/** bit rate in Mbps. */
CLT_1GBE(1_000),
CLT_10GBE(10_000),
CLT_40GBE(40_000),
CLT_100GBE(100_000);
private final long bitRate;
CltSignalType(long bitRate) {
this.bitRate = bitRate;
}
/**
* Return the bit rate in Mbps of the port.
* @return bit rate
*/
public long bitRate() {
return this.bitRate;
}
}
\ No newline at end of file
......@@ -44,8 +44,8 @@ public class OchPort extends DefaultPort {
*/
public OchPort(Element element, PortNumber number, boolean isEnabled, OduSignalType signalType,
boolean isTunable, OchSignal lambda, Annotations... annotations) {
super(element, number, isEnabled, Type.OCH, 0, annotations);
this.signalType = checkNotNull(signalType);
super(element, number, isEnabled, Type.OCH, checkNotNull(signalType).bitRate(), annotations);
this.signalType = signalType;
this.isTunable = isTunable;
this.lambda = checkNotNull(lambda);
}
......
......@@ -28,15 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class OduCltPort extends DefaultPort {
public enum SignalType {
CLT_1GBE,
CLT_10GBE,
CLT_40GBE,
CLT_100GBE
}
private final SignalType signalType;
private final CltSignalType signalType;
/**
* Creates an ODU client port in the specified network element.
......@@ -48,9 +40,9 @@ public class OduCltPort extends DefaultPort {
* @param annotations optional key/value annotations
*/
public OduCltPort(Element element, PortNumber number, boolean isEnabled,
SignalType signalType, Annotations... annotations) {
super(element, number, isEnabled, Type.ODUCLT, 0, annotations);
this.signalType = checkNotNull(signalType);
CltSignalType signalType, Annotations... annotations) {
super(element, number, isEnabled, Type.ODUCLT, checkNotNull(signalType).bitRate(), annotations);
this.signalType = signalType;
}
/**
......@@ -58,7 +50,7 @@ public class OduCltPort extends DefaultPort {
*
* @return ODU client signal type
*/
public SignalType signalType() {
public CltSignalType signalType() {
return signalType;
}
......
......@@ -24,10 +24,25 @@ package org.onosproject.net;
* </p>
*/
public enum OduSignalType {
ODU0,
ODU1,
ODU2,
ODU2e,
ODU3,
ODU4
/** bit rate in Mbps. */
ODU0(1_250),
ODU1(2_500),
ODU2(10_000),
ODU2e(10_000),
ODU3(40_000),
ODU4(100_000);
private final long bitRate;
OduSignalType(long bitRate) {
this.bitRate = bitRate;
}
/**
* Return the bit rate in Mbps of the port.
* @return bit rate
*/
public long bitRate() {
return this.bitRate;
}
}
......
......@@ -16,7 +16,7 @@
package org.onosproject.net.device;
import com.google.common.base.MoreObjects;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
......@@ -26,7 +26,7 @@ import org.onosproject.net.SparseAnnotations;
*/
public class OduCltPortDescription extends DefaultPortDescription {
private final OduCltPort.SignalType signalType;
private final CltSignalType signalType;
/**
* Creates ODU client port description based on the supplied information.
......@@ -36,7 +36,7 @@ public class OduCltPortDescription extends DefaultPortDescription {
* @param signalType ODU client signal type
* @param annotations optional key/value annotations map
*/
public OduCltPortDescription(PortNumber number, boolean isEnabled, OduCltPort.SignalType signalType,
public OduCltPortDescription(PortNumber number, boolean isEnabled, CltSignalType signalType,
SparseAnnotations... annotations) {
super(number, isEnabled, Port.Type.ODUCLT, 0, annotations);
this.signalType = signalType;
......@@ -49,7 +49,7 @@ public class OduCltPortDescription extends DefaultPortDescription {
* @param signalType ODU client signal type
* @param annotations optional key/value annotations map
*/
public OduCltPortDescription(PortDescription base, OduCltPort.SignalType signalType,
public OduCltPortDescription(PortDescription base, CltSignalType signalType,
SparseAnnotations annotations) {
super(base, annotations);
this.signalType = signalType;
......@@ -60,7 +60,7 @@ public class OduCltPortDescription extends DefaultPortDescription {
*
* @return ODU client signal type
*/
public OduCltPort.SignalType signalType() {
public CltSignalType signalType() {
return signalType;
}
......
......@@ -18,8 +18,8 @@ package org.onosproject.net.intent;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.OduCltPort;
import java.util.Collections;
......@@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public class OpticalCircuitIntent extends Intent {
private final ConnectPoint src;
private final ConnectPoint dst;
private final OduCltPort.SignalType signalType;
private final CltSignalType signalType;
private final boolean isBidirectional;
/**
......@@ -49,7 +49,7 @@ public class OpticalCircuitIntent extends Intent {
* @param priority priority to use for flows from this intent
*/
protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
OduCltPort.SignalType signalType, boolean isBidirectional, int priority) {
CltSignalType signalType, boolean isBidirectional, int priority) {
super(appId, key, Collections.emptyList(), priority);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
......@@ -73,7 +73,7 @@ public class OpticalCircuitIntent extends Intent {
public static class Builder extends Intent.Builder {
private ConnectPoint src;
private ConnectPoint dst;
private OduCltPort.SignalType signalType;
private CltSignalType signalType;
private boolean isBidirectional;
@Override
......@@ -119,7 +119,7 @@ public class OpticalCircuitIntent extends Intent {
* @param signalType signal type to use for built intent
* @return this builder
*/
public Builder signalType(OduCltPort.SignalType signalType) {
public Builder signalType(CltSignalType signalType) {
this.signalType = signalType;
return this;
}
......@@ -188,7 +188,7 @@ public class OpticalCircuitIntent extends Intent {
*
* @return ODU signal type
*/
public OduCltPort.SignalType getSignalType() {
public CltSignalType getSignalType() {
return signalType;
}
......
......@@ -17,6 +17,7 @@ package org.onosproject.net.device.impl;
import org.junit.Before;
import org.junit.Test;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.basics.OpticalPortConfig;
......@@ -24,7 +25,6 @@ import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.OduCltPort;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
......@@ -50,9 +50,9 @@ public class OpticalPortOperatorTest {
.build();
private static final OduCltPortDescription N_DESC = new OduCltPortDescription(
NAMED, true, OduCltPort.SignalType.CLT_100GBE, SA);
NAMED, true, CltSignalType.CLT_100GBE, SA);
private static final OduCltPortDescription FAULTY = new OduCltPortDescription(
null, true, OduCltPort.SignalType.CLT_100GBE);
null, true, CltSignalType.CLT_100GBE);
private final ConfigApplyDelegate delegate = new MockCfgDelegate();
private final ObjectMapper mapper = new ObjectMapper();
......
......@@ -49,6 +49,7 @@ import org.onosproject.incubator.net.domain.IntentDomainId;
import org.onosproject.mastership.MastershipTerm;
import org.onosproject.net.Annotations;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
......@@ -483,7 +484,7 @@ public final class KryoNamespaces {
.register(GridType.class)
.register(ChannelSpacing.class)
.register(OduCltPort.class)
.register(OduCltPort.SignalType.class)
.register(CltSignalType.class)
.register(IndexedLambda.class)
.register(OchSignal.class)
.register(OduSignalId.class)
......
......@@ -34,6 +34,7 @@ import org.onosproject.core.DefaultGroupId;
import org.onosproject.mastership.MastershipTerm;
import org.onosproject.net.Annotations;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultDevice;
......@@ -208,8 +209,8 @@ public class KryoSerializerTest {
@Test
public void testOduCltPort() {
testSerializedEquals(new OduCltPort(DEV1, P1, true, OduCltPort.SignalType.CLT_10GBE));
testSerializedEquals(new OduCltPort(DEV1, P1, true, OduCltPort.SignalType.CLT_10GBE, A1_2));
testSerializedEquals(new OduCltPort(DEV1, P1, true, CltSignalType.CLT_10GBE));
testSerializedEquals(new OduCltPort(DEV1, P1, true, CltSignalType.CLT_10GBE, A1_2));
}
@Test
......
......@@ -46,13 +46,13 @@ import org.onlab.util.Spectrum;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.ChannelSpacing;
import org.onosproject.net.CltSignalType;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
import org.onosproject.net.GridType;
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;
......@@ -537,20 +537,20 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) &&
!port.getConfig().contains(OFPortConfig.PORT_DOWN);
Long portSpeedInMbps = portSpeed(port);
OduCltPort.SignalType sigType = null;
CltSignalType sigType = null;
switch (portSpeedInMbps.toString()) {
case "1000":
sigType = OduCltPort.SignalType.CLT_1GBE;
sigType = CltSignalType.CLT_1GBE;
break;
case "10000":
sigType = OduCltPort.SignalType.CLT_10GBE;
sigType = CltSignalType.CLT_10GBE;
break;
case "40000":
sigType = OduCltPort.SignalType.CLT_40GBE;
sigType = CltSignalType.CLT_40GBE;
break;
case "100000":
sigType = OduCltPort.SignalType.CLT_100GBE;
sigType = CltSignalType.CLT_100GBE;
break;
default:
throw new RuntimeException("Un recognize OduClt speed: " + portSpeedInMbps.toString());
......