Search in sources :

Example 36 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.

the class AbstractTeLspNlriCodec method serializeTeLsp.

public static TeLspCase serializeTeLsp(final ChoiceNode objectType) {
    final TeLspCaseBuilder teLsp = new TeLspCaseBuilder();
    teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
    teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
    final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
    teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
    return teLsp.build();
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) TeLspCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCaseBuilder) TunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)

Example 37 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project netvirt by opendaylight.

the class VpnInstanceListener method addBgpVrfTableForVpn.

@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void addBgpVrfTableForVpn(VpnInstance vpnInstance, String vpnName, List<String> vpnInstanceUpdatedRdList, boolean isVpnInstanceRdUpdated) {
    String primaryRd = vpnUtil.getPrimaryRd(vpnName);
    Collection<VpnTarget> vpnTargetCollection = (vpnInstance.getVpnTargets() != null) ? vpnInstance.getVpnTargets().getVpnTarget().values() : null;
    List<VpnTarget> vpnTargetList = new ArrayList<VpnTarget>(vpnTargetCollection != null ? vpnTargetCollection : Collections.emptyList());
    List<String> exportRTList = new ArrayList<>();
    List<String> importRTList = new ArrayList<>();
    if (!vpnTargetList.isEmpty()) {
        for (VpnTarget vpnTarget : vpnTargetList) {
            if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.ExportExtcommunity) {
                exportRTList.add(vpnTarget.getVrfRTValue());
            }
            if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.ImportExtcommunity) {
                importRTList.add(vpnTarget.getVrfRTValue());
            }
            if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.Both) {
                exportRTList.add(vpnTarget.getVrfRTValue());
                importRTList.add(vpnTarget.getVrfRTValue());
            }
        }
    }
    synchronized (vpnName.intern()) {
        List<String> rds = Collections.emptyList();
        // Vpn Instance RD Update for ECMP use case
        if (isVpnInstanceRdUpdated) {
            rds = vpnInstanceUpdatedRdList;
        } else {
            rds = vpnInstance.getRouteDistinguisher() != null ? new ArrayList<>(vpnInstance.getRouteDistinguisher()) : new ArrayList<>();
        }
        for (String rd : rds) {
            List<String> irtList = rd.equals(primaryRd) ? importRTList : Collections.emptyList();
            int ipAddrFamilyConfigured = vpnInstance.getIpAddressFamilyConfigured().getIntValue();
            switch(ipAddrFamilyConfigured) {
                case 10:
                    bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV4);
                    bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV6);
                    LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv4andIPv6 AddressFamily ", vpnName, rd, irtList, exportRTList);
                    break;
                case 6:
                    bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV6);
                    LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv6 AddressFamily ", vpnName, rd, irtList, exportRTList);
                    break;
                case 4:
                    bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV4);
                    LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv4 AddressFamily ", vpnName, rd, irtList, exportRTList);
                    break;
                default:
                    break;
            }
            // L2VPN Use case
            if (vpnInstance.isL2vpn()) {
                bgpManager.addVrf(rd, importRTList, exportRTList, AddressFamily.L2VPN);
                LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} RD {}, ImportRTList {}, " + "ExportRTList {} for L2VPN AddressFamily ", vpnName, rd, irtList, exportRTList);
            }
        }
    }
}
Also used : VpnTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.vpn.instance.vpntargets.VpnTarget) ArrayList(java.util.ArrayList) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 38 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily 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);
                replayDone = true;
            } catch (TApplicationException tae) {
                LOG.debug("Replaying addNbr {}, tapplicationexception: ", replayNbr.getNbr().getAddress().getValue(), tae);
                if (tae.getType() == BgpRouterException.BGP_ERR_PEER_EXISTS) {
                    LOG.debug("Replaying addNbr Neighbor already present");
                    replayDone = true;
                } else {
                    LOG.error("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), tae);
                }
            } catch (TException | BgpRouterException eNbr) {
                LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
            }
            LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
            // Update Source handling
            UpdateSource us = replayNbr.getNbr().getUpdateSource();
            if (us != null) {
                LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
                try {
                    br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
                } catch (TException | BgpRouterException eUs) {
                    LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
                }
                LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
            }
            // Ebgp Multihope
            EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
            if (en != null) {
                try {
                    br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
                } catch (TException | BgpRouterException eEbgpMhop) {
                    LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
                }
            }
            // keyAddressFamiliesMap
            Map<AddressFamiliesKey, AddressFamilies> keyAddressFamiliesMap = replayNbr.getNbr().getAddressFamilies();
            if (keyAddressFamiliesMap != null) {
                for (AddressFamilies af : keyAddressFamiliesMap.values()) {
                    af_afi afi = af_afi.findByValue(af.getAfi().intValue());
                    af_safi safi = af_safi.findByValue(af.getSafi().intValue());
                    try {
                        br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
                    } catch (TException | BgpRouterException eAFs) {
                        LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
                    }
                }
            }
            // replay is success --> no need to replay this nbr in next iteration.
            replayNbr.setShouldRetry(replayDone ? false : true);
        }
    } while (nbrRetry.decrementAndRetry());
    boolean replaySuccess = true;
    for (ReplayNbr replayNbr : replayNbrList) {
        replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
        if (replaySuccess == false) {
            LOG.error("replayNbrConfig: will be cancelling stale cleanup, cfg nbr: {} Failed:", replayNbr.getNbr().getAddress().getValue());
        }
    }
    return replaySuccess;
}
Also used : TException(org.apache.thrift.TException) AddressFamiliesKey(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.neighbors.AddressFamiliesKey) ArrayList(java.util.ArrayList) Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors) EbgpMultihop(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.neighbors.EbgpMultihop) TApplicationException(org.apache.thrift.TApplicationException) 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.neighborscontainer.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.neighborscontainer.neighbors.UpdateSource)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)10 ArrayList (java.util.ArrayList)10 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)6 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.AddressFamily)6 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)6 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)6 Test (org.junit.Test)5 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)4 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiers)3 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)3 Preconditions (com.google.common.base.Preconditions)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)2 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)2 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)2 VrfsContainer (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.VrfsContainer)2 Vrfs (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.Vrfs)2 VrfsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.VrfsKey)2