use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi in project bgpcep by opendaylight.
the class GlobalUtil method buildAfiSafi.
/**
* Build Afi Safi containing State.
*
* @param ribState containing RIb Operational State
* @param tablesKey table Key
* @param bgpTableTypeRegistry BGP TableType Registry
* @return Afi Safi Operational State
*/
public static AfiSafi buildAfiSafi(final BGPRibState ribState, final TablesKey tablesKey, final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
final Optional<Class<? extends AfiSafiType>> optAfiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
if (!optAfiSafi.isPresent()) {
return null;
}
final State state = new StateBuilder().addAugmentation(GlobalAfiSafiStateAugmentation.class, new GlobalAfiSafiStateAugmentationBuilder().setTotalPaths(ribState.getPathCount(tablesKey)).setTotalPrefixes(ribState.getPrefixesCount(tablesKey)).build()).build();
return new AfiSafiBuilder().setAfiSafiName(optAfiSafi.get()).setState(state).build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method toAddPathCapability.
@Test
public void toAddPathCapability() {
final List<AfiSafi> families = new ArrayList<>();
families.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(true).setSendMax(Shorts.checkedCast(ALL_PATHS)).build()).build());
families.add(new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(false).setSendMax(Shorts.checkedCast(N_PATHS)).build()).build());
families.add(new AfiSafiBuilder().setAfiSafiName(IPV6LABELLEDUNICAST.class).addAugmentation(NeighborAddPathsConfig.class, new NeighborAddPathsConfigBuilder().setReceive(false).build()).build());
final List<AddressFamilies> result = OpenConfigMappingUtil.toAddPathCapability(families, this.tableTypeRegistry);
assertEquals(FAMILIES, result);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi 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.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi 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());
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi in project bgpcep by opendaylight.
the class OpenConfigMappingUtil method toAddPathCapability.
public static List<AddressFamilies> toAddPathCapability(final List<AfiSafi> afiSafis, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<AddressFamilies> addPathCapability = new ArrayList<>();
for (final AfiSafi afiSafi : afiSafis) {
final BgpNeighborAddPathsConfig afiSafi1 = afiSafi.getAugmentation(NeighborAddPathsConfig.class);
final Optional<BgpTableType> bgpTableType = tableTypeRegistry.getTableType(afiSafi.getAfiSafiName());
if (afiSafi1 != null && bgpTableType.isPresent()) {
final AddressFamiliesBuilder builder = new AddressFamiliesBuilder(bgpTableType.get());
builder.setSendReceive(toSendReceiveMode(afiSafi1));
addPathCapability.add(builder.build());
}
}
return addPathCapability;
}
Aggregations