Search in sources :

Example 1 with AfiSafis

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetAfiSafiWithDefault.

@Test
public void testGetAfiSafiWithDefault() {
    final ImmutableList<AfiSafi> defaultValue = ImmutableList.of(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build());
    assertEquals(defaultValue, OpenConfigMappingUtil.getAfiSafiWithDefault(null, true));
    final AfiSafis afiSafi = new AfiSafisBuilder().build();
    assertEquals(defaultValue, OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafi, true));
    final AfiSafi afiSafiIpv6 = new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(true).setSendMax(SHORT).build()).build();
    final List<AfiSafi> afiSafiIpv6List = new ArrayList<>();
    afiSafiIpv6List.add(afiSafiIpv6);
    final List<AfiSafi> expected = new ArrayList<>(afiSafiIpv6List);
    expected.add(AFI_SAFI_IPV4);
    assertEquals(afiSafiIpv6, OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder().setAfiSafi(afiSafiIpv6List).build(), true).get(0));
    assertEquals(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build(), OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder().setAfiSafi(afiSafiIpv6List).build(), true).get(1));
    assertEquals(AFI_SAFI, OpenConfigMappingUtil.getAfiSafiWithDefault(createAfiSafi(), true));
    assertTrue(OpenConfigMappingUtil.getAfiSafiWithDefault(null, false).isEmpty());
    assertTrue(OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafi, false).isEmpty());
    assertEquals(afiSafiIpv6, OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder().setAfiSafi(afiSafiIpv6List).build(), false).get(0));
    assertEquals(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build(), OpenConfigMappingUtil.getAfiSafiWithDefault(new AfiSafisBuilder().setAfiSafi(afiSafiIpv6List).build(), false).get(1));
    assertEquals(AFI_SAFI, OpenConfigMappingUtil.getAfiSafiWithDefault(createAfiSafi(), false));
}
Also used : NeighborAddPathsConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfig) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) 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) AfiSafisBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder) ArrayList(java.util.ArrayList) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis) NeighborAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder) Test(org.junit.Test)

Example 2 with AfiSafis

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis in project bgpcep by opendaylight.

the class StateProviderImplTest method testActiveStateProvider.

@Test
public void testActiveStateProvider() throws Exception {
    doReturn(true).when(this.bgpRibState).isActive();
    doReturn(true).when(this.bgpPeerState).isActive();
    final StateProviderImpl stateProvider = new StateProviderImpl(getDataBroker(), 1, this.tableTypeRegistry, this.stateCollector, "global-bgp");
    stateProvider.init();
    final Global globalExpected = buildGlobalExpected(0);
    this.bgpRibStates.add(this.bgpRibState);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected, global);
        return bgpRib;
    });
    this.totalPathsCounter.increment();
    this.totalPrefixesCounter.increment();
    final Global globalExpected2 = buildGlobalExpected(1);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected2, global);
        return bgpRib;
    });
    this.totalPathsCounter.decrement();
    this.totalPrefixesCounter.decrement();
    final Global globalExpected3 = buildGlobalExpected(0);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected3, global);
        Assert.assertNull(bgpRib.getNeighbors());
        Assert.assertNull(bgpRib.getPeerGroups());
        return bgpRib;
    });
    this.bgpPeerStates.add(this.bgpPeerState);
    final PeerGroup peerGroupExpected = buildGroupExpected();
    this.totalPathsCounter.increment();
    this.totalPrefixesCounter.increment();
    final AfiSafis expectedAfiSafis = buildAfiSafis();
    final ErrorHandling expectedErrorHandling = buildErrorHandling();
    final GracefulRestart expectedGracefulRestart = buildGracefulRestart();
    final Transport expectedTransport = buildTransport();
    final Timers expectedTimers = buildTimers();
    final BgpNeighborStateAugmentation expectedBgpNeighborState = buildBgpNeighborStateAugmentation();
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Neighbors neighbors = bgpRib.getNeighbors();
        Assert.assertNotNull(neighbors);
        assertEquals(peerGroupExpected, bgpRib.getPeerGroups().getPeerGroup().get(0));
        final Neighbor neighborResult = neighbors.getNeighbor().get(0);
        assertEquals(this.neighborAddress, neighborResult.getNeighborAddress());
        assertEquals(expectedAfiSafis, neighborResult.getAfiSafis());
        assertEquals(expectedErrorHandling, neighborResult.getErrorHandling());
        assertEquals(expectedGracefulRestart, neighborResult.getGracefulRestart());
        assertEquals(expectedTransport, neighborResult.getTransport());
        assertEquals(expectedTimers, neighborResult.getTimers());
        final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State stateResult = neighborResult.getState();
        assertEquals(expectedBgpNeighborState, stateResult.getAugmentation(BgpNeighborStateAugmentation.class));
        assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.getAugmentation(NeighborStateAugmentation.class).getSessionState());
        final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.getAugmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
        Assert.assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
        return bgpRib;
    });
    this.bgpRibStates.clear();
    checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
    stateProvider.close();
}
Also used : ErrorHandling(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling) PeerGroup(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup) Neighbors(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) BgpCapability(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) GracefulRestart(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart) Transport(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation) NeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborStateAugmentation) Timers(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 3 with AfiSafis

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis in project bgpcep by opendaylight.

the class StateProviderImplTest method buildAfiSafis.

private static AfiSafis buildAfiSafis() {
    final NeighborAfiSafiStateAugmentationBuilder neighborAfiSafiStateAugmentation = new NeighborAfiSafiStateAugmentationBuilder().setActive(true).setPrefixes(new PrefixesBuilder().setSent(1L).setReceived(2L).setInstalled(1L).build());
    final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setGracefulRestart(new GracefulRestartBuilder().setState(new StateBuilder().setEnabled(false).addAugmentation(NeighborAfiSafiGracefulRestartStateAugmentation.class, new NeighborAfiSafiGracefulRestartStateAugmentationBuilder().setAdvertised(true).setReceived(true).build()).build()).build()).setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder().setEnabled(false).addAugmentation(NeighborAfiSafiStateAugmentation.class, neighborAfiSafiStateAugmentation.build()).build()).build();
    return new AfiSafisBuilder().setAfiSafi(Collections.singletonList(afiSafi)).build();
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder) NeighborAfiSafiGracefulRestartStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiGracefulRestartStateAugmentationBuilder) GracefulRestartBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) NeighborAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiStateAugmentationBuilder) PrefixesBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder) AfiSafisBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder) NeighborAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiStateAugmentation) IPV4UNICAST(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)

Example 4 with AfiSafis

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis in project bgpcep by opendaylight.

the class BgpPeer method getBgpParameters.

private static List<BgpParameters> getBgpParameters(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    final List<BgpParameters> tlvs = new ArrayList<>();
    final List<OptionalCapabilities> caps = new ArrayList<>();
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
    final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false);
    final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
    if (!addPathCapability.isEmpty()) {
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
    }
    final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
    for (final BgpTableType tableType : tableTypes) {
        if (!rib.getLocalTables().contains(tableType)) {
            LOG.info("RIB instance does not list {} " + "in its local tables. Incoming data will be dropped.", tableType);
        }
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
    }
    tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
    return tlvs;
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder) MultiprotocolCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) ArrayList(java.util.ArrayList) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) BgpParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities) As4BytesCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies) AddPathCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapabilityBuilder)

Example 5 with AfiSafis

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis in project bgpcep by opendaylight.

the class BgpPeer method containsEqualConfiguration.

@Override
public synchronized Boolean containsEqualConfiguration(final Neighbor neighbor) {
    if (this.currentConfiguration == null) {
        return false;
    }
    final AfiSafis actAfiSafi = this.currentConfiguration.getAfiSafis();
    final AfiSafis extAfiSafi = neighbor.getAfiSafis();
    final List<AfiSafi> actualSafi = actAfiSafi != null ? actAfiSafi.getAfiSafi() : Collections.emptyList();
    final List<AfiSafi> extSafi = extAfiSafi != null ? extAfiSafi.getAfiSafi() : Collections.emptyList();
    return actualSafi.containsAll(extSafi) && extSafi.containsAll(actualSafi) && Objects.equals(this.currentConfiguration.getConfig(), neighbor.getConfig()) && Objects.equals(this.currentConfiguration.getNeighborAddress(), neighbor.getNeighborAddress()) && Objects.equals(this.currentConfiguration.getAddPaths(), neighbor.getAddPaths()) && Objects.equals(this.currentConfiguration.getApplyPolicy(), neighbor.getApplyPolicy()) && Objects.equals(this.currentConfiguration.getAsPathOptions(), neighbor.getAsPathOptions()) && Objects.equals(this.currentConfiguration.getEbgpMultihop(), neighbor.getEbgpMultihop()) && Objects.equals(this.currentConfiguration.getGracefulRestart(), neighbor.getGracefulRestart()) && Objects.equals(this.currentConfiguration.getErrorHandling(), neighbor.getErrorHandling()) && Objects.equals(this.currentConfiguration.getLoggingOptions(), neighbor.getLoggingOptions()) && Objects.equals(this.currentConfiguration.getRouteReflector(), neighbor.getRouteReflector()) && Objects.equals(this.currentConfiguration.getState(), neighbor.getState()) && Objects.equals(this.currentConfiguration.getTimers(), neighbor.getTimers()) && Objects.equals(this.currentConfiguration.getTransport(), neighbor.getTransport());
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis)

Aggregations

AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)6 ArrayList (java.util.ArrayList)3 AfiSafis (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis)3 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)3 Test (org.junit.Test)2 AfiSafiBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder)2 BgpNeighborAddPathsConfig (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighborAddPathsConfig)2 AfiSafisBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder)2 AddressFamilies (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies)2 HashMap (java.util.HashMap)1 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)1 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)1 AllPathSelection (org.opendaylight.protocol.bgp.mode.impl.add.all.paths.AllPathSelection)1 AddPathBestNPathSelection (org.opendaylight.protocol.bgp.mode.impl.add.n.paths.AddPathBestNPathSelection)1 BgpPeerTest.createAfiSafi (org.opendaylight.protocol.bgp.rib.impl.config.BgpPeerTest.createAfiSafi)1 GracefulRestartBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.GracefulRestartBuilder)1 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder)1 PrefixesBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder)1 GracefulRestart (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart)1 ErrorHandling (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling)1