use of org.onosproject.net.intent.OpticalOduIntent 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();
}
use of org.onosproject.net.intent.OpticalOduIntent in project onos by opennetworkinglab.
the class OpticalOduIntentCompilerTest method test10GbeMultiplexOverOdu2.
/**
* Tests compile of OpticalOduIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_10GBE), over OTU ports (with OTU2):
* - All TributarySlots are used
*/
@Test
public void test10GbeMultiplexOverOdu2() {
intent = OpticalOduIntent.builder().appId(APP_ID).key(KEY1).src(d1p3).dst(d3p3).signalType(D1P3.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(d1p3.port());
selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
assertThat(rule1.selector(), is(selectorBuilder1.build()));
// validate SRC treatment (without OduSignalId - all TributarySlots are used)
TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
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.ODU2));
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate SRC treatment (without OduSignalId - all TributarySlots are used)
TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
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 (without OduSignalId - all TributarySlots are used)
TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
selectorBuilder3.matchInPort(d3p1.port());
selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
assertThat(rule3.selector(), is(selectorBuilder3.build()));
// validate DST treatment
assertThat(rule3.treatment(), is(DefaultTrafficTreatment.builder().setOutput(d3p3.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
use of org.onosproject.net.intent.OpticalOduIntent in project onos by opennetworkinglab.
the class IntentsListCommand method detailsFormat.
/**
* Returns detailed information text about a specific intent.
*
* @param intent to print
* @param state of intent
* @return detailed information or "" if {@code state} was null
*/
private StringBuilder detailsFormat(Intent intent, IntentState state) {
StringBuilder builder = new StringBuilder();
if (state == null) {
return builder;
}
if (!intent.resources().isEmpty()) {
builder.append('\n').append(format(RESOURCES, intent.resources()));
}
if (intent instanceof ConnectivityIntent) {
ConnectivityIntent ci = (ConnectivityIntent) intent;
if (!ci.selector().criteria().isEmpty()) {
builder.append('\n').append(format(COMMON_SELECTOR, formatSelector(ci.selector())));
}
if (!ci.treatment().allInstructions().isEmpty()) {
builder.append('\n').append(format(TREATMENT, ci.treatment().allInstructions()));
}
if (ci.constraints() != null && !ci.constraints().isEmpty()) {
builder.append('\n').append(format(CONSTRAINTS, ci.constraints()));
}
}
if (intent instanceof HostToHostIntent) {
HostToHostIntent pi = (HostToHostIntent) intent;
builder.append('\n').append(format(SRC + HOST, pi.one()));
builder.append('\n').append(format(DST + HOST, pi.two()));
} else if (intent instanceof PointToPointIntent) {
PointToPointIntent pi = (PointToPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof MultiPointToSinglePointIntent) {
MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent;
builder.append('\n').append(formatFilteredCps(pi.filteredIngressPoints(), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof SinglePointToMultiPointIntent) {
SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(pi.filteredEgressPoints(), EGRESS));
} else if (intent instanceof PathIntent) {
PathIntent pi = (PathIntent) intent;
builder.append(format("path=%s, cost=%f", pi.path().links(), pi.path().cost()));
} else if (intent instanceof LinkCollectionIntent) {
LinkCollectionIntent li = (LinkCollectionIntent) intent;
builder.append('\n').append(format("links=%s", li.links()));
builder.append('\n').append(format(CP, li.egressPoints()));
} else if (intent instanceof OpticalCircuitIntent) {
OpticalCircuitIntent ci = (OpticalCircuitIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
} else if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
builder.append('\n').append(format("ochSignal=%s", ci.ochSignal()));
} else if (intent instanceof OpticalOduIntent) {
OpticalOduIntent ci = (OpticalOduIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
}
List<Intent> installable = service.getInstallableIntents(intent.key()).stream().filter(i -> contentFilter.filter(i)).collect(Collectors.toList());
if (showInstallable && installable != null && !installable.isEmpty()) {
builder.append('\n').append(format(INSTALLABLE, installable));
}
return builder;
}
Aggregations