Search in sources :

Example 11 with BgpTableType

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

the class OpenConfigMappingUtilTest method toPathSelectionMode.

@Test
public void toPathSelectionMode() {
    final List<AfiSafi> families = new ArrayList<>();
    families.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).addAugmentation(new GlobalAddPathsConfigBuilder().setSendMax(N_PATHS).build()).build());
    families.add(new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class).addAugmentation(new GlobalAddPathsConfigBuilder().setSendMax(ALL_PATHS).build()).build());
    final Map<BgpTableType, PathSelectionMode> result = OpenConfigMappingUtil.toPathSelectionMode(families, tableTypeRegistry);
    final Map<BgpTableType, PathSelectionMode> expected = new HashMap<>();
    expected.put(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class), ADD_PATH_BEST_N_PATH_SELECTION);
    expected.put(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class), ADD_PATH_BEST_ALL_PATH_SELECTION);
    // FIXME: these assertions are wrong, as they perform lookup on non-existing keys
    assertEquals(expected.get(0), result.get(0));
    assertEquals(expected.get(1), result.get(1));
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily) HashMap(java.util.HashMap) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) BgpPeerTest.createAfiSafi(org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createAfiSafi) ArrayList(java.util.ArrayList) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GlobalAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.GlobalAddPathsConfigBuilder) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST) IPV6UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 12 with BgpTableType

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

the class AbstractRIBTestSetup method mockRib.

public void mockRib() throws Exception {
    final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
    final List<BgpTableType> localTables = new ArrayList<>();
    localTables.add(new BgpTableTypeImpl(IPV4_AFI, SAFI));
    localTables.add(new BgpTableTypeImpl(IPV6_AFI, SAFI));
    final CurrentAdapterSerializer serializer = mappingService.currentSerializer();
    this.a1.startRIBExtensionProvider(context, serializer);
    mockedMethods();
    doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(Uint32.valueOf(5)), RIB_ID, context, this.dispatcher, new ConstantCodecsRegistry(serializer), this.dom, this.policies, localTables, Collections.singletonMap(KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) CurrentAdapterSerializer(org.opendaylight.mdsal.binding.dom.adapter.CurrentAdapterSerializer) ArrayList(java.util.ArrayList) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 13 with BgpTableType

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

the class EventBusRegistration method sendMessage.

private static void sendMessage(final BGPSessionListener listener, final Notification message) {
    if (BGPMock.CONNECTION_LOST_MAGIC_MSG.equals(message)) {
        listener.onSessionTerminated(null, new BGPTerminationReason(BGPError.CEASE));
    } else if (message instanceof Open) {
        final Set<BgpTableType> tts = new HashSet<>();
        final List<AddressFamilies> addPathCapabilitiesList = new ArrayList<>();
        for (final BgpParameters param : ((Open) message).getBgpParameters()) {
            for (final OptionalCapabilities capa : param.getOptionalCapabilities()) {
                final CParameters cParam = capa.getCParameters();
                final CParameters1 aug = cParam.augmentation(CParameters1.class);
                if (aug == null) {
                    continue;
                }
                if (aug.getMultiprotocolCapability() != null) {
                    final MultiprotocolCapability p = aug.getMultiprotocolCapability();
                    LOG.debug("Adding open parameter {}", p);
                    final BgpTableType type = new BgpTableTypeImpl(p.getAfi(), p.getSafi());
                    tts.add(type);
                } else if (aug.getAddPathCapability() != null) {
                    final AddPathCapability addPathCap = aug.getAddPathCapability();
                    addPathCapabilitiesList.addAll(addPathCap.getAddressFamilies());
                }
            }
        }
        listener.onSessionUp(new MockBGPSession(tts, addPathCapabilitiesList));
    } else if (!(message instanceof Keepalive)) {
        try {
            listener.onMessage(new MockBGPSession(), message);
        } catch (BGPDocumentedException e) {
            LOG.warn("Exception encountered while handling message", e);
        }
    }
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) HashSet(java.util.HashSet) Set(java.util.Set) Keepalive(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Keepalive) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities) BGPTerminationReason(org.opendaylight.protocol.bgp.rib.spi.BGPTerminationReason) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapability) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) AddPathCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.AddPathCapability) ArrayList(java.util.ArrayList) List(java.util.List) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 14 with BgpTableType

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

the class SimpleBGPTableTypeRegistryProviderTest method testBGPTableTypeRegistryProvider.

@Test
public void testBGPTableTypeRegistryProvider() {
    final Optional<Class<? extends AfiSafiType>> afiSafiType = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    Assert.assertTrue(afiSafiType.isPresent());
    final Optional<Class<? extends AfiSafiType>> afiSafiType2 = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
    Assert.assertFalse(afiSafiType2.isPresent());
    final Optional<BgpTableType> tableType = this.provider.getTableType(IPV4UNICAST.class);
    Assert.assertTrue(tableType.isPresent());
    final Optional<BgpTableType> tableType2 = this.provider.getTableType(IPV6UNICAST.class);
    Assert.assertFalse(tableType2.isPresent());
    this.registration.close();
    final Optional<BgpTableType> tableType3 = this.provider.getTableType(IPV4UNICAST.class);
    Assert.assertFalse(tableType3.isPresent());
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 15 with BgpTableType

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

the class TableTypeActivatorTest method testActivator.

@Test
public void testActivator() {
    final TableTypeActivator tableTypeActivator = new TableTypeActivator();
    final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
    tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
    final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(EVPN);
    Assert.assertEquals(L2VPNEVPN.class, afiSafiType.get());
    final Optional<BgpTableType> tableType = registry.getTableType(L2VPNEVPN.class);
    Assert.assertEquals(EVPN, tableType.get());
    tableTypeActivator.stopBGPTableTypeRegistryProvider();
    tableTypeActivator.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) SimpleBGPTableTypeRegistryProvider(org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType) Test(org.junit.Test)

Aggregations

BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType)24 Test (org.junit.Test)16 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)12 ArrayList (java.util.ArrayList)11 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)9 ByteBuf (io.netty.buffer.ByteBuf)8 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)7 HashMap (java.util.HashMap)5 AfiSafiType (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)5 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)5 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily)5 HashSet (java.util.HashSet)4 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)4 SimpleBGPTableTypeRegistryProvider (org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider)4 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters)4 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities)4 AddressFamilies (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies)4 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)3 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)3 BgpNeighborAddPathsConfig (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighborAddPathsConfig)3