use of org.onosproject.net.TributarySlot 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.TributarySlot 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.TributarySlot in project onos by opennetworkinglab.
the class OpticalOduIntentCompiler method findTributarySlots.
private Map<LinkKey, Set<TributarySlot>> findTributarySlots(OpticalOduIntent intent, Set<LinkKey> links) {
OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
int requestedTsNum = oduSignalType.tributarySlots();
Map<LinkKey, Set<TributarySlot>> slotsMap = new HashMap<>();
for (LinkKey link : links) {
Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
if (common.isEmpty() || (common.size() < requestedTsNum)) {
log.debug("Failed to find TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
// failed to find enough available TributarySlots on a link
return Collections.emptyMap();
}
slotsMap.put(link, common.stream().limit(requestedTsNum).collect(Collectors.toSet()));
}
return slotsMap;
}
use of org.onosproject.net.TributarySlot in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method availableSlotResources.
private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);
int requestedTsNum = oduSignalType.tributarySlots();
Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst);
if (commonTributarySlots.isEmpty()) {
return Collections.emptyList();
}
if (commonTributarySlots.size() < requestedTsNum) {
return Collections.emptyList();
}
Set<TributarySlot> tributarySlots = commonTributarySlots.stream().limit(requestedTsNum).collect(Collectors.toSet());
final List<ConnectPoint> portsList = ImmutableList.of(src, dst);
List<Resource> tributarySlotResources = portsList.stream().flatMap(cp -> tributarySlots.stream().map(ts -> Resources.discrete(cp.deviceId(), cp.port()).resource().child(ts))).collect(Collectors.toList());
if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
log.debug("Resource allocation for {} on {} and {} failed (resource request: {})", signalType, src, dst, tributarySlotResources);
return Collections.emptyList();
}
return tributarySlotResources;
}
use of org.onosproject.net.TributarySlot in project onos by opennetworkinglab.
the class OpticalOduIntentCompilerTest method test1GbeMultiplexOverOdu2.
/**
* Tests compile of OpticalOduIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_1GBE), over OTU ports (with OTU2):
* - only one TributarySlot is used
*/
@Test
public void test1GbeMultiplexOverOdu2() {
intent = OpticalOduIntent.builder().appId(APP_ID).key(KEY1).src(d1p1).dst(d3p2).signalType(D1P1.signalType()).bidirectional(false).build();
sut.activate();
List<Intent> compiled = sut.compile(intent, Collections.emptyList());
assertThat(compiled, hasSize(1));
assertThat("key is inherited", compiled.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
// 1st Device
FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
selectorBuilder1.matchInPort(d1p1.port());
selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
assertThat(rule1.selector(), is(selectorBuilder1.build()));
// validate SRC treatment (with OduSignalId, where 1 TributarySlot is used)
TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
Set<TributarySlot> slots = new HashSet<>();
slots.add(TributarySlot.of(1));
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(OduSignalType.ODU2, slots);
treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
treatmentBuilder1.setOutput(d1p2.port());
assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
// 2nd Device
FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
selectorBuilder2.matchInPort(d2p1.port());
selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate SRC treatment (with OduSignalId, where 1 TributarySlot is used)
TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
treatmentBuilder2.add(Instructions.modL1OduSignalId(oduSignalId));
treatmentBuilder2.setOutput(d2p2.port());
assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
// 3rd Device
FlowRule rule3 = rules.stream().filter(x -> x.deviceId().equals(device3.id())).findFirst().get();
// validate DST selector (with OduSignalId, where the same TributarySlot is used)
TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
selectorBuilder3.matchInPort(d3p1.port());
selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
selectorBuilder3.add(Criteria.matchOduSignalId(oduSignalId));
assertThat(rule3.selector(), is(selectorBuilder3.build()));
// validate DST treatment
assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p2.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
Aggregations