Search in sources :

Example 6 with PeerId

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));
}
Also used : PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Example 7 with PeerId

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));
}
Also used : Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes) BGPRouteEntryExportParametersImpl(org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)

Example 8 with PeerId

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);
}
Also used : NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Example 9 with PeerId

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);
}
Also used : PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Test(org.junit.Test)

Example 10 with PeerId

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);
    }
}
Also used : PeerDownNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerDownNotification) BmpRouterPeer(org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)

Aggregations

PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId)13 Test (org.junit.Test)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)5 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)5 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)4 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)4 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)4 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)3 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)3 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)2 BmpRouterPeer (org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer)2 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)2 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1