use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class OpticalPathProvisioner method createIntents.
/**
* Scans the list of cross connection points and returns a list of optical connectivity intents.
* During the process, save information about packet links to given set.
*
* @param crossConnectPoints list of (src, dst) pair between which optical path will be set up
* @return list of optical connectivity intents
*/
private List<Intent> createIntents(List<Pair<ConnectPoint, ConnectPoint>> crossConnectPoints) {
List<Intent> intents = new LinkedList<>();
Iterator<Pair<ConnectPoint, ConnectPoint>> itr = crossConnectPoints.iterator();
while (itr.hasNext()) {
// checkArgument at start ensures we'll always have pairs of connect points
Pair<ConnectPoint, ConnectPoint> next = itr.next();
ConnectPoint src = next.getLeft();
ConnectPoint dst = next.getRight();
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
OduCltPort srcOCPort = (OduCltPort) srcPort;
OduCltPort dstOCPort = (OduCltPort) dstPort;
if (!srcOCPort.signalType().equals(dstOCPort.signalType())) {
continue;
}
// Create OTN circuit
OpticalCircuitIntent circuitIntent = OpticalCircuitIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOCPort.signalType()).bidirectional(false).build();
intents.add(circuitIntent);
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
OchPort srcOchPort = (OchPort) srcPort;
OchPort dstOchPort = (OchPort) dstPort;
if (!srcOchPort.signalType().equals(dstOchPort.signalType())) {
continue;
}
// Create lightpath
OpticalConnectivityIntent opticalIntent = OpticalConnectivityIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOchPort.signalType()).bidirectional(false).build();
intents.add(opticalIntent);
} else {
log.warn("Unsupported cross connect point types {} {}", srcPort.type(), dstPort.type());
return Collections.emptyList();
}
}
return intents;
}
use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class ServiceApplicationComponent method createOpticalIntent.
/**
* Returns a new optical intent created from the method parameters.
*
* @param ingress ingress description (device/port)
* @param egress egress description (device/port)
* @param key intent key
* @param appId application id. As per Intent class, it cannot be null
*
* @return created intent
*/
protected Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, Key key, ApplicationId appId) {
if (ingress == null || egress == null) {
log.error("Invalid endpoint(s) for optical intent: ingress {}, egress {}", ingress, egress);
return null;
}
DeviceService ds = opticalView(deviceService);
Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
Port dstPort = ds.getPort(egress.deviceId(), egress.port());
if (srcPort == null || dstPort == null) {
log.error("Invalid port(s) for optical intent: src {}, dst {}", srcPort, dstPort);
return null;
}
OduSignalType signalType = ((OchPort) srcPort).signalType();
return OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(// TODO Revisit this.
true).build();
}
use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class RoadmUtil method createOchSignalFromWavelength.
public static OchSignal createOchSignalFromWavelength(double wavelength, DeviceService deviceService, DeviceId deviceId, PortNumber portNumber) {
if (wavelength == 0L) {
return null;
}
Port port = deviceService.getPort(deviceId, portNumber);
Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
if (ochPortOpt.isPresent()) {
OchPort ochPort = ochPortOpt.get();
GridType gridType = ochPort.lambda().gridType();
ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
int slotGranularity = ochPort.lambda().slotGranularity();
int multiplier = getMultiplier(wavelength, gridType, channelSpacing);
return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
} else {
return null;
}
}
use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class PortWaveLengthCommand method createOchSignalFromWavelength.
private OchSignal createOchSignalFromWavelength(DeviceService deviceService, ConnectPoint cp) {
long wavelength = Long.parseLong(parameter);
if (wavelength == 0L) {
return null;
}
Port port = deviceService.getPort(cp);
Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
if (ochPortOpt.isPresent()) {
OchPort ochPort = ochPortOpt.get();
GridType gridType = ochPort.lambda().gridType();
ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
int slotGranularity = ochPort.lambda().slotGranularity();
int multiplier = getMultplier(wavelength, gridType, channelSpacing);
return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
} else {
print("[ERROR] connect point %s is not OChPort", cp);
return null;
}
}
use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class OchPortHelper method asOchPort.
public static Optional<OchPort> asOchPort(Port port) {
if (port instanceof OchPort) {
return Optional.of((OchPort) port);
}
try {
Annotations an = port.annotations();
OduSignalType signalType = Enum.valueOf(OduSignalType.class, an.value(SIGNAL_TYPE));
boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
OchSignal lambda = OchSignalCodec.decode(obj);
// DefaultOchPort should filter them, if necessary.
return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
// TODO: it'll be better to verify each inputs properly
// instead of catching all these Exceptions.
} catch (IOException | NullPointerException | IllegalArgumentException | ClassCastException e) {
log.warn("{} was not well-formed OCh port.", port, e);
return Optional.empty();
}
}
Aggregations