Search in sources :

Example 1 with RibKey

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

the class StateProviderImplTest method setUp.

@Before
public void setUp() {
    doReturn(IPV4UNICAST.class).when(this.tableTypeRegistry).getAfiSafiType(eq(TABLES_KEY));
    doReturn(this.bgpRibStates).when(this.stateProvider).getRibStats();
    doReturn(this.bgpPeerStates).when(this.stateProvider).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 -> Map.of(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(10L).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).isLocalRestarting();
    doReturn(true).when(this.bgpGracelfulRestartState).isPeerRestarting();
    doReturn(this.restartTime.toJava()).when(this.bgpGracelfulRestartState).getPeerRestartTime();
    doReturn(BgpAfiSafiGracefulRestartState.Mode.BILATERAL).when(this.bgpGracelfulRestartState).getMode();
    doReturn(this.bgpAfiSafiState).when(this.bgpPeerState).getBGPAfiSafiState();
    doReturn(Set.of(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
    doReturn(Set.of(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());
    doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartAdvertised(any());
    doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartReceived(any());
    doReturn(60).when(this.bgpAfiSafiState).getLlGracefulRestartTimer(any());
}
Also used : RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib) Before(org.junit.Before)

Example 2 with RibKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.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.augmentation(Topology1.class).getRibId())));
    final AbstractTopologyBuilder<?> topologyBuilder = createTopologyBuilder(dataBroker, ribReference, topology.getTopologyId());
    return new TopologyReferenceSingletonServiceImpl(topologyBuilder, deployer, topology);
}
Also used : RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib) DefaultRibReference(org.opendaylight.protocol.bgp.rib.DefaultRibReference) DefaultRibReference(org.opendaylight.protocol.bgp.rib.DefaultRibReference) RibReference(org.opendaylight.protocol.bgp.rib.RibReference)

Example 3 with RibKey

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

the class AbstractConfig method setUp.

@Override
@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.rev180329.bgp.rib.Rib.class, new RibKey(RIB_ID))).when(this.rib).getInstanceIdentifier();
    doReturn(this.domTx).when(this.rib).createPeerDOMChain(any(DOMTransactionChainListener.class));
    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));
    doReturn(CommitInfo.emptyFluentFuture()).when(this.domDW).commit();
    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), any(), anyInt(), any(KeyMapping.class));
    doReturn(this.dispatcher).when(this.rib).getDispatcher();
    doReturn(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)).when(this.tableTypeRegistry).getTableType(any());
    doReturn(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(IpAddressNoZone.class), any(BGPSessionListener.class), any(BGPSessionPreferences.class));
    doNothing().when(this.bgpPeerRegistry).removePeer(any(IpAddressNoZone.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) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) BGPSessionPreferences(org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) RIBSupportContextRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.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.rev200120.BgpId) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) Before(org.junit.Before)

Aggregations

BgpRib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.BgpRib)3 RibKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey)3 Before (org.junit.Before)2 Rib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib)2 InetSocketAddress (java.net.InetSocketAddress)1 DOMTransactionChainListener (org.opendaylight.mdsal.dom.api.DOMTransactionChainListener)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 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Rib (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Rib)1 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)1 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId)1 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)1 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1