use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class TunnelProviderDeployer method createTunnelTopologyProvider.
private synchronized void createTunnelTopologyProvider(final Topology topology) {
if (!filterPcepTopologies(topology.getTopologyTypes())) {
return;
}
final TopologyId topologyId = topology.getTopologyId();
if (this.pcepTunnelServices.containsKey(topology.getTopologyId())) {
LOG.warn("Tunnel Topology {} already exist. New instance won't be created", topologyId);
return;
}
LOG.debug("Create Tunnel Topology {}", topologyId);
final PcepTunnelTopologyConfig config = topology.getAugmentation(PcepTunnelTopologyConfig.class);
final String pcepTopoID = StringUtils.substringBetween(config.getPcepTopologyReference().getValue(), "=\"", "\"");
final InstanceIdentifier<Topology> pcepTopoRef = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId(pcepTopoID))).build();
final PCEPTunnelClusterSingletonService tunnelTopoCss = new PCEPTunnelClusterSingletonService(this.dependencies, pcepTopoRef, topologyId);
this.pcepTunnelServices.put(topology.getTopologyId(), tunnelTopoCss);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class TunnelProviderDeployer method removeTunnelTopologyProvider.
private synchronized void removeTunnelTopologyProvider(final Topology topo) {
if (!filterPcepTopologies(topo.getTopologyTypes())) {
return;
}
final TopologyId topologyId = topo.getTopologyId();
final PCEPTunnelClusterSingletonService topology = this.pcepTunnelServices.remove(topologyId);
closeTopology(topology, topologyId);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class NodeChangedListenerTest method testNodeChangedListener.
@Test
public void testNodeChangedListener() throws ReadFailedException, TransactionCommitFailedException {
// add node -> create two nodes with TPs and link
createNode(NODE1_ID, NODE1_IPV4, LSP1_NAME, LSP1_ID, NODE2_IPV4);
final Topology tunnelTopo = readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, tunnelTopo1 -> {
assertNotNull(tunnelTopo1.getNode());
assertEquals(2, tunnelTopo1.getNode().size());
return tunnelTopo1;
});
final NodeId srcId = new NodeId("ip://" + new IpAddress(new Ipv4Address(NODE1_IPV4)));
final NodeId dstId = new NodeId("ip://" + new IpAddress(new Ipv4Address(NODE2_IPV4)));
final Node dst;
final Node src;
if (tunnelTopo.getNode().get(0).getNodeId().equals(srcId)) {
src = tunnelTopo.getNode().get(0);
dst = tunnelTopo.getNode().get(1);
} else {
src = tunnelTopo.getNode().get(1);
dst = tunnelTopo.getNode().get(0);
}
Assert.assertEquals(srcId, src.getNodeId());
Assert.assertEquals(dstId, dst.getNodeId());
Assert.assertEquals(1, dst.getTerminationPoint().size());
Assert.assertEquals(1, src.getTerminationPoint().size());
final TerminationPoint dstTp = dst.getTerminationPoint().get(0);
final TerminationPoint srcTp = src.getTerminationPoint().get(0);
final TpId dstNodeTpId = new TpId(dstId.getValue());
final TpId srcNodeTpId = new TpId(srcId.getValue());
Assert.assertEquals(dstNodeTpId, dstTp.getTpId());
Assert.assertEquals(srcNodeTpId, srcTp.getTpId());
Assert.assertEquals(1, src.getSupportingNode().size());
Assert.assertNull(dst.getSupportingNode());
final SupportingNode sNode = src.getSupportingNode().get(0);
Assert.assertEquals(NODE1_ID, sNode.getKey().getNodeRef());
Assert.assertEquals(1, tunnelTopo.getLink().size());
final Link link = tunnelTopo.getLink().get(0);
Assert.assertEquals(srcId, link.getSource().getSourceNode());
Assert.assertEquals(srcNodeTpId, link.getSource().getSourceTp());
Assert.assertEquals(dstId, link.getDestination().getDestNode());
Assert.assertEquals(dstNodeTpId, link.getDestination().getDestTp());
// update second node -> adds supporting node and second link
createNode(NODE2_ID, NODE2_IPV4, LSP2_NAME, LSP2_ID, NODE1_IPV4);
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, updatedNodeTopo -> {
assertNotNull(updatedNodeTopo.getNode());
Assert.assertEquals(2, updatedNodeTopo.getNode().size());
final Node updatedNode;
if (updatedNodeTopo.getNode().get(0).getNodeId().equals(srcId)) {
updatedNode = updatedNodeTopo.getNode().get(1);
} else {
updatedNode = updatedNodeTopo.getNode().get(0);
}
assertNotNull(updatedNode.getSupportingNode());
Assert.assertEquals(1, updatedNode.getSupportingNode().size());
final SupportingNode sNode2 = updatedNode.getSupportingNode().get(0);
Assert.assertEquals(NODE2_ID, sNode2.getNodeRef());
Assert.assertEquals(2, updatedNodeTopo.getLink().size());
return updatedNodeTopo;
});
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, updatedNodeTopo -> {
final Link link2;
if (updatedNodeTopo.getLink().get(0).getSource().getSourceNode().equals(srcId)) {
link2 = updatedNodeTopo.getLink().get(1);
} else {
link2 = updatedNodeTopo.getLink().get(0);
}
assertEquals(dstId, link2.getSource().getSourceNode());
assertEquals(dstNodeTpId, link2.getSource().getSourceTp());
assertEquals(srcId, link2.getDestination().getDestNode());
assertEquals(srcNodeTpId, link2.getDestination().getDestTp());
return updatedNodeTopo;
});
// remove nodes -> remove link
removeNode(NODE1_ID);
removeNode(NODE2_ID);
readDataOperational(getDataBroker(), TUNNEL_TOPO_IID, removedNodeTopo -> {
assertEquals(0, removedNodeTopo.getNode().size());
assertEquals(0, removedNodeTopo.getLink().size());
return removedNodeTopo;
});
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class PcepStateUtils method readNodeFromDataStore.
private static Node readNodeFromDataStore(final DataBroker dataBroker, final String topologyId, final String nodeId) {
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId(topologyId))).child(Node.class, new NodeKey(new NodeId(nodeId))).build();
final ReadOnlyTransaction rot = dataBroker.newReadOnlyTransaction();
try {
return rot.read(LogicalDatastoreType.OPERATIONAL, topology).get().orNull();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to read node {}", nodeId, e);
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.
the class PcepStateUtilsTest method createDefaultProtocol.
private void createDefaultProtocol() throws ExecutionException, InterruptedException {
final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
final Node node = new NodeBuilder().setNodeId(new NodeId(NODE_ID)).addAugmentation(PcepTopologyNodeStatsAug.class, new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(createPcepSessionState()).build()).build();
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId(PCEP_TOPOLOGY))).child(Node.class, new NodeKey(new NodeId(NODE_ID))).build();
wt.put(LogicalDatastoreType.OPERATIONAL, topology, node, true);
wt.submit().get();
}
Aggregations