Search in sources :

Example 1 with CrossConnects

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());
}
Also used : CrossConnects(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects) Pair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair)

Example 2 with CrossConnects

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);
}
Also used : PortNumber(org.onosproject.net.PortNumber) Pair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair) DefaultPair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.DefaultPair)

Example 3 with CrossConnects

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;
}
Also used : TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Instructions(org.onosproject.net.flow.instructions.Instructions) PortFormat(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.PortFormat) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) Instruction(org.onosproject.net.flow.instructions.Instruction) Range(com.google.common.collect.Range) PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry) Pair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair) Set(java.util.Set) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) HandlerBehaviour(org.onosproject.net.driver.HandlerBehaviour) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) List(java.util.List) FlowRuleService(org.onosproject.net.flow.FlowRuleService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CrossConnects(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects) DefaultPair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.DefaultPair) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Criterion(org.onosproject.net.flow.criteria.Criterion) DefaultCrossConnects(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.DefaultCrossConnects) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) DefaultCrossConnects(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.DefaultCrossConnects) PortFormat(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.PortFormat) DefaultPair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.DefaultPair) Instructions(org.onosproject.net.flow.instructions.Instructions) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) PortNumber(org.onosproject.net.PortNumber) Instruction(org.onosproject.net.flow.instructions.Instruction)

Aggregations

Pair (org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair)3 PortNumber (org.onosproject.net.PortNumber)2 CrossConnects (org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects)2 DefaultPair (org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.DefaultPair)2 Range (com.google.common.collect.Range)1 List (java.util.List)1 Set (java.util.Set)1 CoreService (org.onosproject.core.CoreService)1 HandlerBehaviour (org.onosproject.net.driver.HandlerBehaviour)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 FlowRule (org.onosproject.net.flow.FlowRule)1 FlowRuleService (org.onosproject.net.flow.FlowRuleService)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 Criterion (org.onosproject.net.flow.criteria.Criterion)1 PortCriterion (org.onosproject.net.flow.criteria.PortCriterion)1 Instruction (org.onosproject.net.flow.instructions.Instruction)1