Search in sources :

Example 36 with AddressFamily

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.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.opendaylight.params.xml.ns.yang.bgp.types.rev130919.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);
                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

ByteBuf (io.netty.buffer.ByteBuf)10 ArrayList (java.util.ArrayList)9 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.controller.md.sal.common.api.data.TransactionCommitFailedException)2 NextHopParserSerializer (org.opendaylight.protocol.bgp.parser.spi.NextHopParserSerializer)2 NlriParser (org.opendaylight.protocol.bgp.parser.spi.NlriParser)2 Bgp (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)2 Vrfs (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Vrfs)2 VrfsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.VrfsKey)2