Search in sources :

Example 1 with RibKey

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

the class AbstractBgpTopologyProvider method createInstance.

private TopologyReferenceSingletonService createInstance(final Topology topology) {
    final RibReference ribReference = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(topology.getAugmentation(Topology1.class).getRibId())));
    final AbstractTopologyBuilder<?> topologyBuilder = createTopologyBuilder(this.dataBroker, ribReference, topology.getTopologyId());
    return new TopologyReferenceSingletonServiceImpl(topologyBuilder, this.deployer, topology);
}
Also used : RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib) DefaultRibReference(org.opendaylight.protocol.bgp.rib.DefaultRibReference) DefaultRibReference(org.opendaylight.protocol.bgp.rib.DefaultRibReference) RibReference(org.opendaylight.protocol.bgp.rib.RibReference)

Example 2 with RibKey

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

the class StateProviderImplTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doReturn(Optional.of(IPV4UNICAST.class)).when(this.tableTypeRegistry).getAfiSafiType(eq(TABLES_KEY));
    doReturn(this.bgpRibStates).when(this.stateCollector).getRibStats();
    doReturn(this.bgpPeerStates).when(this.stateCollector).getPeerStats();
    final KeyedInstanceIdentifier<Rib, RibKey> iid = InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(new RibId(this.ribId)));
    doReturn(iid).when(this.bgpRibState).getInstanceIdentifier();
    doReturn(this.as).when(this.bgpRibState).getAs();
    doReturn(this.bgpId).when(this.bgpRibState).getRouteId();
    doAnswer(invocation -> this.totalPathsCounter.longValue()).when(this.bgpRibState).getTotalPathsCount();
    doAnswer(invocation -> this.totalPrefixesCounter.longValue()).when(this.bgpRibState).getTotalPrefixesCount();
    doAnswer(invocation -> this.totalPathsCounter.longValue()).when(this.bgpRibState).getPathCount(eq(TABLES_KEY));
    doAnswer(invocation -> this.totalPrefixesCounter.longValue()).when(this.bgpRibState).getPrefixesCount(eq(TABLES_KEY));
    doAnswer(invocation -> Collections.singletonMap(TABLES_KEY, this.totalPrefixesCounter.longValue())).when(this.bgpRibState).getTablesPrefixesCount();
    doAnswer(invocation -> Collections.singletonMap(TABLES_KEY, this.totalPathsCounter.longValue())).when(this.bgpRibState).getPathsCount();
    // Mock Peer
    doReturn("test-group").when(this.bgpPeerState).getGroupId();
    doReturn(iid).when(this.bgpPeerState).getInstanceIdentifier();
    doAnswer(invocation -> this.totalPrefixesCounter.longValue()).when(this.bgpPeerState).getTotalPrefixes();
    doAnswer(invocation -> this.totalPathsCounter.longValue()).when(this.bgpPeerState).getTotalPathsCount();
    doReturn(this.neighborAddress).when(this.bgpPeerState).getNeighborAddress();
    doReturn(this.bgpSessionState).when(this.bgpPeerState).getBGPSessionState();
    doReturn(this.bgpPeerMessagesState).when(this.bgpPeerState).getBGPPeerMessagesState();
    doReturn(1L).when(this.bgpPeerMessagesState).getNotificationMessagesReceivedCount();
    doReturn(1L).when(this.bgpPeerMessagesState).getNotificationMessagesSentCount();
    doReturn(1L).when(this.bgpPeerMessagesState).getUpdateMessagesReceivedCount();
    doReturn(1L).when(this.bgpPeerMessagesState).getUpdateMessagesSentCount();
    doReturn(State.UP).when(this.bgpSessionState).getSessionState();
    doReturn(true).when(this.bgpSessionState).isAddPathCapabilitySupported();
    doReturn(true).when(this.bgpSessionState).isAsn32CapabilitySupported();
    doReturn(true).when(this.bgpSessionState).isGracefulRestartCapabilitySupported();
    doReturn(true).when(this.bgpSessionState).isMultiProtocolCapabilitySupported();
    doReturn(true).when(this.bgpSessionState).isRouterRefreshCapabilitySupported();
    doReturn(this.timersState).when(this.bgpPeerState).getBGPTimersState();
    doReturn(10L).when(this.timersState).getNegotiatedHoldTime();
    doReturn(1L).when(this.timersState).getUpTime();
    doReturn(this.bgpTransportState).when(this.bgpPeerState).getBGPTransportState();
    doReturn(this.localPort).when(this.bgpTransportState).getLocalPort();
    doReturn(this.neighborAddress).when(this.bgpTransportState).getRemoteAddress();
    doReturn(this.remotePort).when(this.bgpTransportState).getRemotePort();
    doReturn(this.bgpErrorHandlingState).when(this.bgpPeerState).getBGPErrorHandlingState();
    doReturn(1L).when(this.bgpErrorHandlingState).getErroneousUpdateReceivedCount();
    doReturn(this.bgpGracelfulRestartState).when(this.bgpPeerState).getBGPGracelfulRestart();
    doReturn(true).when(this.bgpGracelfulRestartState).isGracefulRestartAdvertized(any());
    doReturn(true).when(this.bgpGracelfulRestartState).isGracefulRestartReceived(any());
    doReturn(true).when(this.bgpGracelfulRestartState).isLocalRestarting();
    doReturn(true).when(this.bgpGracelfulRestartState).isPeerRestarting();
    doReturn(this.restartTime).when(this.bgpGracelfulRestartState).getPeerRestartTime();
    doReturn(this.bgpAfiSafiState).when(this.bgpPeerState).getBGPAfiSafiState();
    doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
    doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisReceived();
    doReturn(1L).when(this.bgpAfiSafiState).getPrefixesInstalledCount(any());
    doReturn(2L).when(this.bgpAfiSafiState).getPrefixesReceivedCount(any());
    doReturn(1L).when(this.bgpAfiSafiState).getPrefixesSentCount(any());
    doReturn(true).when(this.bgpAfiSafiState).isAfiSafiSupported(any());
    doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartAdvertized(any());
    doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartReceived(any());
}
Also used : RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Before(org.junit.Before)

Example 3 with RibKey

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

the class AbstractConfig method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    doReturn(InstanceIdentifier.create(BgpRib.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib.class, new RibKey(RIB_ID))).when(this.rib).getInstanceIdentifier();
    doReturn(this.domTx).when(this.rib).createPeerDOMChain(any(TransactionChainListener.class));
    doAnswer(invocation -> {
        final Object[] args = invocation.getArguments();
        return getDataBroker().createTransactionChain((TransactionChainListener) args[0]);
    }).when(this.rib).createPeerChain(any(TransactionChainListener.class));
    doReturn(getDataBroker()).when(this.rib).getDataBroker();
    doReturn(AS).when(this.rib).getLocalAs();
    doReturn(mock(RIBSupportContextRegistry.class)).when(this.rib).getRibSupportContext();
    doReturn(Collections.emptySet()).when(this.rib).getLocalTablesKeys();
    doNothing().when(this.domTx).close();
    doReturn(this.domDW).when(this.domTx).newWriteOnlyTransaction();
    doNothing().when(this.domDW).put(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(MapEntryNode.class));
    doNothing().when(this.domDW).delete(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
    doNothing().when(this.domDW).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    final CheckedFuture<?, ?> checkedFuture = mock(CheckedFuture.class);
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(checkedFuture).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
    doReturn(checkedFuture).when(this.domDW).submit();
    doReturn(null).when(checkedFuture).checkedGet();
    doReturn(null).when(checkedFuture).get();
    doReturn(true).when(checkedFuture).isDone();
    doReturn("checkedFuture").when(checkedFuture).toString();
    doReturn(YangInstanceIdentifier.of(Rib.QNAME)).when(this.rib).getYangRibId();
    doReturn(this.dataTreeChangeService).when(this.rib).getService();
    doReturn(this.listener).when(this.dataTreeChangeService).registerDataTreeChangeListener(any(), any());
    doReturn(new BgpId("127.0.0.1")).when(this.rib).getBgpIdentifier();
    doReturn(true).when(this.future).cancel(true);
    doReturn(this.future).when(this.dispatcher).createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(KeyMapping.class));
    doReturn(this.dispatcher).when(this.rib).getDispatcher();
    doReturn(java.util.Optional.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))).when(this.tableTypeRegistry).getTableType(any());
    doReturn(java.util.Optional.of(TABLES_KEY)).when(this.tableTypeRegistry).getTableKey(any());
    doReturn(Collections.singleton(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))).when(this.rib).getLocalTables();
    doNothing().when(this.bgpPeerRegistry).addPeer(any(IpAddress.class), any(BGPSessionListener.class), any(BGPSessionPreferences.class));
    doNothing().when(this.bgpPeerRegistry).removePeer(any(IpAddress.class));
    doReturn("registry").when(this.bgpPeerRegistry).toString();
    doNothing().when(this.listener).close();
    doReturn(this.bgpPeerRegistry).when(this.dispatcher).getBGPPeerRegistry();
    doReturn(this.peerTracker).when(this.rib).getPeerTracker();
    doReturn(this.policies).when(this.rib).getRibPolicies();
    doReturn(null).when(this.peerGroupLoader).getPeerGroup(any(InstanceIdentifier.class), any(String.class));
}
Also used : BGPSessionListener(org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener) InetSocketAddress(java.net.InetSocketAddress) Executor(java.util.concurrent.Executor) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) RIBSupportContextRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) Before(org.junit.Before)

Aggregations

BgpRib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib)3 RibKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.RibKey)3 Before (org.junit.Before)2 Rib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib)2 InetSocketAddress (java.net.InetSocketAddress)1 Executor (java.util.concurrent.Executor)1 TransactionChainListener (org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener)1 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)1 DefaultRibReference (org.opendaylight.protocol.bgp.rib.DefaultRibReference)1 RibReference (org.opendaylight.protocol.bgp.rib.RibReference)1 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)1 RIBSupportContextRegistry (org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry)1 BGPSessionListener (org.opendaylight.protocol.bgp.rib.spi.BGPSessionListener)1 KeyMapping (org.opendaylight.protocol.concepts.KeyMapping)1 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Rib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Rib)1 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId)1 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1