use of org.onosproject.net.OduSignalType 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.OduSignalType 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();
}
}
use of org.onosproject.net.OduSignalType in project onos by opennetworkinglab.
the class OpticalOduIntentCompiler method isAvailableTributarySlots.
private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
int requestedTsNum = oduSignalType.tributarySlots();
Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
if (common.isEmpty() || (common.size() < requestedTsNum)) {
log.debug("Not enough available TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
return false;
}
return true;
}
use of org.onosproject.net.OduSignalType 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.OduSignalType 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;
}
Aggregations