Search in sources :

Example 1 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.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.chain);
    assertNotNull(this.writer);
    final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(Rib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME, AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
    this.writer.transform(new PeerId(this.peerIp), this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
    verifyPeerSkeletonInsertedCorrectly(peerPath);
    // verify supported tables were inserted for ipv4
    Mockito.verify(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath.node(SupportedTables.QNAME).node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.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.rev171207.PeerId) Test(org.junit.Test)

Example 2 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId in project bgpcep by opendaylight.

the class MatchBgpNeighborSetTest method testMatchFromBgpNeighborInvert.

@Test
public void testMatchFromBgpNeighborInvert() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-from-neighbor-invert-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getFromPeerId();
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertNull(result.getAttributes());
    doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertNotNull(result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId) Test(org.junit.Test)

Example 3 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId in project bgpcep by opendaylight.

the class MatchBgpNeighborSetTest method testMatchToBgpNeighborInvert.

@Test
public void testMatchToBgpNeighborInvert() {
    Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-to-neighbor-invert-test")).findFirst().get();
    RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
    doReturn(new PeerId("bgp://127.0.0.2")).when(this.exportParameters).getFromPeerId();
    doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getToPeerId();
    RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertNull(result.getAttributes());
    doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
    result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
    assertNotNull(result.getAttributes());
}
Also used : Statement(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement) RouteAttributeContainer(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId) Test(org.junit.Test)

Example 4 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId in project bgpcep by opendaylight.

the class MatchBgpNeighborSetHandler method matchBgpNeighborSetCondition.

private boolean matchBgpNeighborSetCondition(@Nonnull final PeerId fromPeerId, @Nullable final PeerId toPeerId, final MatchBgpNeighborSet matchBgpNeighborSet) {
    final BgpNeighbor from = matchBgpNeighborSet.getFromNeighbor();
    Boolean match = null;
    if (from != null) {
        match = checkMatch(from.getNeighborSet(), fromPeerId, from.getMatchSetOptions());
    }
    if (match != null && !match) {
        return false;
    }
    final BgpNeighbor to = matchBgpNeighborSet.getToNeighbor();
    if (to != null) {
        match = checkMatch(to.getNeighborSet(), toPeerId, to.getMatchSetOptions());
    }
    return match;
}
Also used : BgpNeighbor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.BgpNeighbor)

Example 5 with PeerId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId in project bgpcep by opendaylight.

the class BmpRouterImpl method onPeerUp.

private synchronized void onPeerUp(final PeerUpNotification peerUp) {
    final PeerId peerId = getPeerIdFromOpen(peerUp.getReceivedOpen());
    if (!getPeer(peerId).isPresent()) {
        final BmpRouterPeer peer = BmpRouterPeerImpl.createRouterPeer(this.domTxChain, this.peersYangIId, peerUp, this.extensions, this.tree, peerId);
        this.peers.put(peerId, peer);
        LOG.debug("Router {}: Peer {} goes up.", this.routerIp, peerId.getValue());
    } else {
        LOG.debug("Peer: {} for Router: {} already exists.", peerId.getValue(), this.routerIp);
    }
}
Also used : BmpRouterPeer(org.opendaylight.protocol.bmp.impl.spi.BmpRouterPeer) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)

Aggregations

PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)11 Test (org.junit.Test)7 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)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.rev171207.path.attributes.AttributesBuilder)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)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 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)2 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)2 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.rev171207.rib.TablesKey)2 BgpNeighbor (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp._default.policy.rev180109.BgpNeighbor)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Optional (com.google.common.base.Optional)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1