Search in sources :

Example 81 with Label

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.Label in project netvirt by opendaylight.

the class L3vpnOverMplsGrePopulator method createOperationalAdjacency.

@Override
public Adjacency createOperationalAdjacency(L3vpnInput input) {
    Adjacency nextHop = input.getNextHop();
    String nextHopIp = input.getNextHopIp();
    String prefix = VpnUtil.getIpPrefix(nextHop.getIpAddress());
    List<String> adjNextHop = nextHop.getNextHopIpList();
    String rd = input.getRd();
    String primaryRd = input.getPrimaryRd();
    String vpnName = input.getVpnName();
    long label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(primaryRd, prefix));
    if (label == VpnConstants.INVALID_LABEL) {
        String error = "Unable to fetch label from Id Manager. Bailing out of creation of operational " + "vpn interface adjacency " + prefix + "for vpn " + vpnName;
        throw new NullPointerException(error);
    }
    List<String> nextHopList = adjNextHop != null && !adjNextHop.isEmpty() ? adjNextHop : nextHopIp == null ? Collections.emptyList() : Collections.singletonList(nextHopIp);
    return new AdjacencyBuilder(nextHop).setLabel(label).setNextHopIpList(nextHopList).setIpAddress(prefix).setVrfId(rd).setKey(new AdjacencyKey(prefix)).setAdjacencyType(nextHop.getAdjacencyType()).setSubnetGatewayMacAddress(nextHop.getSubnetGatewayMacAddress()).build();
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)

Example 82 with Label

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.Label in project netvirt by opendaylight.

the class L3vpnPopulator method addToLabelMapper.

public void addToLabelMapper(Long label, BigInteger dpnId, String prefix, List<String> nextHopIpList, Long vpnId, String vpnInterfaceName, Long elanTag, boolean isSubnetRoute, String rd) {
    Preconditions.checkNotNull(label, "addToLabelMapper: label cannot be null or empty!");
    Preconditions.checkNotNull(prefix, "addToLabelMapper: prefix cannot be null or empty!");
    Preconditions.checkNotNull(vpnId, "addToLabelMapper: vpnId cannot be null or empty!");
    Preconditions.checkNotNull(rd, "addToLabelMapper: rd cannot be null or empty!");
    if (!isSubnetRoute) {
        // NextHop must be present for non-subnetroute entries
        Preconditions.checkNotNull(nextHopIpList, "addToLabelMapper: nextHopIp cannot be null or empty!");
    }
    synchronized (label.toString().intern()) {
        addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            LOG.info("addToLabelMapper: label {} dpn {} prefix {} nexthoplist {} vpnid {} vpnIntfcName {} rd {}" + " elanTag {}", label, dpnId, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            if (dpnId != null) {
                LabelRouteInfoBuilder lriBuilder = new LabelRouteInfoBuilder();
                lriBuilder.setLabel(label).setDpnId(dpnId).setPrefix(prefix).setNextHopIpList(nextHopIpList).setParentVpnid(vpnId).setIsSubnetRoute(isSubnetRoute);
                if (elanTag != null) {
                    lriBuilder.setElanTag(elanTag);
                } else {
                    LOG.warn("addToLabelMapper: elanTag is null for label {} prefix {} rd {} vpnId {}", label, prefix, rd, vpnId);
                }
                if (vpnInterfaceName != null) {
                    lriBuilder.setVpnInterfaceName(vpnInterfaceName);
                } else {
                    LOG.warn("addToLabelMapper: vpn interface is null for label {} prefix {} rd {} vpnId {}", label, prefix, rd, vpnId);
                }
                lriBuilder.setParentVpnRd(rd);
                VpnInstanceOpDataEntry vpnInstanceOpDataEntry = VpnUtil.getVpnInstanceOpData(broker, rd);
                if (vpnInstanceOpDataEntry != null) {
                    List<String> vpnInstanceNames = Collections.singletonList(vpnInstanceOpDataEntry.getVpnInstanceName());
                    lriBuilder.setVpnInstanceList(vpnInstanceNames);
                }
                LabelRouteInfo lri = lriBuilder.build();
                InstanceIdentifier<LabelRouteInfo> lriIid = InstanceIdentifier.builder(LabelRouteMap.class).child(LabelRouteInfo.class, new LabelRouteInfoKey(label)).build();
                tx.merge(LogicalDatastoreType.OPERATIONAL, lriIid, lri, true);
                LOG.info("addToLabelMapper: Added label route info to label {} prefix {} nextHopList {} vpnId {}" + " interface {} rd {} elantag {}", label, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            } else {
                LOG.warn("addToLabelMapper: Can't add entry to label map for label {} prefix {} nextHopList {}" + " vpnId {} interface {} rd {} elantag {}, dpnId is null", label, prefix, nextHopIpList, vpnId, vpnInterfaceName, rd, elanTag);
            }
        }), LOG, "addToLabelMapper");
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) VpnUtil(org.opendaylight.netvirt.vpnmanager.VpnUtil) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) ListenableFutures.addErrorLogging(org.opendaylight.infrautils.utils.concurrent.ListenableFutures.addErrorLogging) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput) VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) List(java.util.List) VrfEntryBase(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.VrfEntryBase) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) SubnetRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRouteBuilder) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) Preconditions(com.google.common.base.Preconditions) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) List(java.util.List) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey)

Example 83 with Label

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.Label in project netvirt by opendaylight.

the class FibEntriesListener method addLabelToVpnInstance.

private void addLabelToVpnInstance(String rd, List<RoutePaths> routePaths) {
    List<Long> labels = routePaths.stream().map(RoutePaths::getLabel).distinct().collect(Collectors.toList());
    VpnInstanceOpDataEntry vpnInstanceOpData = vpnInstanceListener.getVpnInstanceOpData(rd);
    if (vpnInstanceOpData != null) {
        List<Long> routeIds = vpnInstanceOpData.getRouteEntryId() == null ? new ArrayList<>() : vpnInstanceOpData.getRouteEntryId();
        labels.forEach(label -> {
            LOG.debug("Adding label to vpn info - {}", label);
            if (!routeIds.contains(label)) {
                routeIds.add(label);
            }
        });
        TransactionUtil.asyncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(rd), new VpnInstanceOpDataEntryBuilder(vpnInstanceOpData).setRouteEntryId(routeIds).build(), TransactionUtil.DEFAULT_CALLBACK);
    } else {
        LOG.warn("No VPN Instance found for RD: {}", rd);
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths)

Example 84 with Label

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.Label in project netvirt by opendaylight.

the class TunnelInterfaceStateListener method handleTunnelEventForDPNVpn.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPNVpn(StateTunnelList stateTunnelList, Map<Long, String> vpnIdRdMap, TunnelAction tunnelAction, boolean isTepDeletedOnDpn, List<Uuid> subnetList, TunnelEventProcessingMethod method, VpnInterface cfgVpnInterface) {
    String rd;
    String intfName = cfgVpnInterface.getName();
    final BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
    String destTepIp = String.valueOf(stateTunnelList.getDstInfo().getTepIp().getValue());
    String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
    int tunTypeVal = getTunnelType(stateTunnelList);
    BigInteger remoteDpnId = null;
    if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
        remoteDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
    }
    if (cfgVpnInterface.getVpnInstanceNames() == null) {
        LOG.warn("handleTunnelEventForDpn: no vpnName found for interface {}", intfName);
        return;
    }
    for (VpnInstanceNames vpnInstance : cfgVpnInterface.getVpnInstanceNames()) {
        String vpnName = vpnInstance.getVpnName();
        if (method == TunnelEventProcessingMethod.POPULATESUBNETS) {
            Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
            if (opVpnInterface.isPresent() && !opVpnInterface.get().isScheduledForRemove()) {
                VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
                jobCoordinator.enqueueJob("VPNINTERFACE-" + intfName, new UpdateVpnInterfaceOnTunnelEvent(tunnelAction, vpnInterface, stateTunnelList, isTepDeletedOnDpn));
                // Populate the List of subnets
                InstanceIdentifier<PortOpDataEntry> portOpIdentifier = InstanceIdentifier.builder(PortOpData.class).child(PortOpDataEntry.class, new PortOpDataEntryKey(intfName)).build();
                Optional<PortOpDataEntry> optionalPortOp = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, portOpIdentifier);
                if (optionalPortOp.isPresent()) {
                    List<Uuid> subnetIdList = optionalPortOp.get().getSubnetIds();
                    if (subnetIdList != null) {
                        for (Uuid subnetId : subnetIdList) {
                            if (!subnetList.contains(subnetId)) {
                                subnetList.add(subnetId);
                            }
                        }
                    }
                }
                // Populate the map for VpnId-to-Rd
                long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
                rd = VpnUtil.getVpnRd(dataBroker, vpnName);
                vpnIdRdMap.put(vpnId, rd);
            }
        } else if (method == TunnelEventProcessingMethod.MANAGEREMOTEROUTES) {
            Optional<VpnInterfaceOpDataEntry> opVpnInterface = VpnUtil.getVpnInterfaceOpDataEntry(dataBroker, intfName, vpnName);
            if (opVpnInterface.isPresent()) {
                VpnInterfaceOpDataEntry vpnInterface = opVpnInterface.get();
                AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
                List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : Collections.emptyList();
                String prefix = null;
                long vpnId = VpnUtil.getVpnId(dataBroker, vpnInterface.getVpnInstanceName());
                if (vpnIdRdMap.containsKey(vpnId)) {
                    rd = vpnIdRdMap.get(vpnId);
                    LOG.info("handleTunnelEventForDPN: Remote DpnId {} VpnId {} rd {} VpnInterface {} srcTepIp " + "{} destTepIp {}", remoteDpnId, vpnId, rd, vpnInterface, srcTepIp, destTepIp);
                    for (Adjacency adj : adjList) {
                        prefix = adj.getIpAddress();
                        long label = adj.getLabel();
                        if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
                            fibManager.manageRemoteRouteOnDPN(true, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                        }
                        if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
                            fibManager.manageRemoteRouteOnDPN(false, srcDpnId, vpnId, rd, prefix, destTepIp, label);
                        }
                    }
                }
            }
        }
    }
}
Also used : Optional(com.google.common.base.Optional) PortOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntry) PortOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.port.op.data.PortOpDataEntryKey) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstanceNames(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) BigInteger(java.math.BigInteger) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) DcGatewayIpList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 85 with Label

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.Label in project netvirt by opendaylight.

the class BgpConfigurationManager method replay.

@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized boolean replay() throws InterruptedException, TimeoutException, ExecutionException {
    boolean replaySucceded = true;
    String host = getConfigHost();
    int port = getConfigPort();
    LOG.error("connecting  to bgp host {} ", host);
    boolean res = bgpRouter.connect(host, port);
    if (!res) {
        LOG.error("Cannot connect to BGP config server at {}:{}{}", host, port, config != null ? "; Configuration Replay aborted" : "");
        return replaySucceded;
    }
    config = getConfig();
    if (config == null) {
        LOG.error("bgp config is empty nothing to push to bgp");
        return replaySucceded;
    }
    BgpRouter br = bgpRouter;
    AsId asId = config.getAsId();
    if (asId == null) {
        LOG.error("bgp as-id is null");
        return replaySucceded;
    }
    long asNum = asId.getLocalAs();
    IpAddress routerId = asId.getRouterId();
    String rid = routerId == null ? "" : new String(routerId.getValue());
    int stalepathTime = (int) getStalePathtime(RESTART_DEFAULT_GR, config.getAsId());
    boolean announceFbit = true;
    boolean replayDone = false;
    final int numberOfStartBgpRetries = 3;
    RetryOnException startBgpRetry = new RetryOnException(numberOfStartBgpRetries);
    do {
        try {
            LOG.debug("Replaying BGPConfig ");
            br.startBgp(asNum, rid, stalepathTime, announceFbit);
            LOG.debug("Replay BGPConfig successful");
            replayDone = true;
            break;
        } catch (BgpRouterException bre) {
            if (bre.getErrorCode() == BgpRouterException.BGP_ERR_ACTIVE) {
                LOG.debug("Starting the routesync for exception", bre);
                startBgpRetry.errorOccured();
                if (!startBgpRetry.shouldRetry()) {
                    LOG.debug("starting route sync for BgpRouter exception");
                    doRouteSync();
                }
            } else {
                LOG.error("Replay: startBgp() received exception error {} : ", bre.getErrorCode(), bre);
                startBgpRetry.errorOccured();
            }
        } catch (TApplicationException tae) {
            if (tae.getType() == BgpRouterException.BGP_ERR_ACTIVE) {
                LOG.debug("Starting the routesync for exception", tae);
                startBgpRetry.errorOccured();
                if (!startBgpRetry.shouldRetry()) {
                    LOG.debug("starting route sync for Thrift BGP_ERR_ACTIVE exception");
                    doRouteSync();
                }
            } else if (tae.getType() == BgpRouterException.BGP_ERR_COMMON_FAILURE) {
                LOG.debug("Starting the routesync for AS-ID started exception", tae);
                startBgpRetry.errorOccured();
                if (!startBgpRetry.shouldRetry()) {
                    LOG.debug("starting route sync for Thrift BGP_ERR_COMMON_FAILURE exception");
                    doRouteSync();
                }
            } else {
                LOG.error("Replay: startBgp() received exception type {}: ", tae.getType(), tae);
                startBgpRetry.errorOccured();
            }
        } catch (Exception e) {
            // not unusual. We may have restarted & BGP is already on
            LOG.error("Replay:startBgp() received exception: ", e);
            startBgpRetry.errorOccured();
        }
    } while (startBgpRetry.shouldRetry());
    replaySucceded = replayDone;
    startBgpCountersTask();
    startBgpAlarmsTask();
    /*
         * commenting this due to a bug with QBGP. Will uncomment once QBGP fix is done.
         * This wont have any functional impacts
         */
    // try {
    // br.delayEOR(delayEorSeconds);
    // } catch (TException | BgpRouterException e) {
    // LOG.error("Replay: delayEOR() number of seconds to wait for EOR from ODL:", e);
    // }
    List<Neighbors> neighbors = config.getNeighbors();
    if (neighbors != null) {
        LOG.error("configuring existing Neighbors present for replay total neighbors {}", neighbors.size());
        boolean neighborConfigReplayResult = replayNbrConfig(neighbors, br);
        if (neighborConfigReplayResult == false) {
            replaySucceded = false;
        }
    } else {
        LOG.error("no Neighbors present for replay config ");
    }
    Logging logging = config.getLogging();
    if (logging != null) {
        try {
            br.setLogging(logging.getFile(), logging.getLevel());
        } catch (TException | BgpRouterException e) {
            LOG.error("Replay:setLogging() received exception", e);
        }
    }
    GracefulRestart gracefulRestart = config.getGracefulRestart();
    if (gracefulRestart != null) {
        try {
            br.addGracefulRestart(gracefulRestart.getStalepathTime().intValue());
        } catch (TException | BgpRouterException e) {
            LOG.error("Replay:addGr() received exception", e);
        }
    }
    List<Vrfs> vrfs = config.getVrfs();
    if (vrfs == null) {
        vrfs = new ArrayList<>();
    }
    for (Vrfs vrf : vrfs) {
        for (AddressFamiliesVrf adf : vrf.getAddressFamiliesVrf()) {
            try {
                br.addVrf(BgpUtil.getLayerType(adf), vrf.getRd(), vrf.getImportRts(), vrf.getExportRts());
            } catch (TException | BgpRouterException e) {
                LOG.error("Replay:addVrf() received exception", e);
            }
        }
    }
    List<Networks> ln = config.getNetworks();
    if (ln != null) {
        for (Networks net : ln) {
            String rd = net.getRd();
            String pfxlen = net.getPrefixLen();
            String nh = net.getNexthop().getValue();
            Long label = net.getLabel();
            int lbl = label == null ? 0 : label.intValue();
            int l3vni = net.getL3vni() == null ? 0 : net.getL3vni().intValue();
            int l2vni = net.getL2vni() == null ? 0 : net.getL2vni().intValue();
            if (rd == null && lbl > 0) {
                // LU prefix is being deleted.
                rd = Integer.toString(lbl);
            }
            BgpControlPlaneType protocolType = net.getBgpControlPlaneType();
            int ethernetTag = net.getEthtag().intValue();
            String esi = net.getEsi();
            String macaddress = net.getMacaddress();
            EncapType encapType = net.getEncapType();
            String routerMac = net.getRoutermac();
            try {
                br.addPrefix(rd, pfxlen, nh, lbl, l3vni, l2vni, BgpUtil.convertToThriftProtocolType(protocolType), ethernetTag, esi, macaddress, BgpUtil.convertToThriftEncapType(encapType), routerMac);
            } catch (TException | BgpRouterException e) {
                LOG.error("Replay:addPfx() received exception", e);
            }
        }
    }
    List<Multipath> multipaths = config.getMultipath();
    if (multipaths != null) {
        for (Multipath multipath : multipaths) {
            if (multipath != null) {
                af_afi afi = af_afi.findByValue(multipath.getAfi().intValue());
                af_safi safi = af_safi.findByValue(multipath.getSafi().intValue());
                try {
                    if (multipath.isMultipathEnabled()) {
                        br.enableMultipath(afi, safi);
                    } else {
                        br.disableMultipath(afi, safi);
                    }
                } catch (TException | BgpRouterException e) {
                    LOG.info("Replay:multipaths() received exception", e);
                }
            }
        }
    }
    List<VrfMaxpath> vrfMaxpaths = config.getVrfMaxpath();
    if (vrfMaxpaths != null) {
        for (VrfMaxpath vrfMaxpath : vrfMaxpaths) {
            try {
                br.multipaths(vrfMaxpath.getRd(), vrfMaxpath.getMaxpaths());
            } catch (TException | BgpRouterException e) {
                LOG.info("Replay:vrfMaxPath() received exception", e);
            }
        }
    }
    // send End of Rib Marker to Qthriftd.
    final int numberOfEORRetries = 3;
    replayDone = false;
    RetryOnException eorRetry = new RetryOnException(numberOfEORRetries);
    do {
        try {
            br.sendEOR();
            LOG.debug("Replay sendEOR {} successful");
            replayDone = true;
            break;
        } catch (Exception e) {
            eorRetry.errorOccured();
            LOG.error("Replay:sedEOR() received exception:", e);
        }
    } while (eorRetry.shouldRetry());
    return replaySucceded && replayDone;
}
Also used : TException(org.apache.thrift.TException) Vrfs(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Vrfs) Networks(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Networks) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi) AsId(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.AsId) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) BgpControlPlaneType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.BgpControlPlaneType) EncapType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.EncapType) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi) Logging(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Logging) Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Neighbors) BgpRouter(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouter) VrfMaxpath(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.VrfMaxpath) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SocketException(java.net.SocketException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) TimeoutException(java.util.concurrent.TimeoutException) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) CandidateAlreadyRegisteredException(org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException) TApplicationException(org.apache.thrift.TApplicationException) TApplicationException(org.apache.thrift.TApplicationException) Multipath(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.Multipath) GracefulRestart(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart) AddressFamiliesVrf(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfs.AddressFamiliesVrf) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

ArrayList (java.util.ArrayList)44 BigInteger (java.math.BigInteger)38 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)24 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)20 ByteBuf (io.netty.buffer.ByteBuf)19 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)16 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)16 List (java.util.List)15 ExecutionException (java.util.concurrent.ExecutionException)14 Optional (com.google.common.base.Optional)13 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)13 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)13 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)13 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)13 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)12 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)12 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12