Search in sources :

Example 6 with MatchMplsLabel

use of org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel in project netvirt by opendaylight.

the class VrfEntryListener method makeLFibTableEntry.

private void makeLFibTableEntry(BigInteger dpId, long label, List<InstructionInfo> instructions, int priority, int addOrRemove, WriteTransaction tx) {
    Boolean wrTxPresent = true;
    if (tx == null) {
        wrTxPresent = false;
        tx = dataBroker.newWriteOnlyTransaction();
    }
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(MatchEthernetType.MPLS_UNICAST);
    matches.add(new MatchMplsLabel(label));
    // Install the flow entry in L3_LFIB_TABLE
    String flowRef = FibUtil.getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, label, priority);
    FlowEntity flowEntity;
    flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_LFIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
    Flow flow = flowEntity.getFlowBuilder().build();
    String flowId = flowEntity.getFlowId();
    FlowKey flowKey = new FlowKey(new FlowId(flowId));
    Node nodeDpn = FibUtil.buildDpnNode(dpId);
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, WriteTransaction.CREATE_MISSING_PARENTS);
    } else {
        tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
    }
    if (!wrTxPresent) {
        tx.submit();
    }
    LOG.debug("LFIB Entry for dpID {} : label : {} instructions {} : key {} {} successfully", dpId, label, instructions, flowKey, NwConstants.ADD_FLOW == addOrRemove ? "ADDED" : "REMOVED");
}
Also used : FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Aggregations

ArrayList (java.util.ArrayList)6 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)6 MatchMplsLabel (org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)3 ActionPopMpls (org.opendaylight.genius.mdsalutil.actions.ActionPopMpls)3 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)3 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)3 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)1 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)1 ActionSetFieldEthernetDestination (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination)1 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)1 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)1 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)1 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)1