use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects in project onos by opennetworkinglab.
the class PolatisFlowRuleProgrammable method editConnection.
private boolean editConnection(FlowRule rule, String mode) {
CrossConnects crossConnects = PolatisOpticalUtility.fromFlowRule(this, rule);
final StringBuilder cfg = new StringBuilder(xmlOpen(KEY_CONNS_XMLNS));
List<Pair> pairs = crossConnects.pair();
final String keyPairCompat = parseKeyPairCompat(this);
final String keyPairMode = String.format("%s operation=\"%s\"", keyPairCompat, mode);
pairs.forEach(p -> {
cfg.append(xmlOpen(keyPairMode)).append(xmlOpen(KEY_SRC)).append(p.ingress()).append(xmlClose(KEY_SRC)).append(xmlOpen(KEY_DST)).append(p.egress()).append(xmlClose(KEY_DST)).append(xmlClose(keyPairCompat));
});
cfg.append(xmlClose(KEY_CONNS));
return netconfEditConfig(handler(), null, cfg.toString());
}
use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects in project onos by opennetworkinglab.
the class PolatisOpticalUtility method toFlowRule.
/**
* Finds the FlowRule from flow rule store by the given cross connect information.
* Returns an extra flow to remove the flow by ONOS if not found.
* @param behaviour the parent driver handler
* @param cfg cross connect information
* @return the flow rule
*/
public static FlowRule toFlowRule(HandlerBehaviour behaviour, CrossConnects cfg) {
// Note: do we need to handle more than one pair? In any case, this
// looks strange.
Pair p = cfg.pair().get(0);
long i = p.ingress().uint32();
long o = p.egress().uint32();
PortNumber iPortNumber = PortNumber.portNumber(i);
PortNumber oPortNumber = PortNumber.portNumber(o);
return toFlowRule(behaviour, iPortNumber, oPortNumber);
}
use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects in project onos by opennetworkinglab.
the class PolatisOpticalUtility method fromFlowRule.
/**
* Transforms a flow FlowRule object to a cross-connect object.
* @param behaviour the parent driver handler
* @param rule FlowRule object
* @return cross connect object
*/
public static CrossConnects fromFlowRule(HandlerBehaviour behaviour, FlowRule rule) {
// TrafficSelector
Set<Criterion> criterions = rule.selector().criteria();
PortNumber inPort = criterions.stream().filter(c -> c instanceof PortCriterion).map(c -> ((PortCriterion) c).port()).findAny().orElse(null);
// TrafficTreatment
List<Instruction> instructions = rule.treatment().immediate();
PortNumber outPort = instructions.stream().filter(c -> c instanceof Instructions.OutputInstruction).map(c -> ((Instructions.OutputInstruction) c).port()).findAny().orElse(null);
DefaultCrossConnects crossConnects = new DefaultCrossConnects();
DefaultPair p = new DefaultPair();
p.ingress(new PortFormat(inPort.toLong()));
p.egress(new PortFormat(outPort.toLong()));
crossConnects.addToPair(p);
return crossConnects;
}
Aggregations