Search in sources :

Example 21 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project controller by opendaylight.

the class DataServiceIT method test.

/**
 * Ignored this, because classes here are constructed from very different class loader as MD-SAL is run into,
 * this is code is run from different classloader.
 */
@Test
public void test() throws Exception {
    final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    assertNotNull(transaction);
    InstanceIdentifier<UnorderedList> node1 = createNodeRef("0");
    Optional<UnorderedList> node = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).get(5, TimeUnit.SECONDS);
    assertFalse(node.isPresent());
    UnorderedList nodeData1 = createNode("0");
    transaction.put(LogicalDatastoreType.OPERATIONAL, node1, nodeData1);
    transaction.commit().get(5, TimeUnit.SECONDS);
    Optional<UnorderedList> readedData = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).get(5, TimeUnit.SECONDS);
    assertTrue(readedData.isPresent());
    assertEquals(nodeData1.key(), readedData.get().key());
    final WriteTransaction transaction2 = dataBroker.newWriteOnlyTransaction();
    assertNotNull(transaction2);
    transaction2.delete(LogicalDatastoreType.OPERATIONAL, node1);
    transaction2.commit().get(5, TimeUnit.SECONDS);
    Optional<UnorderedList> readedData2 = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, node1).get(5, TimeUnit.SECONDS);
    assertFalse(readedData2.isPresent());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) UnorderedList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.lists.unordered.container.UnorderedList) Test(org.junit.Test)

Example 22 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class PCEPTopologySessionListener method loadLspData.

/**
 * Recover lspData and mark any LSPs in the LSP database that were previously reported by the PCC as stale.
 */
@Override
protected synchronized void loadLspData(final Node node, final Map<String, ReportedLsp> lspData, final Map<PlspId, String> lsps, final boolean incrementalSynchro) {
    // load node's lsps from DS
    final PathComputationClient pcc = node.augmentation(Node1.class).getPathComputationClient();
    for (final ReportedLsp reportedLsp : pcc.nonnullReportedLsp().values()) {
        final String lspName = reportedLsp.getName();
        lspData.put(lspName, reportedLsp);
        if (!reportedLsp.getPath().isEmpty()) {
            final Path1 path1 = reportedLsp.getPath().values().iterator().next().augmentation(Path1.class);
            if (path1 != null) {
                final PlspId plspId = path1.getLsp().getPlspId();
                if (!incrementalSynchro) {
                    staleLsps.add(plspId);
                }
                lsps.put(plspId, lspName);
            }
        }
    }
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLsp) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClient) Path1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)

Example 23 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class Ipv4ReachabilityTopologyBuilderTest method testIpv4ReachabilityTopologyBuilder.

@Test
public void testIpv4ReachabilityTopologyBuilder() throws InterruptedException, ExecutionException {
    // create route
    updateIpv4Route(createIpv4Route(NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        final TopologyTypes1 topologyTypes = topology.getTopologyTypes().augmentation(TopologyTypes1.class);
        assertNotNull(topologyTypes);
        assertNotNull(topologyTypes.getBgpIpv4ReachabilityTopology());
        assertEquals(1, topology.nonnullNode().size());
        final Node node = topology.nonnullNode().values().iterator().next();
        assertEquals(NEXT_HOP, node.getNodeId().getValue());
        assertEquals(ROUTE_IP4PREFIX, node.augmentation(Node1.class).getIgpNodeAttributes().nonnullPrefix().values().iterator().next().getPrefix().getIpv4Prefix().getValue());
        return topology;
    });
    // update route
    updateIpv4Route(createIpv4Route(NEW_NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.nonnullNode().size());
        final Node nodeUpdated = topology.nonnullNode().values().iterator().next();
        assertEquals(NEW_NEXT_HOP, nodeUpdated.getNodeId().getValue());
        assertEquals(ROUTE_IP4PREFIX, nodeUpdated.augmentation(Node1.class).getIgpNodeAttributes().nonnullPrefix().values().iterator().next().getPrefix().getIpv4Prefix().getValue());
        return topology;
    });
    // delete route
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.ipv4RouteIID);
    wTx.commit();
    readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
        assertNull(topology.getNode());
        return topology;
    });
    this.ipv4TopoBuilder.close();
    checkNotPresentOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier());
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TopologyTypes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1) Test(org.junit.Test)

Example 24 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class LinkstateTopologyBuilderTest method testIsisLinkstateTopologyBuilder.

@Test
public void testIsisLinkstateTopologyBuilder() throws InterruptedException, ExecutionException {
    // create node
    updateLinkstateRoute(this.linkstateNodeRouteIID, createLinkstateNodeRoute(ProtocolId.IsisLevel2, "node1", NODE_1_AS, ROUTER_1_ID));
    readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.nonnullNode().size());
        final Node node1 = topology.nonnullNode().values().iterator().next();
        assertEquals(NODE_1_ISIS_ID, node1.getNodeId().getValue());
        final IgpNodeAttributes igpNode1 = node1.augmentation(Node1.class).getIgpNodeAttributes();
        assertEquals(ROUTER_1_ID, igpNode1.getRouterId().get(0).getIpv4Address().getValue());
        assertEquals("node1", igpNode1.getName().getValue());
        final IgpNodeAttributes1 igpNodeAttributes1 = igpNode1.augmentation(IgpNodeAttributes1.class);
        assertEquals("0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes().getIso().getIsoSystemId().getValue());
        assertEquals(ROUTER_1_ID, igpNodeAttributes1.getIsisNodeAttributes().getTed().getTeRouterIdIpv4().getValue());
        assertEquals("47.0000.0000.0000.0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes().getNet().get(0).getValue());
        assertNull(igpNode1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1.class));
        assertEquals(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
        assertNull(node1.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Node1.class));
        return topology;
    });
    // create link
    updateLinkstateRoute(this.linkstateLinkRouteIID, createLinkstateLinkRoute(ProtocolId.IsisLevel2, NODE_1_AS, NODE_2_AS, "link1"));
    readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.nonnullLink().size());
        final Link link1 = topology.nonnullLink().values().iterator().next();
        assertEquals(2, topology.nonnullNode().size());
        assertEquals(1, Iterables.get(topology.getNode().values(), 0).getTerminationPoint().size());
        assertEquals(1, Iterables.get(topology.getNode().values(), 1).getTerminationPoint().size());
        assertEquals("bgpls://IsisLevel2:1/type=link&local-as=1&local-router=0000.0102.0304&remote-as" + "=2&mt=1", link1.getLinkId().getValue());
        assertEquals(NODE_1_ISIS_ID, link1.getSource().getSourceNode().getValue());
        assertEquals(NODE_2_ISIS_ID, link1.getDestination().getDestNode().getValue());
        final IgpLinkAttributes igpLink1 = link1.augmentation(Link1.class).getIgpLinkAttributes();
        assertEquals("link1", igpLink1.getName());
        assertEquals((short) 1, igpLink1.augmentation(IgpLinkAttributes1.class).getIsisLinkAttributes().getMultiTopologyId().shortValue());
        assertNull(igpLink1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class));
        assertEquals(LinkstateTopologyBuilder.SR_AWARE_LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
        assertEquals(2, topology.getNode().size());
        final Node srcNode;
        if (topology.getNode().values().iterator().next().getNodeId().getValue().contains("0000.0102.0304")) {
            srcNode = topology.getNode().values().iterator().next();
        } else {
            srcNode = Iterables.get(topology.getNode().values(), 1);
        }
        assertEquals(1, srcNode.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Node1.class).getSegments().size());
        assertEquals(ADJ_SID, link1.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Link1.class).getSegment().getValue().intValue());
        return topology;
    });
    removeLinkstateRoute(this.linkstateLinkRouteIID);
    // update node
    updateLinkstateRoute(this.linkstateNodeRouteIID, createLinkstateNodeRoute(ProtocolId.IsisLevel2, "updated-node", NODE_1_AS, ROUTER_2_ID));
    readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.getNode().size());
        final IgpNodeAttributes igpNode2 = topology.getNode().values().iterator().next().augmentation(Node1.class).getIgpNodeAttributes();
        assertEquals(ROUTER_2_ID, igpNode2.getRouterId().get(0).getIpv4Address().getValue());
        assertEquals("updated-node", igpNode2.getName().getValue());
        return topology;
    });
    // remove
    removeLinkstateRoute(this.linkstateNodeRouteIID);
    readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
        assertNull(topology.getNode());
        assertNull(topology.getLink());
        return topology;
    });
}
Also used : Collections(java.util.Collections) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) IgpNodeAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes) Node1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1) IgpLinkAttributes1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1) Link1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Link1) IgpNodeAttributes1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1) IgpLinkAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.link.attributes.IgpLinkAttributes) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) Test(org.junit.Test)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)14 Test (org.junit.Test)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)12 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)6 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)6 Optional (com.google.common.base.Optional)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)4 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)4 Node1 (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1)4