use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class OpticalIntentUtility 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 deviceService device service
* @param key intent key
* @param appId application id
* @param bidirectional if this argument is true, the optical link created
* will be bidirectional, otherwise the link will be unidirectional.
* @param signal optical signal
* @param suggestedPath suggested path
*
* @return created intent
*/
public static Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, DeviceService deviceService, Key key, ApplicationId appId, boolean bidirectional, OchSignal signal, Path suggestedPath) {
Intent intent = null;
if (ingress == null || egress == null) {
log.debug("Invalid endpoint(s); could not create optical intent");
return intent;
}
DeviceService ds = opticalView(deviceService);
Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
Port dstPort = ds.getPort(egress.deviceId(), egress.port());
if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
Device srcDevice = ds.getDevice(ingress.deviceId());
Device dstDevice = ds.getDevice(egress.deviceId());
// continue only if both OduClt port's Devices are of the same type
if (!(srcDevice.type().equals(dstDevice.type()))) {
log.debug("Devices without same deviceType: SRC {} and DST={}", srcDevice.type(), dstDevice.type());
return intent;
}
CltSignalType signalType = ((OduCltPort) srcPort).signalType();
if (Type.ROADM.equals(srcDevice.type()) || Type.ROADM_OTN.equals(srcDevice.type()) || Type.OLS.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
intent = OpticalCircuitIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
} else if (Type.OTN.equals(srcDevice.type())) {
intent = OpticalOduIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).build();
} else {
log.debug("Wrong Device Type for connect points {} and {}", ingress, egress);
}
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
OduSignalType signalType = ((OchPort) srcPort).signalType();
intent = OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
} else {
log.debug("Unable to create optical intent between connect points {} and {}", ingress, egress);
}
return intent;
}
use of org.onosproject.net.optical.OchPort in project onos by opennetworkinglab.
the class OpticalIntentUtility method createExplicitOpticalIntent.
/**
* Returns a new optical intent created from the method parameters, strict suggestedPath is specified.
*
* @param ingress ingress description (device/port)
* @param egress egress description (device/port)
* @param deviceService device service
* @param key intent key
* @param appId application id
* @param bidirectional if this argument is true, the optical link created
* will be bidirectional, otherwise the link will be unidirectional.
* @param signal optical signal
* @param suggestedPath suggested path for the intent
*
* @return created intent
*/
public static Intent createExplicitOpticalIntent(ConnectPoint ingress, ConnectPoint egress, DeviceService deviceService, Key key, ApplicationId appId, boolean bidirectional, OchSignal signal, Path suggestedPath) {
Intent intent = null;
if (ingress == null || egress == null) {
log.error("Invalid endpoint(s); could not create optical intent");
return intent;
}
DeviceService ds = opticalView(deviceService);
Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
Port dstPort = ds.getPort(egress.deviceId(), egress.port());
if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
Device srcDevice = ds.getDevice(ingress.deviceId());
Device dstDevice = ds.getDevice(egress.deviceId());
// continue only if both OduClt port's Devices are of the same type
if (!(srcDevice.type().equals(dstDevice.type()))) {
log.debug("Devices without same deviceType: SRC={} and DST={}", srcDevice.type(), dstDevice.type());
return intent;
}
CltSignalType signalType = ((OduCltPort) srcPort).signalType();
if (Type.ROADM.equals(srcDevice.type()) || Type.ROADM_OTN.equals(srcDevice.type()) || Type.OLS.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
intent = OpticalCircuitIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
} else if (Type.OTN.equals(srcDevice.type())) {
intent = OpticalOduIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).build();
} else {
log.error("Wrong Device Type for connect points: " + "ingress {} of type {}; egress {} of type {}", ingress, srcDevice.type(), egress, dstDevice.type());
}
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
OduSignalType signalType = ((OchPort) srcPort).signalType();
intent = OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
} else {
log.error("Unable to create explicit optical intent between connect points {} and {}", ingress, egress);
}
return intent;
}
Aggregations