use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies 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;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class MultiPathSupportImplTest method testIsTableTypeSupported.
@Test
public void testIsTableTypeSupported() {
final List<AddressFamilies> supportedTables = Lists.newArrayList();
final BgpTableType ipv4Unicast = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
final BgpTableType ipv4L3vpn = new BgpTableTypeImpl(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
final BgpTableType ipv6Unicast = new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
final BgpTableType ipv6L3vpn = new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
supportedTables.add(createAddPathCapability(ipv4Unicast, SendReceive.Send));
supportedTables.add(createAddPathCapability(ipv4L3vpn, SendReceive.Receive));
supportedTables.add(createAddPathCapability(ipv6Unicast, SendReceive.Both));
final MultiPathSupport multiPathSupport = MultiPathSupportImpl.createParserMultiPathSupport(supportedTables);
Assert.assertTrue(multiPathSupport.isTableTypeSupported(ipv4Unicast));
Assert.assertTrue(multiPathSupport.isTableTypeSupported(ipv6Unicast));
Assert.assertFalse(multiPathSupport.isTableTypeSupported(ipv4L3vpn));
Assert.assertFalse(multiPathSupport.isTableTypeSupported(ipv6L3vpn));
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledSafi.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledSafi() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(3)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safirException);
handler.serializeCapability(capabilityToSerialize, bytes);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledAfi.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledAfi() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(2)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afirExpection, this.safiRegistry);
handler.serializeCapability(capabilityToSerialize, bytes);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies in project netvirt by opendaylight.
the class BgpConfigurationManager method replayNbrConfig.
private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
if (neighbors == null || neighbors.isEmpty()) {
LOG.error("Replaying nbr configuration, received NULL list ");
return true;
}
List<ReplayNbr> replayNbrList = new ArrayList<>();
for (Neighbors nbr : neighbors) {
if (nbr != null) {
replayNbrList.add(new ReplayNbr(nbr, true));
}
}
final int numberOfNbrRetries = 3;
RetryOnException nbrRetry = new RetryOnException(numberOfNbrRetries);
do {
for (ReplayNbr replayNbr : replayNbrList) {
if (!replayNbr.isShouldRetry()) {
continue;
}
boolean replayDone = false;
LOG.debug("Replaying addNbr {}", replayNbr.getNbr().getAddress().getValue());
replayDone = false;
try {
final String md5password = extractMd5Secret(replayNbr.getNbr());
br.addNeighbor(replayNbr.getNbr().getAddress().getValue(), replayNbr.getNbr().getRemoteAs().longValue(), md5password);
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (us != null) {
LOG.debug("Replaying updatesource along with nbr: {} US-ip: {} to peer {}", replayNbr.getNbr().getAddress().getValue(), us.getSourceIp().getValue(), us.getPeerIp().getValue());
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
}
replayDone = true;
} catch (TException | BgpRouterException eNbr) {
LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
}
boolean replaySuccess = true;
replaySuccess = replaySuccess && replayDone;
LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
// Update Source handling
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (replayDone == false && us != null) {
LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
replayDone = false;
try {
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
replayDone = true;
} catch (TException | BgpRouterException eUs) {
LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
}
LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
replaySuccess = replaySuccess && replayDone;
}
// Ebgp Multihope
EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
if (en != null) {
replayDone = false;
try {
br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
replayDone = true;
} catch (TException | BgpRouterException eEbgpMhop) {
LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
}
replaySuccess = replaySuccess && replayDone;
}
// afs
List<AddressFamilies> afs = replayNbr.getNbr().getAddressFamilies();
if (afs != null) {
for (AddressFamilies af : afs) {
af_afi afi = af_afi.findByValue(af.getAfi().intValue());
af_safi safi = af_safi.findByValue(af.getSafi().intValue());
replayDone = false;
try {
br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
replayDone = true;
} catch (TException | BgpRouterException eAFs) {
LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
}
replaySuccess = replaySuccess && replayDone;
}
}
// replay is success --> no need to replay this nbr in next iteration.
replayNbr.setShouldRetry(replaySuccess ? false : true);
}
} while (nbrRetry.decrementAndRetry());
boolean replaySuccess = true;
for (ReplayNbr replayNbr : replayNbrList) {
replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
}
return replaySuccess;
}
Aggregations