Ayaka Koshibe
Committed by Gerrit Code Review

Misc device/optical config features:

o devices and optical ports are updated with network configs
o refactored AllowedEntity checks in DeviceManager
o "basic" -> "optical" for OpticalPort config key
o Device and OpticalPort operators can create descriptions

Change-Id: I59edc368f3a8ff931954b174d4a898f6b4add5d5
......@@ -84,7 +84,7 @@ public class BasicNetworkConfigs {
},
new ConfigFactory<ConnectPoint, OpticalPortConfig>(CONNECT_POINT_SUBJECT_FACTORY,
OpticalPortConfig.class,
"basic") {
"optical") {
@Override
public OpticalPortConfig createConfig() {
return new OpticalPortConfig();
......
......@@ -16,6 +16,7 @@
package org.onosproject.net.device.impl;
import static org.slf4j.LoggerFactory.getLogger;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.net.config.ConfigOperator;
import org.onosproject.net.config.basics.BasicDeviceConfig;
......@@ -93,4 +94,12 @@ public final class BasicDeviceOperator implements ConfigOperator {
DefaultAnnotations newAnnotations = newBuilder.build();
return DefaultAnnotations.union(an, newAnnotations);
}
public static DeviceDescription descriptionOf(Device device) {
checkNotNull(device, "Must supply non-null Device");
return new DefaultDeviceDescription(device.id().uri(), device.type(),
device.manufacturer(), device.hwVersion(),
device.swVersion(), device.serialNumber(),
device.chassisId(), (SparseAnnotations) device.annotations());
}
}
......
......@@ -16,11 +16,16 @@
package org.onosproject.net.device.impl;
import static org.slf4j.LoggerFactory.getLogger;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.net.config.ConfigOperator;
import org.onosproject.net.config.basics.OpticalPortConfig;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.OchPort;
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;
import org.onosproject.net.device.DefaultPortDescription;
......@@ -137,4 +142,32 @@ public final class OpticalPortOperator implements ConfigOperator {
}
return DefaultAnnotations.union(an, b.build());
}
/**
* Returns a description built from an existing port.
*
* @param port the device port
* @return a PortDescription based on the port
*/
public static PortDescription descriptionOf(Port port) {
checkNotNull(port, "Must supply non-null Port");
final PortNumber ptn = port.number();
final boolean isup = port.isEnabled();
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);
case OCH:
OchPort och = (OchPort) port;
return new OchPortDescription(ptn, isup, och.signalType(),
och.isTunable(), och.lambda(), an);
case ODUCLT:
OduCltPort odu = (OduCltPort) port;
return new OduCltPortDescription(ptn, isup, odu.signalType(), an);
default:
return new DefaultPortDescription(ptn, isup, port.type(), port.portSpeed(), an);
}
}
}
......