Search in sources :

Example 76 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class NodeChangeListenerImpl method processRemovedNode.

private void processRemovedNode(final DataTreeModification<FlowCapableNode> modification) {
    final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory = modification.getRootPath().getRootIdentifier();
    final NodeId nodeId = provideTopologyNodeId(iiToNodeInInventory);
    final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> iiToTopologyRemovedNode = provideIIToTopologyNode(nodeId);
    if (iiToTopologyRemovedNode != null) {
        operationProcessor.enqueueOperation(manager -> {
            manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyRemovedNode);
            TopologyManagerUtil.removeAffectedLinks(nodeId, manager, II_TO_TOPOLOGY);
        });
    } else {
        LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting node.");
    }
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) InventoryNode(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)

Example 77 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImpl method processRemovedTerminationPoints.

private void processRemovedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
    final InstanceIdentifier<FlowCapableNodeConnector> removedNode = modification.getRootPath().getRootIdentifier();
    final TpId terminationPointId = provideTopologyTerminationPointId(removedNode);
    final InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(terminationPointId, removedNode);
    if (iiToTopologyTerminationPoint != null) {
        final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> node = iiToTopologyTerminationPoint.firstIdentifierOf(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class);
        operationProcessor.enqueueOperation(manager -> {
            Optional<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeOptional = Optional.empty();
            try {
                nodeOptional = Optional.ofNullable(manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).checkedGet().orNull());
            } catch (ReadFailedException e) {
                LOG.warn("Error occurred when trying to read NodeConnector: {}", e.getMessage());
                LOG.debug("Error occurred when trying to read NodeConnector.. ", e);
            }
            if (nodeOptional.isPresent()) {
                TopologyManagerUtil.removeAffectedLinks(terminationPointId, manager, II_TO_TOPOLOGY);
                manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyTerminationPoint);
            }
        });
    } else {
        LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting termination point.");
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 78 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class DeviceMastershipManager method registerNodeListener.

@SuppressWarnings("IllegalCatch")
private void registerNodeListener() {
    final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
    final DataTreeIdentifier<FlowCapableNode> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
    try {
        SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK, ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
        listenerRegistration = looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(treeId, DeviceMastershipManager.this));
    } catch (Exception e) {
        LOG.warn("Data listener registration failed: {}", e.getMessage());
        LOG.debug("Data listener registration failed ", e);
        throw new IllegalStateException("Node listener registration failed!", e);
    }
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) SimpleTaskRetryLooper(org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)

Example 79 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.

@Test
public void testAddRemoveFlowsRpc() throws Exception {
    Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
    final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
    bulkFlowItems.add(bulkFlowItem);
    final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
    addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
    salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
    verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
    final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
    removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
    salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
    verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
Also used : BulkFlowItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder) BulkFlowItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) RemoveFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder) AddFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput) RemoveFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder) Test(org.junit.Test)

Example 80 with Node

use of Nodes.Node in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsDs.

@Test
public void testAddRemoveFlowsDs() throws Exception {
    Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
    final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")).setTableId((short) 2);
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
    final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
    bulkFlowDsItems.add(bulkFlowDsItem);
    final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
    addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
    salBulkFlowService.addFlowsDs(addFlowsDsInput);
    verify(writeTransaction).submit();
    verify(writeTransaction).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
    Flow flow = flowArgumentCaptor.getValue();
    Assert.assertEquals("1", flow.getId().getValue());
    Assert.assertEquals((short) 2, flow.getTableId().shortValue());
    final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
    removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
    final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
    salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
    verify(writeTransaction).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
    verify(writeTransaction, times(2)).submit();
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) 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) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) RemoveFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInputBuilder) AddFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInput) BulkFlowDsItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItemBuilder) BulkFlowDsItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.ds.list.grouping.BulkFlowDsItem) AddFlowsDsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDsInputBuilder) RemoveFlowsDsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsDsInput) Test(org.junit.Test)

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