use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class CriterionJsonMatcher method matchCriterion.
/**
* Matches an ODU signal ID criterion object.
*
* @param criterion criterion to match
* @return true if the JSON matches the criterion, false otherwise.
*/
private boolean matchCriterion(OduSignalIdCriterion criterion) {
final OduSignalId oduSignal = criterion.oduSignalId();
final JsonNode jsonOduSignal = jsonCriterion.get(CriterionCodec.ODU_SIGNAL_ID);
int jsonTpn = jsonOduSignal.get(CriterionCodec.TRIBUTARY_PORT_NUMBER).intValue();
int jsonTsLen = jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_LEN).intValue();
byte[] jsonTributaryBitMap = HexString.fromHexString(jsonOduSignal.get(CriterionCodec.TRIBUTARY_SLOT_BITMAP).asText());
OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, jsonTributaryBitMap);
if (!oduSignal.equals(jsonOduSignalId)) {
description.appendText("oduSignalId was " + criterion);
return false;
}
return true;
}
use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class InstructionCodecTest method modOduSignalIdInstructionTest.
/**
* Tests the encoding of mod ODU signal ID instructions.
*/
@Test
public void modOduSignalIdInstructionTest() {
OduSignalId oduSignalId = OduSignalId.oduSignalId(1, 8, new byte[] { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
L1ModificationInstruction.ModOduSignalIdInstruction instruction = (L1ModificationInstruction.ModOduSignalIdInstruction) Instructions.modL1OduSignalId(oduSignalId);
ObjectNode instructionJson = instructionCodec.encode(instruction, context);
assertThat(instructionJson, matchesInstruction(instruction));
}
use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompilerTest method test1GbeMultiplexOverOdu2.
/**
* Tests compile of OpticalCircuitIntent with allocation of TributarySlots.
* Compile two ODUCLT ports (with CLT_1GBE), over OCH ports (with ODU2):
* - only one TributarySlot is used
*/
@Test
public void test1GbeMultiplexOverOdu2() {
// Use driver with TributarySlotQuery Behaviour
sut.driverService = new MockDriverServiceWithTs();
ConnectPoint oduCltSrcCP = new ConnectPoint(device1.id(), D1P1.number());
ConnectPoint oduCltDstCP = new ConnectPoint(device2.id(), D2P1.number());
ConnectPoint ochSrcCP = new ConnectPoint(device1.id(), D1P2.number());
ConnectPoint ochDstCP = new ConnectPoint(device2.id(), D2P2.number());
intent = OpticalCircuitIntent.builder().appId(APP_ID).key(KEY1).src(oduCltSrcCP).dst(oduCltDstCP).signalType(D1P1.signalType()).bidirectional(false).build();
sut.activate(null);
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();
FlowRule rule1 = rules.stream().filter(x -> x.deviceId().equals(device1.id())).findFirst().get();
// validate SRC selector
TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
selectorBuilder1.matchInPort(oduCltSrcCP.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(D1P2.signalType(), slots);
treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
treatmentBuilder1.setOutput(ochSrcCP.port());
assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
FlowRule rule2 = rules.stream().filter(x -> x.deviceId().equals(device2.id())).findFirst().get();
// validate DST selector (with OduSignalId, where the same TributarySlot is used)
TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
selectorBuilder2.matchInPort(ochDstCP.port());
selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
assertThat(rule2.selector(), is(selectorBuilder2.build()));
// validate DST treatment
assertThat(rule2.treatment(), is(DefaultTrafficTreatment.builder().setOutput(oduCltDstCP.port()).build()));
rules.forEach(rule -> assertEquals("FlowRule priority is incorrect", intent.priority(), rule.priority()));
sut.deactivate();
}
use of org.onosproject.net.OduSignalId 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