Search in sources :

Example 11 with TopologyBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project bgpcep by opendaylight.

the class PCEPTunnelTopologyProvider method init.

synchronized void init() {
    final WriteTransaction tx = this.dataBroker.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.OPERATIONAL, getTopologyReference().getInstanceIdentifier(), new TopologyBuilder().setTopologyId(this.tunneltopologyId).setTopologyTypes(new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class, new TopologyTypes1Builder().setTopologyTunnelPcep(new TopologyTunnelPcepBuilder().build()).build()).build()).setNode(new ArrayList<>()).build(), true);
    try {
        tx.submit().get();
    } catch (final InterruptedException | ExecutionException e) {
        LOG.error("Failed to create Tunnel Topology root", e);
    }
    this.reg = this.ncl.getDataProvider().registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, this.src), this.ncl);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TopologyTunnelPcepBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.topology.tunnel.pcep.type.TopologyTunnelPcepBuilder) TopologyTypesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypesBuilder) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) TopologyTypes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.TopologyTypes1) TopologyTypes1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.TopologyTypes1Builder) ExecutionException(java.util.concurrent.ExecutionException)

Example 12 with TopologyBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project netvirt by opendaylight.

the class StateManager method initializeNetvirtTopology.

private void initializeNetvirtTopology() {
    final TopologyId topologyId = new TopologyId("netvirt:1");
    InstanceIdentifier<Topology> path = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
    TopologyBuilder tpb = new TopologyBuilder();
    tpb.setTopologyId(topologyId);
    try {
        txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.OPERATIONAL, path, tpb.build())).get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("StateManager error initializing netvirt topology", e);
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) LoggerFactory(org.slf4j.LoggerFactory) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) INeutronVpnManager(org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ExecutionException(java.util.concurrent.ExecutionException) Inject(javax.inject.Inject) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) PostConstruct(javax.annotation.PostConstruct) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) ExecutionException(java.util.concurrent.ExecutionException) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 13 with TopologyBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project openflowplugin by opendaylight.

the class NodeChangeListenerImplTest method testOnNodeRemoved.

@SuppressWarnings({ "rawtypes" })
@Test
public void testOnNodeRemoved() {
    NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
    final InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
    Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
    final InstanceIdentifier<?> invNodeID = InstanceIdentifier.create(Nodes.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeKey);
    List<Link> linkList = Arrays.asList(newLink("link1", newSourceNode("node1"), newDestNode("dest")), newLink("link2", newSourceNode("source"), newDestNode("node1")), newLink("link2", newSourceNode("source2"), newDestNode("dest2")));
    final Topology topology = new TopologyBuilder().setLink(linkList).build();
    final InstanceIdentifier[] expDeletedIIDs = { topologyIID.child(Link.class, linkList.get(0).getKey()), topologyIID.child(Link.class, linkList.get(1).getKey()), topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))) };
    SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
    readFuture.set(Optional.of(topology));
    ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
    doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
    SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
    readFutureNode.set(Optional.of(topoNode));
    doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
    final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
    int expDeleteCalls = expDeletedIIDs.length;
    CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
    ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
    setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
    doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
    DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeID);
    nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForSubmit(submitLatch1);
    setReadFutureAsync(topology, readFuture);
    waitForDeletes(expDeleteCalls, deleteLatch);
    assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
    verifyMockTx(mockTx1);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) InventoryNode(org.opendaylight.yang.gen.v1.urn.opendaylight.model.topology.inventory.rev131030.InventoryNode) TestUtils.newDestNode(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newDestNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TestUtils.newSourceNode(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newSourceNode) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestUtils.newInvNodeKey(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) Optional(com.google.common.base.Optional) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) CountDownLatch(java.util.concurrent.CountDownLatch) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Mockito.doReturn(org.mockito.Mockito.doReturn) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) Test(org.junit.Test)

Example 14 with TopologyBuilder

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project openflowplugin by opendaylight.

the class TerminationPointChangeListenerImplTest method testOnNodeConnectorUpdatedWithLinkStateDown.

@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorUpdatedWithLinkStateDown() {
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey("node1");
    org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey("tp1");
    final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
    List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")));
    Topology topology = new TopologyBuilder().setLink(linkList).build();
    ReadWriteTransaction mockTx = mock(ReadWriteTransaction.class);
    doReturn(Futures.immediateCheckedFuture(Optional.of(topology))).when(mockTx).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
    setupStubbedSubmit(mockTx);
    CountDownLatch deleteLatch = new CountDownLatch(1);
    ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
    setupStubbedDeletes(mockTx, deletedLinkIDs, deleteLatch);
    doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
    DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID);
    when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(provideFlowCapableNodeConnector(true, false));
    terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
    waitForDeletes(1, deleteLatch);
    InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1")));
    verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), any(TerminationPoint.class), eq(true));
    assertDeletedIDs(new InstanceIdentifier[] { topologyIID.child(Link.class, linkList.get(0).getKey()) }, deletedLinkIDs);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) TestUtils.newInvNodeKey(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) CountDownLatch(java.util.concurrent.CountDownLatch) Mockito.doReturn(org.mockito.Mockito.doReturn) TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TestUtils.newLink(org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Test(org.junit.Test)

Aggregations

TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)12 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)7 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)5 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)5 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 Test (org.junit.Test)4 Mockito.doReturn (org.mockito.Mockito.doReturn)4 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)4 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)4 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)4 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)4 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)4 ExecutionException (java.util.concurrent.ExecutionException)3 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)3 Optional (com.google.common.base.Optional)2 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)2