use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode 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.node.attributes.SupportingNode in project bgpcep by opendaylight.
the class TunnelProgrammingTest method createNode.
private static Node createNode(final NodeId nodeId, final TpId tpId, final String ipv4Address) {
final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
tpBuilder.setTpId(tpId);
tpBuilder.setKey(new TerminationPointKey(tpId));
tpBuilder.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder().setTerminationPointType(new IpBuilder().setIpAddress(Collections.singletonList(new IpAddress(new Ipv4Address(ipv4Address)))).build()).build()).build());
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(nodeId);
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setTerminationPoint(Lists.newArrayList(tpBuilder.build()));
final SupportingNode supportingNode = new SupportingNodeBuilder().setKey(new SupportingNodeKey(nodeId, new TopologyId("dummy"))).addAugmentation(SupportingNode1.class, new SupportingNode1Builder().setPathComputationClient(new PathComputationClientBuilder().setControlling(true).build()).build()).build();
nodeBuilder.setSupportingNode(Lists.newArrayList(supportingNode));
return nodeBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode in project bgpcep by opendaylight.
the class NodeChangedListener method handleSni.
private void handleSni(final InstanceIdentifier<Node> sni, final Node node, final Boolean inControl, final ReadWriteTransaction trans) {
if (sni != null) {
final NodeKey k = InstanceIdentifier.keyOf(sni);
boolean have = false;
/*
* We may have found a termination point which has been created as a destination,
* so it does not have a supporting node pointer. Since we now know what it is,
* fill it in.
*/
if (node.getSupportingNode() != null) {
for (final SupportingNode sn : node.getSupportingNode()) {
if (sn.getNodeRef().equals(k.getNodeId())) {
have = true;
break;
}
}
}
if (!have) {
final SupportingNode sn = createSupportingNode(k.getNodeId(), inControl);
trans.put(LogicalDatastoreType.OPERATIONAL, this.target.child(Node.class, node.getKey()).child(SupportingNode.class, sn.getKey()), sn);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode in project bgpcep by opendaylight.
the class NodeChangedListener method createSupportingNode.
private SupportingNode createSupportingNode(final NodeId sni, final Boolean inControl) {
final SupportingNodeKey sk = new SupportingNodeKey(sni, this.source);
final SupportingNodeBuilder snb = new SupportingNodeBuilder();
snb.setNodeRef(sni);
snb.setKey(sk);
snb.addAugmentation(SupportingNode1.class, new SupportingNode1Builder().setPathComputationClient(new PathComputationClientBuilder().setControlling(inControl).build()).build());
return snb.build();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode in project lispflowmapping by opendaylight.
the class VppEndpointListener method processNodeOnConnection.
private void processNodeOnConnection(final Node newOrModifiedNode) {
for (SupportingNode supportingNode : newOrModifiedNode.getSupportingNode()) {
final NodeId nodeMount = supportingNode.getNodeRef();
final VppNetconfConnectionProbe probe = new VppNetconfConnectionProbe(supportingNode.getNodeRef(), dataBroker);
try {
// Verify netconf connection
boolean connectionReady = probe.startProbing();
if (connectionReady) {
LOG.debug("Node {} is connected, creating ...", supportingNode.getNodeRef());
final TopologyId topologyMount = supportingNode.getTopologyRef();
final KeyedInstanceIdentifier<Node, NodeKey> iiToVpp = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyMount)).child(Node.class, new NodeKey(nodeMount));
nodeIdToKeyedInstanceIdentifierMap.put(newOrModifiedNode.getNodeId(), iiToVpp);
} else {
LOG.debug("Failed while connecting to node {}", supportingNode.getNodeRef());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception while processing node {} ... ", supportingNode.getNodeRef(), e);
} catch (TimeoutException e) {
LOG.warn("Node {} was not connected within {} seconds. " + "Check node configuration and connectivity to proceed", supportingNode.getNodeRef(), VppNetconfConnectionProbe.NODE_CONNECTION_TIMER);
}
}
}
Aggregations