Search in sources :

Example 11 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class Ipv6ReachabilityTopologyBuilderTest method testIpv6ReachabilityTopologyBuilder.

@Test
public void testIpv6ReachabilityTopologyBuilder() throws InterruptedException, ExecutionException {
    // create route
    updateIpv6Route(createIpv6Route(NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv6TopoBuilder.getInstanceIdentifier(), topology -> {
        final TopologyTypes1 topologyType = topology.getTopologyTypes().augmentation(TopologyTypes1.class);
        assertNotNull(topologyType);
        assertNotNull(topologyType.getBgpIpv6ReachabilityTopology());
        assertEquals(1, topology.nonnullNode().size());
        final Node node = topology.nonnullNode().values().iterator().next();
        assertEquals(NEXT_HOP, node.getNodeId().getValue());
        assertEquals(ROUTE_IP6PREFIX, node.augmentation(Node1.class).getIgpNodeAttributes().nonnullPrefix().values().iterator().next().getPrefix().getIpv6Prefix().getValue());
        return topology;
    });
    // update route
    updateIpv6Route(createIpv6Route(NEW_NEXT_HOP));
    readDataOperational(getDataBroker(), this.ipv6TopoBuilder.getInstanceIdentifier(), topology -> {
        assertEquals(1, topology.nonnullNode().size());
        final Node nodeUpdated = topology.nonnullNode().values().iterator().next();
        assertEquals(NEW_NEXT_HOP, nodeUpdated.getNodeId().getValue());
        assertEquals(ROUTE_IP6PREFIX, nodeUpdated.augmentation(Node1.class).getIgpNodeAttributes().nonnullPrefix().values().iterator().next().getPrefix().getIpv6Prefix().getValue());
        return topology;
    });
    // delete route
    final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.ipv6RouteIID);
    wTx.commit();
    readDataOperational(getDataBroker(), this.ipv6TopoBuilder.getInstanceIdentifier(), topology -> {
        assertNull(topology.getNode());
        return topology;
    });
    this.ipv6TopoBuilder.close();
    checkNotPresentOperational(getDataBroker(), this.ipv6TopoBuilder.getInstanceIdentifier());
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) TopologyTypes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1) Test(org.junit.Test)

Example 12 with Node1

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 testOspfLinkstateTopologyBuilder.

@Test
public void testOspfLinkstateTopologyBuilder() throws InterruptedException, ExecutionException {
    // create node
    updateLinkstateRoute(this.linkstateNodeRouteIID, createLinkstateNodeRoute(ProtocolId.Ospf, "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_OSPF_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());
        assertNull(igpNode1.augmentation(IgpNodeAttributes1.class));
        assertEquals(ROUTER_1_ID, igpNode1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1.class).getOspfNodeAttributes().getTed().getTeRouterIdIpv4().getValue());
        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;
    });
    // update node with prefix
    updateLinkstateRoute(this.linkstatePrefixRouteIID, createLinkstatePrefixRoute(ProtocolId.Ospf, NODE_1_AS, NODE_1_PREFIX, 500L, ROUTER_1_ID));
    readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
        final Node node1 = topology.nonnullNode().values().iterator().next();
        final IgpNodeAttributes igpNode1 = node1.augmentation(Node1.class).getIgpNodeAttributes();
        assertEquals(1, igpNode1.nonnullPrefix().size());
        final Prefix prefix = igpNode1.nonnullPrefix().values().iterator().next();
        assertEquals(NODE_1_PREFIX, prefix.getPrefix().getIpv4Prefix().getValue());
        assertEquals(500L, prefix.getMetric().longValue());
        assertEquals(LinkstateTopologyBuilder.SR_AWARE_LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
        assertEquals(1, node1.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Node1.class).nonnullSegments().size());
        assertEquals(SRGB_START + NODE_SID_INDEX, node1.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr.rev130819.Node1.class).nonnullSegments().values().iterator().next().getSegmentId().getValue().intValue());
        return topology;
    });
    // create link
    updateLinkstateRoute(this.linkstateLinkRouteIID, createLinkstateLinkRoute(ProtocolId.Ospf, 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.getNode().size());
        assertEquals(1, Iterables.get(topology.getNode().values(), 0).getTerminationPoint().size());
        assertEquals(1, Iterables.get(topology.getNode().values(), 1).getTerminationPoint().size());
        assertEquals("bgpls://Ospf:1/type=link&local-as=1&local-router=0000.0102.0304&remote-as=2&mt=1", link1.getLinkId().getValue());
        assertEquals(NODE_1_OSPF_ID, link1.getSource().getSourceNode().getValue());
        assertEquals(NODE_2_OSPF_ID, link1.getDestination().getDestNode().getValue());
        final IgpLinkAttributes igpLink1 = link1.augmentation(Link1.class).getIgpLinkAttributes();
        assertEquals("link1", igpLink1.getName());
        assertNull(igpLink1.augmentation(IgpLinkAttributes1.class));
        assertEquals((short) 1, igpLink1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class).getOspfLinkAttributes().getMultiTopologyId().shortValue());
        assertEquals(2, igpLink1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class).getOspfLinkAttributes().getTed().getSrlg().getSrlgValues().size());
        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(2, 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;
    });
}
Also used : Collections(java.util.Collections) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) IgpNodeAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.IgpNodeAttributes) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Prefix(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.node.attributes.igp.node.attributes.Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Node1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1) IgpLinkAttributes1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1) Link1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Link1) IgpNodeAttributes1(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1) IgpLinkAttributes(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.igp.link.attributes.IgpLinkAttributes) Link(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link) Test(org.junit.Test)

Example 13 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class AbstractTopologySessionListener method onSessionUp.

@Override
public final void onSessionUp(final PCEPSession psession) {
    synchronized (this.serverSessionManager) {
        synchronized (this) {
            /*
                 * The session went up. Look up the router in Inventory model, create it if it
                 * is not there (marking that fact for later deletion), and mark it as
                 * synchronizing. Also create it in the topology model, with empty LSP list.
                 */
            final InetAddress peerAddress = psession.getRemoteAddress();
            this.syncOptimization = new SyncOptimization(psession);
            final TopologyNodeState state = this.serverSessionManager.takeNodeState(peerAddress, this, isLspDbRetreived());
            // due to configuration change
            if (state == null) {
                LOG.error("Unable to fetch topology node state for PCEP session. Closing session {}", psession);
                psession.close(TerminationReason.UNKNOWN);
                this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
                return;
            }
            if (this.session != null || this.nodeState != null) {
                LOG.error("PCEP session is already up with {}. Closing session {}", psession.getRemoteAddress(), psession);
                psession.close(TerminationReason.UNKNOWN);
                this.onSessionTerminated(psession, new PCEPCloseTermination(TerminationReason.UNKNOWN));
                return;
            }
            this.session = psession;
            this.nodeState = state;
            LOG.trace("Peer {} resolved to topology node {}", peerAddress, state.getNodeId());
            // Our augmentation in the topology node
            final PathComputationClientBuilder pccBuilder = new PathComputationClientBuilder();
            onSessionUp(psession, pccBuilder);
            this.synced.set(isSynchronized());
            pccBuilder.setIpAddress(IetfInetUtil.INSTANCE.ipAddressNoZoneFor(peerAddress));
            final InstanceIdentifier<Node1> topologyAugment = state.getNodeId().augmentation(Node1.class);
            this.pccIdentifier = topologyAugment.child(PathComputationClient.class);
            final Node initialNodeState = state.getInitialNodeState();
            final boolean isNodePresent = isLspDbRetreived() && initialNodeState != null;
            if (isNodePresent) {
                loadLspData(initialNodeState, this.lspData, this.lsps, isIncrementalSynchro());
                pccBuilder.setReportedLsp(initialNodeState.augmentation(Node1.class).getPathComputationClient().getReportedLsp());
            }
            state.storeNode(topologyAugment, new Node1Builder().setPathComputationClient(pccBuilder.build()).build(), this.session);
            this.listenerState = new SessionStateImpl(this, psession);
            this.serverSessionManager.bind(this.nodeState.getNodeId(), this.listenerState);
            LOG.info("Session with {} attached to topology node {}", psession.getRemoteAddress(), state.getNodeId());
        }
    }
}
Also used : PCEPCloseTermination(org.opendaylight.protocol.pcep.PCEPCloseTermination) Node1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1) Node1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1Builder) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClient) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) PathComputationClientBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.PathComputationClientBuilder) SessionStateImpl(org.opendaylight.bgpcep.pcep.topology.provider.session.stats.SessionStateImpl) InetAddress(java.net.InetAddress)

Example 14 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project controller by opendaylight.

the class EventSourceTopology method insert.

private void insert(final KeyedInstanceIdentifier<Node, NodeKey> sourcePath) {
    final NodeKey nodeKey = sourcePath.getKey();
    final InstanceIdentifier<Node1> augmentPath = sourcePath.augmentation(Node1.class);
    final Node1 nodeAgument = new Node1Builder().setEventSourceNode(new NodeId(nodeKey.getNodeId().getValue())).build();
    putData(OPERATIONAL, augmentPath, nodeAgument);
}
Also used : Node1(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.Node1) Node1Builder(org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.messagebus.eventsource.rev141202.Node1Builder) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)

Example 15 with Node1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.Node1 in project bgpcep by opendaylight.

the class PCEPStatefulPeerProposal method setPeerProposal.

void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder, final byte[] speakerId) {
    if (isSynOptimizationEnabled(openTlvsBuilder)) {
        Optional<LspDbVersion> result = Optional.absent();
        try (ReadOnlyTransaction rTx = this.dataBroker.newReadOnlyTransaction()) {
            final ListenableFuture<Optional<LspDbVersion>> future = rTx.read(LogicalDatastoreType.OPERATIONAL, this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class).child(PathComputationClient.class).augmentation(PathComputationClient1.class).child(LspDbVersion.class));
            try {
                result = future.get();
            } catch (final InterruptedException | ExecutionException e) {
                LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(PCEPStatefulPeerProposal.this.topologyId), e);
            }
        }
        if (speakerId == null && !result.isPresent()) {
            return;
        }
        final Tlvs3Builder syncBuilder = new Tlvs3Builder();
        if (result.isPresent()) {
            syncBuilder.setLspDbVersion(result.get());
        }
        if (speakerId != null) {
            syncBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(speakerId).build());
        }
        openTlvsBuilder.addAugmentation(Tlvs3.class, syncBuilder.build()).build();
    }
}
Also used : Optional(com.google.common.base.Optional) PathComputationClient(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.PathComputationClient) SpeakerEntityIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityIdBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) 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)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)14 Test (org.junit.Test)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)12 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)6 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)6 Optional (com.google.common.base.Optional)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)4 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)4 Node1 (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.nt.l3.unicast.igp.topology.rev131021.Node1)4