Search in sources :

Example 11 with Node

use of Nodes.Node in project netvirt by opendaylight.

the class VrfEntryListener method createTerminatingServiceActions.

public void createTerminatingServiceActions(BigInteger destDpId, int label, List<ActionInfo> actionsInfos, WriteTransaction tx) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    LOG.debug("create terminatingServiceAction on DpnId = {} and serviceId = {} and actions = {}", destDpId, label, actionsInfos);
    // Matching metadata
    // FIXME vxlan vni bit set is not working properly with OVS.need to revisit
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(label)));
    List<InstructionInfo> mkInstructions = new ArrayList<>();
    mkInstructions.add(new InstructionApplyActions(actionsInfos));
    FlowEntity terminatingServiceTableFlowEntity = MDSALUtil.buildFlowEntity(destDpId, NwConstants.INTERNAL_TUNNEL_TABLE, getTableMissFlowRef(destDpId, NwConstants.INTERNAL_TUNNEL_TABLE, label), 5, String.format("%s:%d", "TST Flow Entry ", label), 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(label)), mkMatches, mkInstructions);
    FlowKey flowKey = new FlowKey(new FlowId(terminatingServiceTableFlowEntity.getFlowId()));
    FlowBuilder flowbld = terminatingServiceTableFlowEntity.getFlowBuilder();
    Node nodeDpn = FibUtil.buildDpnNode(terminatingServiceTableFlowEntity.getDpnId());
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(terminatingServiceTableFlowEntity.getTableId())).child(Flow.class, flowKey).build();
    tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flowbld.build(), WriteTransaction.CREATE_MISSING_PARENTS);
}
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) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 12 with Node

use of Nodes.Node in project netvirt by opendaylight.

the class VrfEntryListener method removeTunnelTableEntry.

private void removeTunnelTableEntry(BigInteger dpId, long label, WriteTransaction tx) {
    FlowEntity flowEntity;
    LOG.debug("remove terminatingServiceActions called with DpnId = {} and label = {}", dpId, label);
    List<MatchInfo> mkMatches = new ArrayList<>();
    // Matching metadata
    mkMatches.add(new MatchTunnelId(BigInteger.valueOf(label)));
    flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.INTERNAL_TUNNEL_TABLE, getTableMissFlowRef(dpId, NwConstants.INTERNAL_TUNNEL_TABLE, (int) label), 5, String.format("%s:%d", "TST Flow Entry ", label), 0, 0, COOKIE_TUNNEL.add(BigInteger.valueOf(label)), mkMatches, null);
    Node nodeDpn = FibUtil.buildDpnNode(flowEntity.getDpnId());
    FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
    InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
    tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
    LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully", dpId, label);
}
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) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Example 13 with Node

use of Nodes.Node in project netvirt by opendaylight.

the class ElanServiceTestBase method getFlowIid.

protected InstanceIdentifier<Flow> getFlowIid(short tableId, FlowId flowid, BigInteger dpnId) {
    FlowKey flowKey = new FlowKey(new FlowId(flowid));
    NodeId nodeId = new NodeId("openflow:" + dpnId);
    Node nodeDpn = new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
    return InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).child(Flow.class, flowKey).build();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) 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) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 14 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class LearningSwitchHandlerSimpleImpl method onSwitchAppeared.

@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
    if (isLearning) {
        LOG.debug("already learning a node, skipping {}", nodeId.getValue());
        return;
    }
    LOG.debug("expected table acquired, learning ..");
    // disable listening - simple learning handles only one node (switch)
    if (registrationPublisher != null) {
        LOG.debug("closing dataTreeChangeListenerRegistration");
        registrationPublisher.getDataTreeChangeListenerRegistration().close();
    }
    isLearning = true;
    tablePath = appearedTablePath;
    nodePath = tablePath.firstIdentifierOf(Node.class);
    nodeId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId();
    mac2portMapping = new HashMap<>();
    // start forwarding all packages to controller
    FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
    FlowKey flowKey = new FlowKey(flowId);
    InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
    int priority = 0;
    // create flow in table with id = 0, priority = 4 (other params are
    // defaulted in OFDataStoreUtil)
    FlowBuilder allToCtrlFlow = FlowUtils.createFwdAllToControllerFlow(InstanceIdentifierUtils.getTableId(tablePath), priority, flowId);
    LOG.debug("writing packetForwardToController flow");
    dataStoreAccessor.writeFlowToConfig(flowPath, allToCtrlFlow.build());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 15 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class MultipleLearningSwitchHandlerFacadeImpl method onSwitchAppeared.

@Override
public synchronized void onSwitchAppeared(InstanceIdentifier<Table> appearedTablePath) {
    LOG.debug("expected table acquired, learning ..");
    /**
     * appearedTablePath is in form of /nodes/node/node-id/table/table-id
     * so we shorten it to /nodes/node/node-id to get identifier of switch.
     */
    InstanceIdentifier<Node> nodePath = InstanceIdentifierUtils.getNodePath(appearedTablePath);
    /**
     * We check if we already initialized dispatcher for that node,
     * if not we create new handler for switch.
     */
    if (!packetInDispatcher.getHandlerMapping().containsKey(nodePath)) {
        // delegate this node (owning appearedTable) to SimpleLearningSwitchHandler
        LearningSwitchHandlerSimpleImpl simpleLearningSwitch = new LearningSwitchHandlerSimpleImpl(dataStoreAccessor, packetProcessingService, null);
        /**
         * We propagate table event to newly instantiated instance of learning switch
         */
        simpleLearningSwitch.onSwitchAppeared(appearedTablePath);
        /**
         * We update mapping of already instantiated LearningSwitchHanlders
         */
        packetInDispatcher.getHandlerMapping().put(nodePath, simpleLearningSwitch);
    }
}
Also used : LearningSwitchHandlerSimpleImpl(org.opendaylight.openflowplugin.learningswitch.LearningSwitchHandlerSimpleImpl) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)112 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)58 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)56 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)54 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)43 Test (org.junit.Test)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)20 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)19 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)19 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)17 BigInteger (java.math.BigInteger)16 ArrayList (java.util.ArrayList)16 NodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)16 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)15 Before (org.junit.Before)11 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)8 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)7 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)7 Optional (com.google.common.base.Optional)6