use of org.onosproject.net.optical.OduCltPort 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.OduCltPort in project onos by opennetworkinglab.
the class OduCltPortHelper method asOduCltPort.
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));
// 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();
}
}
use of org.onosproject.net.optical.OduCltPort in project onos by opennetworkinglab.
the class OpticalOduIntentCompiler method compile.
@Override
public List<Intent> compile(OpticalOduIntent intent, List<Intent> installable) {
// Check if ports are OduClt ports
ConnectPoint src = intent.getSrc();
ConnectPoint dst = intent.getDst();
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
checkArgument(srcPort instanceof OduCltPort);
checkArgument(dstPort instanceof OduCltPort);
log.debug("Compiling optical ODU intent between {} and {}", src, dst);
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
resourceService.release(intent.key());
// Check OduClt ports availability
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
// If ports are not available, compilation fails
if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
throw new OpticalIntentCompilationException("Ports for the intent are not available. Intent: " + intent);
}
List<Resource> intentResources = new ArrayList<>();
intentResources.add(srcPortResource);
intentResources.add(dstPortResource);
// Calculate available light paths
Set<Path> paths = getOpticalPaths(intent);
if (paths.isEmpty()) {
throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
}
// Use first path that can be successfully reserved
for (Path path : paths) {
// Find available Tributary Slots on both directions of path
Map<LinkKey, Set<TributarySlot>> slotsMap = findAvailableTributarySlots(intent, path);
if (slotsMap.isEmpty()) {
continue;
}
List<Resource> tributarySlotResources = convertToResources(slotsMap);
if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
continue;
}
intentResources.addAll(tributarySlotResources);
allocateResources(intent, intentResources);
List<FlowRule> rules = new LinkedList<>();
// Create rules for forward and reverse path
rules = createRules(intent, intent.getSrc(), intent.getDst(), path, slotsMap, false);
if (intent.isBidirectional()) {
rules.addAll(createRules(intent, intent.getDst(), intent.getSrc(), path, slotsMap, true));
}
return Collections.singletonList(new FlowRuleIntent(appId, intent.key(), rules, ImmutableSet.copyOf(path.links()), PathIntent.ProtectionType.PRIMARY, intent.resourceGroup()));
}
throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
}
use of org.onosproject.net.optical.OduCltPort in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method connectPorts.
/**
* Builds flow rule for mapping between two ports.
*
* @param src source port
* @param dst destination port
* @param priority
* @param slots Set of TributarySlots
* @return flow rules
*/
private FlowRule connectPorts(ConnectPoint src, ConnectPoint dst, int priority, Set<TributarySlot> slots) {
checkArgument(src.deviceId().equals(dst.deviceId()));
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
selectorBuilder.matchInPort(src.port());
if (!slots.isEmpty()) {
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
OduSignalType oduCltPortOduSignalType;
OduSignalType ochPortOduSignalType;
if (srcPort instanceof OduCltPort) {
oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType());
ochPortOduSignalType = ((OchPort) dstPort).signalType();
selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
// use Instruction of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != ochPortOduSignalType) {
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId));
}
} else {
// srcPort is OchPort
oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType());
ochPortOduSignalType = ((OchPort) srcPort).signalType();
selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
// use Criteria of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != ochPortOduSignalType) {
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId));
}
}
}
treatmentBuilder.setOutput(dst.port());
FlowRule flowRule = DefaultFlowRule.builder().forDevice(src.deviceId()).withSelector(selectorBuilder.build()).withTreatment(treatmentBuilder.build()).withPriority(priority).fromApp(appId).makePermanent().build();
return flowRule;
}
use of org.onosproject.net.optical.OduCltPort in project onos by opennetworkinglab.
the class OpticalPortsListCommand method printPorts.
@Override
protected void printPorts(DeviceService service, Device device) {
List<Port> ports = new ArrayList<>(service.getPorts(device.id()));
ports.sort((p1, p2) -> Long.signum(p1.number().toLong() - p2.number().toLong()));
for (Port port : ports) {
if (!isIncluded(port)) {
continue;
}
String portName = port.number().toString();
String portIsEnabled = port.isEnabled() ? "enabled" : "disabled";
String portType = port.type().toString().toLowerCase();
switch(port.type()) {
case OCH:
if (port instanceof OchPort) {
OchPort och = (OchPort) port;
print(FMT_OCH, portName, portIsEnabled, portType, och.signalType().toString(), och.isTunable() ? "yes" : "no", annotations(och.unhandledAnnotations()));
break;
}
print("WARN: OchPort but not on OpticalDevice or ill-formed");
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
break;
case ODUCLT:
if (port instanceof OduCltPort) {
OduCltPort oduCltPort = (OduCltPort) port;
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, oduCltPort.signalType().toString(), annotations(oduCltPort.unhandledAnnotations()));
break;
}
print("WARN: OduCltPort but not on OpticalDevice or ill-formed");
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
break;
case OMS:
if (port instanceof OmsPort) {
OmsPort oms = (OmsPort) port;
print(FMT_OMS, portName, portIsEnabled, portType, oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(), oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), oms.grid().asHz() / Frequency.ofGHz(1).asHz(), oms.totalChannels(), annotations(oms.unhandledAnnotations()));
break;
}
print("WARN: OmsPort but not on OpticalDevice or ill-formed");
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
break;
case OTU:
if (port instanceof OtuPort) {
OtuPort otuPort = (OtuPort) port;
print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, otuPort.signalType().toString(), annotations(otuPort.unhandledAnnotations()));
break;
}
print("WARN: OtuPort but not on OpticalDevice or ill-formed");
print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
break;
default:
// do not print non-optical ports
break;
}
}
}
Aggregations