Search in sources :

Example 11 with AddressFamilies

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;
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies) BgpNeighborAddPathsConfig(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighborAddPathsConfig) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) ArrayList(java.util.ArrayList) AddressFamiliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamiliesBuilder)

Example 12 with AddressFamilies

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));
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies) MultiPathSupport(org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) Test(org.junit.Test)

Example 13 with AddressFamilies

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);
}
Also used : 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) AddPathCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler) 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) ArrayList(java.util.ArrayList) AddressFamiliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamiliesBuilder) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 14 with AddressFamilies

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);
}
Also used : 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) AddPathCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler) 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) ArrayList(java.util.ArrayList) AddressFamiliesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamiliesBuilder) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 15 with AddressFamilies

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;
}
Also used : TException(org.apache.thrift.TException) ArrayList(java.util.ArrayList) Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors) EbgpMultihop(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.EbgpMultihop) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) AddressFamilies(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi) UpdateSource(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.UpdateSource)

Aggregations

ArrayList (java.util.ArrayList)11 AddressFamilies (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies)11 CParameters1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1)7 Test (org.junit.Test)6 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)6 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder)6 AddPathCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapabilityBuilder)6 AddressFamiliesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamiliesBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)5 CParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParameters)5 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)5 AddPathCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.AddPathCapabilityHandler)4 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)3 Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors)3 AddressFamilies (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighbors.AddressFamilies)3 SendReceive (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.SendReceive)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 List (java.util.List)2 Set (java.util.Set)2 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)2