Search in sources :

Example 1 with SupportingNode

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;
    });
}
Also used : TpId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId) 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) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 2 with SupportingNode

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();
}
Also used : SupportingNodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeBuilder) TerminationPointKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.tunnel.pcep.supporting.node.attributes.PathComputationClientBuilder) TerminationPointBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) SupportingNode1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.SupportingNode1) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) SupportingNodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeBuilder) SupportingNode1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.SupportingNode1Builder) IpBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.igp.termination.point.attributes.termination.point.type.IpBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SupportingNodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey) IgpTerminationPointAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.termination.point.attributes.IgpTerminationPointAttributesBuilder) SupportingNodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TerminationPoint1Builder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.TerminationPoint1Builder) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 3 with SupportingNode

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);
        }
    }
}
Also used : SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) SupportingNodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 4 with SupportingNode

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();
}
Also used : SupportingNodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeBuilder) SupportingNode1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.SupportingNode1Builder) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.tunnel.pcep.supporting.node.attributes.PathComputationClientBuilder) SupportingNodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey)

Example 5 with SupportingNode

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);
        }
    }
}
Also used : VppNetconfConnectionProbe(org.opendaylight.lispflowmapping.neutron.intenthandler.util.VppNetconfConnectionProbe) 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) SupportingNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode) 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) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ExecutionException(java.util.concurrent.ExecutionException) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

SupportingNode (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode)4 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)3 SupportingNodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeKey)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 SupportingNode1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.SupportingNode1Builder)2 PathComputationClientBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.tunnel.pcep.supporting.node.attributes.PathComputationClientBuilder)2 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)2 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)2 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)2 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 SupportingNodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNodeBuilder)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)1 VppNetconfConnectionProbe (org.opendaylight.lispflowmapping.neutron.intenthandler.util.VppNetconfConnectionProbe)1 SupportingNode1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.rev130820.SupportingNode1)1 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)1