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));
}
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();
}
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();
}
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;
}
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());
}
Aggregations