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());
}
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);
}
}
}
}
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());
}
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;
});
}
Aggregations