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());
}
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;
});
}
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());
}
}
}
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);
}
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();
}
}
Aggregations