use of org.onosproject.net.OduSignalId 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.OduSignalId 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;
}
use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class CriteriaTest method testMatchOduSignalIdMethod.
/**
* Test the OduSignalId method.
*/
@Test
public void testMatchOduSignalIdMethod() {
OduSignalId odu = oduSignalId(1, 80, new byte[] { 2, 1, 1, 3, 1, 1, 3, 1, 1, 3 });
Criterion matchoduSignalId = Criteria.matchOduSignalId(odu);
OduSignalIdCriterion oduSignalIdCriterion = checkAndConvert(matchoduSignalId, Criterion.Type.ODU_SIGID, OduSignalIdCriterion.class);
assertThat(oduSignalIdCriterion.oduSignalId(), is(equalTo(odu)));
}
use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class EncodeInstructionCodecHelper method encodeL1.
/**
* Encode an L1 modification instruction.
*
* @param result json node that the instruction attributes are added to
*/
private void encodeL1(ObjectNode result) {
L1ModificationInstruction l1Instruction = (L1ModificationInstruction) instruction;
result.put(InstructionCodec.SUBTYPE, l1Instruction.subtype().name());
switch(l1Instruction.subtype()) {
case ODU_SIGID:
final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction = (L1ModificationInstruction.ModOduSignalIdInstruction) l1Instruction;
OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId();
ObjectNode child = result.putObject("oduSignalId");
child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP, HexString.toHexString(oduSignalId.tributarySlotBitmap()));
break;
default:
log.info("Cannot convert L1 subtype of {}", l1Instruction.subtype());
break;
}
}
use of org.onosproject.net.OduSignalId in project onos by opennetworkinglab.
the class InstructionJsonMatcher method matchModOduSingalIdInstruction.
/**
* Matches the contents of a mod ODU singal Id instruction.
*
* @param instructionJson JSON instruction to match
* @param description Description object used for recording errors
* @return true if contents matches, false otherwise
*/
private boolean matchModOduSingalIdInstruction(JsonNode instructionJson, Description description) {
ModOduSignalIdInstruction instructionToMatch = (ModOduSignalIdInstruction) instruction;
String jsonSubType = instructionJson.get("subtype").textValue();
if (!instructionToMatch.subtype().name().equals(jsonSubType)) {
description.appendText("subtype was " + jsonSubType);
return false;
}
String jsonType = instructionJson.get("type").textValue();
if (!instructionToMatch.type().name().equals(jsonType)) {
description.appendText("type was " + jsonType);
return false;
}
final JsonNode jsonOduSignal = instructionJson.get("oduSignalId");
int jsonTpn = jsonOduSignal.get("tributaryPortNumber").intValue();
int jsonTsLen = jsonOduSignal.get("tributarySlotLength").intValue();
byte[] tributaryBitMap = HexString.fromHexString(jsonOduSignal.get("tributarySlotBitmap").asText());
OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, tributaryBitMap);
if (!instructionToMatch.oduSignalId().equals(jsonOduSignalId)) {
description.appendText("oduSignalId was " + instructionToMatch);
return false;
}
return true;
}
Aggregations