use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class BGPPeerTrackerMock method mockPeerTracker.
private void mockPeerTracker() {
final PeerId pId = new PeerId("bgp://0.0.0.1");
doReturn(this.peerMock).when(this.peerTracker).getPeer(eq(pId));
doReturn(this.peerMock).when(this.peerTracker).getPeer(eq(PEER_ID));
doReturn(true).when(this.peerMock).supportsTable(Mockito.eq(TABLES_KEY));
doReturn(PeerRole.Ibgp).when(this.peerMock).getRole();
doReturn(this.peerMock2).when(this.peerTracker).getPeer(eq(PEER_ID2));
doReturn(false).when(this.peerMock2).supportsTable(Mockito.eq(TABLES_KEY));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class AbstractPeer method applyExportPolicy.
private Optional<ContainerNode> applyExportPolicy(final RouteEntryDependenciesContainer entryDep, final PeerId fromPeerId, final MapEntryNode route, final YangInstanceIdentifier routePath, final ContainerNode attrs) {
final Peer fromPeer = entryDep.getPeerTracker().getPeer(fromPeerId);
final RIBSupport<?, ?> ribSupport = entryDep.getRIBSupport();
final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(fromPeer, this, ribSupport.extractRouteKey(route.getIdentifier()), rtCache);
final Attributes bindingAttrs = ribSupport.attributeFromContainerNode(attrs);
final Optional<Attributes> optExportAttrs = entryDep.getRoutingPolicies().applyExportPolicies(routeEntry, bindingAttrs, entryDep.getAfiSafType());
if (optExportAttrs.isEmpty()) {
// Discards route
return Optional.empty();
}
final Attributes exportAttrs = optExportAttrs.orElseThrow();
// churn objects when it does not have to
return Optional.of(exportAttrs == bindingAttrs ? attrs : ribSupport.attributeToContainerNode(routePath.node(ribSupport.routeAttributesIdentifier()), exportAttrs));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class AdjRibsInWriterTest method testTransform.
@Test
public void testTransform() {
this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, this.ptc);
assertNotNull(this.writer);
final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(RIB_NID).node(Peer.QNAME).nodeWithKey(Peer.QNAME, RIBQNames.PEER_ID_QNAME, this.peerIp).build();
this.writer.transform(new PeerId(this.peerIp), peerPath, this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
verifyPeerSkeletonInsertedCorrectly(peerPath);
// verify supported tables were inserted for ipv4
verify(this.tx).put(eq(LogicalDatastoreType.OPERATIONAL), eq(peerPath.node(SupportedTables.QNAME).node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), any(NormalizedNode.class));
verifyUptodateSetToFalse(peerPath);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class IdentifierUtilsTest method testPeerId.
@Test
public void testPeerId() throws Exception {
final PeerId result = IdentifierUtils.peerId(NIWP_PEER);
assertEquals(PEER_ID, result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class BmpRouterImpl method delegateToPeer.
private synchronized void delegateToPeer(final Notification perPeerMessage) {
final PeerId peerId = getPeerId((PeerHeader) perPeerMessage);
final Optional<BmpRouterPeer> maybePeer = getPeer(peerId);
if (maybePeer.isPresent()) {
maybePeer.get().onPeerMessage(perPeerMessage);
if (perPeerMessage instanceof PeerDownNotification) {
this.peers.remove(peerId);
LOG.debug("Router {}: Peer {} removed.", this.routerIp, peerId.getValue());
}
} else {
LOG.debug("Peer: {} for Router: {} was not found.", peerId.getValue(), this.routerIp);
}
}
Aggregations