Search in sources :

Example 6 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 testOnNodeConnectorUpdatedWithPortDown.

@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorUpdatedWithPortDown() {
    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(false, true));
    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)

Example 7 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 FlowCapableTopologyProvider method start.

/**
 * Gets called on start of a bundle.
 */
public void start() {
    final TopologyKey key = new TopologyKey(new TopologyId(TOPOLOGY_ID));
    final InstanceIdentifier<Topology> path = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, key);
    final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path);
    this.listenerRegistration = notificationService.registerNotificationListener(listener);
    this.transactionChainManager = new TransactionChainManager(dataBroker, TOPOLOGY_PROVIDER);
    this.transactionChainManager.activateTransactionManager();
    this.transactionChainManager.initialSubmitWriteTransaction();
    if (!isFlowTopologyExist(path)) {
        transactionChainManager.writeToTransaction(LogicalDatastoreType.OPERATIONAL, path, new TopologyBuilder().setKey(key).build(), true);
        transactionChainManager.submitTransaction();
    }
    LOG.info("FlowCapableTopologyProvider started");
}
Also used : 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) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 8 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 AbstractTopologyBuilder method initOperationalTopology.

private synchronized void initOperationalTopology() {
    requireNonNull(this.chain, "A valid transaction chain must be provided.");
    final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
    trans.put(LogicalDatastoreType.OPERATIONAL, this.topology, new TopologyBuilder().setKey(this.topologyKey).setServerProvided(Boolean.TRUE).setTopologyTypes(this.topologyTypes).setLink(Collections.emptyList()).setNode(Collections.emptyList()).build(), true);
    Futures.addCallback(trans.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            LOG.trace("Transaction {} committed successfully", trans.getIdentifier());
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Failed to initialize topology {} (transaction {}) by listener {}", AbstractTopologyBuilder.this.topology, trans.getIdentifier(), AbstractTopologyBuilder.this, throwable);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)

Example 9 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 NodeChangedListenerTest method setUp.

@Before
public void setUp() throws TransactionCommitFailedException {
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID, new TopologyBuilder().setKey(new TopologyKey(PCEP_TOPOLOGY_ID)).setNode(Lists.newArrayList()).setTopologyId(PCEP_TOPOLOGY_ID).build(), true);
    wTx.put(LogicalDatastoreType.OPERATIONAL, TUNNEL_TOPO_IID, new TopologyBuilder().setKey(new TopologyKey(TUNNEL_TOPOLOGY_ID)).setTopologyId(TUNNEL_TOPOLOGY_ID).build(), true);
    wTx.submit().checkedGet();
    final NodeChangedListener nodeListener = new NodeChangedListener(getDataBroker(), PCEP_TOPOLOGY_ID, TUNNEL_TOPO_IID);
    this.listenerRegistration = getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.child(Node.class)), nodeListener);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) 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) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Before(org.junit.Before)

Example 10 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 TunnelProgrammingTest method createInitialTopology.

private void createInitialTopology() throws TransactionCommitFailedException {
    final TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setKey(new TopologyKey(TOPOLOGY_ID));
    topologyBuilder.setServerProvided(true);
    topologyBuilder.setTopologyId(TOPOLOGY_ID);
    topologyBuilder.setNode(Lists.newArrayList(createNode(NODE1_ID, TP1_ID, NODE1_IPV4), createNode(NODE2_ID, TP2_ID, NODE2_IPV4)));
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.put(LogicalDatastoreType.OPERATIONAL, TOPO_IID, topologyBuilder.build(), true);
    wTx.submit().checkedGet();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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)

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