Search in sources :

Example 11 with Topology

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);
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) 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) PcepTunnelTopologyConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.config.rev171127.PcepTunnelTopologyConfig) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 12 with Topology

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

Example 13 with Topology

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;
    });
}
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 14 with Topology

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;
}
Also used : TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) 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)

Example 15 with Topology

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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAugBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) 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)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)30 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)26 Test (org.junit.Test)20 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)15 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)12 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)10 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)10 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)10 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)9 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)8 Optional (com.google.common.base.Optional)7 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)7 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)7 ExecutionException (java.util.concurrent.ExecutionException)6 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)5 ArrayList (java.util.ArrayList)4