use of org.onosproject.net.optical.OtuPort in project onos by opennetworkinglab.
the class OpticalOduIntentCompiler method createRules.
/**
* Create rules for the forward (or the reverse) path of the intent.
*
* @param intent OpticalOduIntent intent
* @param path path found for intent
* @param slotsMap Map of LinkKey and TributarySlots resources
* @return list of flow rules
*/
private List<FlowRule> createRules(OpticalOduIntent intent, ConnectPoint src, ConnectPoint dst, Path path, Map<LinkKey, Set<TributarySlot>> slotsMap, boolean reverse) {
// Build the ingress OTN rule
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
selector.matchInPort(src.port());
OduSignalType oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
List<FlowRule> rules = new LinkedList<>();
ConnectPoint current = src;
List<Link> links = ((!reverse) ? path.links() : Lists.reverse(path.links()));
for (Link link : links) {
Set<TributarySlot> slots = slotsMap.get(linkKey(link));
OtuPort otuPort = (OtuPort) (deviceService.getPort(link.src().deviceId(), link.src().port()));
OduSignalType otuPortOduSignalType = OduSignalUtils.mappingOtuSignalTypeToOduSignalType(otuPort.signalType());
TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
OduSignalId oduSignalId = null;
// use Instruction of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != otuPortOduSignalType) {
oduSignalId = OduSignalUtils.buildOduSignalId(otuPortOduSignalType, slots);
treat.add(Instructions.modL1OduSignalId(oduSignalId));
}
ConnectPoint next = ((!reverse) ? link.src() : link.dst());
treat.setOutput(next.port());
FlowRule rule = createFlowRule(intent, current.deviceId(), selector.build(), treat.build());
rules.add(rule);
current = ((!reverse) ? link.dst() : link.src());
selector = DefaultTrafficSelector.builder();
selector.matchInPort(current.port());
selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
// use Criteria of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != otuPortOduSignalType) {
selector.add(Criteria.matchOduSignalId(oduSignalId));
}
}
// Build the egress OTN rule
TrafficTreatment.Builder treatLast = DefaultTrafficTreatment.builder();
treatLast.setOutput(dst.port());
FlowRule rule = createFlowRule(intent, dst.deviceId(), selector.build(), treatLast.build());
rules.add(rule);
return rules;
}
use of org.onosproject.net.optical.OtuPort 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;
}
}
}
use of org.onosproject.net.optical.OtuPort in project onos by opennetworkinglab.
the class OtuPortHelper method asOtuPort.
public static Optional<OtuPort> asOtuPort(Port port) {
if (port instanceof OtuPort) {
return Optional.of((OtuPort) port);
}
try {
Annotations an = port.annotations();
OtuSignalType signalType = Enum.valueOf(OtuSignalType.class, an.value(SIGNAL_TYPE));
// DefaultOtuPort should filter them, if necessary.
return Optional.of(new DefaultOtuPort(port, signalType));
} catch (NullPointerException | IllegalArgumentException e) {
log.warn("{} was not well-formed Otu port.", port, e);
return Optional.empty();
}
}
Aggregations