* @param importRts the import rd(s) for this vrf
* @param exportRts the export rd(s) for this vrf
* @param addressFamily is used to pass the nature of the VPN context : IPv4, IPv6, or EVPN.
- * @throws Exception an exception could be raise (see the implementation method).
*/
- void addVrf(String rd, Collection<String> importRts, Collection<String> exportRts, AddressFamily addressFamily)
- throws Exception;
+ void addVrf(String rd, Collection<String> importRts, Collection<String> exportRts, AddressFamily addressFamily);
/** Delete onv VPN table.
* VPN contexts apply to MPLS or VXLAN overlays.
*/
void addPrefix(String rd, String macAddress, String prefix, List<String> nextHopList,
VrfEntry.EncapType encapType, int vpnLabel, long l3vni, String gatewayMac,
- RouteOrigin origin) throws Exception;
+ RouteOrigin origin);
/**
* Adds a route in a BGP neighbour. It persists the VrfEntry in Datastore and sends the BGP message.
*/
void addPrefix(String rd, String macAddress, String prefix, String nextHop,
VrfEntry.EncapType encapType, int vpnLabel, long l3vni, String gatewayMac,
- RouteOrigin origin) throws Exception;
+ RouteOrigin origin);
void deletePrefix(String rd, String prefix);
final IVpnLinkService vpnLinkSrvce,
final BundleContext bundleContext,
final BgpUtil bgpUtil,
- final MetricProvider metricProvider)
- throws InterruptedException, ExecutionException, TimeoutException {
+ final MetricProvider metricProvider) {
this.dataBroker = dataBroker;
this.fibDSWriter = fibDSWriter;
this.vpnLinkService = vpnLinkSrvce;
}
}
- private void doRouteSync() throws InterruptedException, TimeoutException, ExecutionException {
+ private void doRouteSync() {
LOG.error("Starting BGP route sync");
try {
bgpRouter.initRibSync(bgpSyncHandle);
- } catch (TException | BgpRouterException e) {
+ } catch (BgpRouterException e) {
LOG.error("Route sync aborted, exception when initializing", e);
return;
}
try {
LOG.error("Ending BGP route-sync");
bgpRouter.endRibSync(bgpSyncHandle);
- } catch (TException | BgpRouterException e) {
+ } catch (BgpRouterException e) {
// Ignored?
}
}
*/
public void onUpdatePushRoute(protocol_type protocolType, String rd, String prefix, int plen, String nextHop,
- int ethtag, String esi, String macaddress, int label, int l2label, String routermac, af_afi afi)
- throws InterruptedException, ExecutionException, TimeoutException {
+ int ethtag, String esi, String macaddress, int label, int l2label, String routermac, af_afi afi) {
boolean addroute = false;
boolean macupdate = false;
long l3vni = 0L;
}
public void onUpdateWithdrawRoute(protocol_type protocolType, String rd, String prefix, int plen, String nextHop,
- String macaddress) throws InterruptedException, ExecutionException, TimeoutException {
+ String macaddress) {
long vni = 0L;
boolean macupdate = false;
if (protocolType.equals(protocol_type.PROTOCOL_EVPN)) {
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.apache.thrift.TException;
import org.opendaylight.netvirt.bgpmanager.api.IBgpManager;
import org.opendaylight.netvirt.bgpmanager.oam.BgpAlarmErrorCodes;
import org.opendaylight.netvirt.bgpmanager.oam.BgpConstants;
@Override
@PreDestroy
- public void close() throws Exception {
+ public void close() {
LOG.info("{} close", getClass().getSimpleName());
}
return bcm;
}
- public void configureGR(int stalepathTime) throws TException {
+ public void configureGR(int stalepathTime) {
bcm.addGracefulRestart(stalepathTime);
}
- public void delGracefulRestart() throws Exception {
+ public void delGracefulRestart() {
bcm.delGracefulRestart();
}
public void addNeighbor(String ipAddress, long asNum,
- @Nullable final TcpMd5SignaturePasswordType md5Password) throws TException {
+ @Nullable final TcpMd5SignaturePasswordType md5Password) {
bcm.addNeighbor(ipAddress, asNum, md5Password);
}
- public void addEbgpMultihop(String ipAddress, int nhops) throws TException {
+ public void addEbgpMultihop(String ipAddress, int nhops) {
bcm.addEbgpMultihop(ipAddress, nhops);
}
- public void addUpdateSource(String ipAddress, String srcIp) throws TException {
+ public void addUpdateSource(String ipAddress, String srcIp) {
bcm.addUpdateSource(ipAddress, srcIp);
}
- public void addAddressFamily(String ipAddress, af_afi afi, af_safi safi) throws TException {
+ public void addAddressFamily(String ipAddress, af_afi afi, af_safi safi) {
bcm.addAddressFamily(ipAddress, afi.getValue(), safi.getValue());
}
- public void deleteNeighbor(String ipAddress) throws TException {
+ public void deleteNeighbor(String ipAddress) {
bcm.delNeighbor(ipAddress);
}
@Override
public void addVrf(String rd, Collection<String> importRts, Collection<String> exportRts,
- AddressFamily addressFamily) throws Exception {
+ AddressFamily addressFamily) {
bcm.addVrf(rd, new ArrayList<>(importRts), new ArrayList<>(exportRts), addressFamily);
}
@Override
public void addPrefix(String rd, String macAddress, String prefix, List<String> nextHopList,
VrfEntry.EncapType encapType, int vpnLabel, long l3vni,
- String gatewayMac, RouteOrigin origin)
- throws Exception {
+ String gatewayMac, RouteOrigin origin) {
fibDSWriter.addFibEntryToDS(rd, macAddress, prefix, nextHopList,
encapType, vpnLabel, l3vni, gatewayMac, origin);
bcm.addPrefix(rd, macAddress, prefix, nextHopList,
@Override
public void addPrefix(String rd, String macAddress, String prefix, String nextHop, VrfEntry.EncapType encapType,
- int vpnLabel, long l3vni, String gatewayMac, RouteOrigin origin) throws Exception {
+ int vpnLabel, long l3vni, String gatewayMac, RouteOrigin origin) {
addPrefix(rd, macAddress, prefix, Collections.singletonList(nextHop), encapType, vpnLabel, l3vni,
gatewayMac, origin);
}
@Override
public void advertisePrefix(String rd, String macAddress, String prefix, List<String> nextHopList,
VrfEntry.EncapType encapType, long vpnLabel, long l3vni, long l2vni,
- String gatewayMac) throws Exception {
+ String gatewayMac) {
LOG.info("Advertise Prefix: Adding Prefix rd {} prefix {} label {} l3vni {} l2vni {}",
rd, prefix, vpnLabel, l3vni, l2vni);
bcm.addPrefix(rd, macAddress, prefix, nextHopList,
@Override
public void advertisePrefix(String rd, String macAddress, String prefix, String nextHop,
VrfEntry.EncapType encapType, long vpnLabel, long l3vni, long l2vni,
- String gatewayMac) throws Exception {
+ String gatewayMac) {
LOG.info("ADVERTISE: Adding Prefix rd {} prefix {} nexthop {} label {} l3vni {} l2vni {}",
rd, prefix, nextHop, vpnLabel, l3vni, l2vni);
bcm.addPrefix(rd, macAddress, prefix, Collections.singletonList(nextHop), encapType,
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.thrift.TException;
import org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi;
import org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi;
import org.opendaylight.netvirt.bgpmanager.thrift.gen.protocol_type;
@Override
protected Object doExecute() throws Exception {
- try {
- if (op == null) {
- session.getConsole().println("Please provide valid operation");
+ if (op == null) {
+ session.getConsole().println("Please provide valid operation");
+ usage();
+ session.getConsole().println(
+ "exec configure-bgp -op [start-bgp-server | stop-bgp-server | add-neighbor | delete-neighbor|"
+ + " add-route | delete-route | graceful-restart| enable-log ]");
+ }
+ switch (op) {
+ case "start-bgp-server":
+ startBgp();
+ break;
+ case "stop-bgp-server":
+ stopBgp();
+ break;
+ case "add-neighbor":
+ addNeighbor();
+ break;
+ case "delete-neighbor":
+ deleteNeighbor();
+ break;
+ case "add-route":
+ addRoute();
+ break;
+ case "delete-route":
+ deleteRoute();
+ break;
+ case "graceful-restart":
+ configureGR();
+ break;
+ case "enable-log":
+ enableBgpLogLevel();
+ break;
+ default:
+ session.getConsole().println("invalid operation");
usage();
session.getConsole().println(
- "exec configure-bgp -op [start-bgp-server | stop-bgp-server | add-neighbor | delete-neighbor|"
- + " add-route | delete-route | graceful-restart| enable-log ]");
- }
- switch (op) {
- case "start-bgp-server":
- startBgp();
- break;
- case "stop-bgp-server":
- stopBgp();
- break;
- case "add-neighbor":
- addNeighbor();
- break;
- case "delete-neighbor":
- deleteNeighbor();
- break;
- case "add-route":
- addRoute();
- break;
- case "delete-route":
- deleteRoute();
- break;
- case "graceful-restart":
- configureGR();
- break;
- case "enable-log":
- enableBgpLogLevel();
- break;
- default:
- session.getConsole().println("invalid operation");
- usage();
- session.getConsole().println(
- "exec configure-bgp -op [start-bgp-server | stop-bgp-server | add-neighbor | "
- + "delete-neighbor| graceful-restart| enable-log ]");
- }
- } catch (TException e) {
- log.error("failed to handle the command", e);
+ "exec configure-bgp -op [start-bgp-server | stop-bgp-server | add-neighbor | "
+ + "delete-neighbor| graceful-restart| enable-log ]");
}
return null;
}
return true;
}
- private void configureGR() throws TException {
+ private void configureGR() {
boolean validStalepathTime = validateStalepathTime();
if (!validStalepathTime) {
return;
bgpManager.configureGR(Integer.parseInt(stalePathTime));
}
- private void deleteNeighbor() throws TException {
+ private void deleteNeighbor() {
if (ip == null || !validateIp(ip)) {
session.getConsole().println("invalid neighbor ip");
printDeleteNeighborHelp();
stalePathTime == null ? 0 : Integer.parseInt(stalePathTime), false);
}
- protected void addNeighbor() throws TException {
+ protected void addNeighbor() {
if (!validateAsNumber(asNumber)) {
printAddNeighborHelp();
return;
}
}
- protected void addRoute() throws Exception {
+ protected void addRoute() {
bgpConfigurationManager.onUpdatePushRoute(protocol_type.PROTOCOL_EVPN, rd, prefix,
0, nexthop, 0, null, mac, l3vni, l2vni, null, null);
}
- protected void deleteRoute() throws Exception {
+ protected void deleteRoute() {
bgpConfigurationManager.onUpdateWithdrawRoute(protocol_type.PROTOCOL_EVPN, rd, prefix,
0, nexthop, mac);
}
};
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
int handlerModule = 0;
cmd = cmd.trim();
if (cmd.equals("") || cmd.equals("help") || cmd.equals("-help") || cmd.equals("--help")) {
return null;
}
- public Object show(CommandSession session) throws Exception {
+ public Object show(CommandSession session) {
this.session = session;
return doExecute();
}
- public Object show() throws Exception {
+ public Object show() {
return doExecute();
}
@SuppressWarnings("resource")
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
boolean listVrfs = false;
boolean listNets = false;
PrintStream ps = session.getConsole();
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
switch (action) {
case "add":
if (host == null || port == null) {
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
if (spt == null && file == null && level == null) {
return usage();
}
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
af_afi afi = af_afi.findByValue(1);
af_safi safi = af_safi.findByValue(5);
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
switch (action) {
case "add":
if (nbrIp == null) {
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
switch (action) {
case "add":
int label = qbgpConstants.LBL_EXPLICIT_NULL;
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
switch (action) {
case "add":
// check: rtr already running?
}
@Override
- protected Object doExecute() throws Exception {
+ protected Object doExecute() {
AddressFamily af = null;
if (addrf.compareToIgnoreCase("IPV_4") == 0) {
af = AddressFamily.IPV4;
package org.opendaylight.netvirt.bgpmanager.oam;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Override
public void run() {
List<Neighbors> nbrList = null;
- try {
- LOG.debug("Fetching neighbor status' from BGP");
- BgpCounters.resetFile(BgpCounters.BGP_VPNV4_SUMMARY_FILE);
- BgpCounters.resetFile(BgpCounters.BGP_VPNV6_SUMMARY_FILE);
- BgpCounters.resetFile(BgpCounters.BGP_EVPN_SUMMARY_FILE);
- Map<String, String> neighborStatusMap = new HashMap<>();
-
- if (bgpMgr.getBgpCounters() != null) {
- bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_VPNV4_SUMMARY_FILE,
- "show ip bgp vpnv4 all summary");
- if (bgpMgr.getConfig() != null) {
- nbrList = bgpMgr.getConfig().getNeighbors();
- }
- BgpCounters.parseIpBgpVpnv4AllSummary(neighborStatusMap);
+ LOG.debug("Fetching neighbor status' from BGP");
+ BgpCounters.resetFile(BgpCounters.BGP_VPNV4_SUMMARY_FILE);
+ BgpCounters.resetFile(BgpCounters.BGP_VPNV6_SUMMARY_FILE);
+ BgpCounters.resetFile(BgpCounters.BGP_EVPN_SUMMARY_FILE);
+ Map<String, String> neighborStatusMap = new HashMap<>();
+
+ if (bgpMgr.getBgpCounters() != null) {
+ bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_VPNV4_SUMMARY_FILE,
+ "show ip bgp vpnv4 all summary");
+ if (bgpMgr.getConfig() != null) {
+ nbrList = bgpMgr.getConfig().getNeighbors();
+ }
+ BgpCounters.parseIpBgpVpnv4AllSummary(neighborStatusMap);
- bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_VPNV6_SUMMARY_FILE,
- "show ip bgp vpnv6 all summary");
+ bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_VPNV6_SUMMARY_FILE,
+ "show ip bgp vpnv6 all summary");
- BgpCounters.parseIpBgpVpnv6AllSummary(neighborStatusMap);
+ BgpCounters.parseIpBgpVpnv6AllSummary(neighborStatusMap);
- bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_EVPN_SUMMARY_FILE,
- "show bgp l2vpn evpn all summary");
+ bgpMgr.getBgpCounters().fetchCmdOutputs(BgpCounters.BGP_EVPN_SUMMARY_FILE,
+ "show bgp l2vpn evpn all summary");
- BgpCounters.parseBgpL2vpnEvpnAllSummary(neighborStatusMap);
+ BgpCounters.parseBgpL2vpnEvpnAllSummary(neighborStatusMap);
- processNeighborStatusMap(neighborStatusMap, nbrList);
- }
- LOG.debug("Finished getting the status of BGP neighbors");
- } catch (IOException e) {
- LOG.error("Failed to publish bgp counters ", e);
+ processNeighborStatusMap(neighborStatusMap, nbrList);
}
+ LOG.debug("Finished getting the status of BGP neighbors");
}
private void processNeighborStatusMap(Map<String, String> nbrStatusMap, List<Neighbors> nbrs) {
@Override
public void run() {
- try {
- LOG.debug("Fetching counters from BGP");
- resetCounters();
- fetchCmdOutputs("cmd_ip_bgp_summary.txt", "show ip bgp summary");
- fetchCmdOutputs("cmd_bgp_ipv4_unicast_statistics.txt", "show bgp ipv4 unicast statistics");
- fetchCmdOutputs(BGP_VPNV4_FILE, "show ip bgp vpnv4 all");
- fetchCmdOutputs(BGP_VPNV6_FILE, "show ip bgp vpnv6 all");
- fetchCmdOutputs(BGP_EVPN_FILE, "show bgp l2vpn evpn all");
- parseIpBgpSummary();
- parseIpBgpVpnv4All();
- parseIpBgpVpnv6All();
- parseBgpL2vpnEvpnAll();
- LOG.debug("Finished updating the counters from BGP");
- } catch (IOException e) {
- LOG.error("Failed to publish bgp counters ", e);
- }
+ LOG.debug("Fetching counters from BGP");
+ resetCounters();
+ fetchCmdOutputs("cmd_ip_bgp_summary.txt", "show ip bgp summary");
+ fetchCmdOutputs("cmd_bgp_ipv4_unicast_statistics.txt", "show bgp ipv4 unicast statistics");
+ fetchCmdOutputs(BGP_VPNV4_FILE, "show ip bgp vpnv4 all");
+ fetchCmdOutputs(BGP_VPNV6_FILE, "show ip bgp vpnv6 all");
+ fetchCmdOutputs(BGP_EVPN_FILE, "show bgp l2vpn evpn all");
+ parseIpBgpSummary();
+ parseIpBgpVpnv4All();
+ parseIpBgpVpnv6All();
+ parseBgpL2vpnEvpnAll();
+ LOG.debug("Finished updating the counters from BGP");
}
- void fetchCmdOutputs(String filename, String cmdName) throws IOException {
+ void fetchCmdOutputs(String filename, String cmdName) {
try (Socket socket = new Socket(bgpSdncMip, 2605);
PrintWriter toRouter = new PrintWriter(socket.getOutputStream(), true);
BufferedReader fromRouter = new BufferedReader(new InputStreamReader(socket.getInputStream()));
dispatch(bop);
}
- public int initRibSync(BgpSyncHandle handle) throws TException, BgpRouterException {
+ public int initRibSync(BgpSyncHandle handle) throws BgpRouterException {
if (bgpClient == null) {
throw new BgpRouterException(BgpRouterException.BGP_ERR_NOT_INITED);
}
return 0;
}
- public int endRibSync(BgpSyncHandle handle) throws TException, BgpRouterException {
+ public int endRibSync(BgpSyncHandle handle) throws BgpRouterException {
if (bgpClient == null) {
throw new BgpRouterException(BgpRouterException.BGP_ERR_NOT_INITED);
}
package org.opendaylight.netvirt.bgpmanager.thrift.server;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
-
-import java.util.concurrent.TimeoutException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.server.ServerContext;
LOG.debug("Update on push route : rd {} prefix {} plen {}", rd, prefix, plen);
// l2label is ignored even in case of RT5. only l3label considered
- try {
- bgpConfigManager.onUpdatePushRoute(
- protocolType,
- rd,
- prefix,
- plen,
- nexthop,
- ethtag,
- esi,
- macaddress,
- l3label,
- l2label,
- routermac,
- afi);
- } catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.error("failed to handle update route ", e);
- }
+ bgpConfigManager.onUpdatePushRoute(
+ protocolType,
+ rd,
+ prefix,
+ plen,
+ nexthop,
+ ethtag,
+ esi,
+ macaddress,
+ l3label,
+ l2label,
+ routermac,
+ afi);
}
@Override
int l3label,
int l2label,
af_afi afi) {
- try {
- LOG.debug("Route del ** {} ** {}/{} ", rd, prefix, plen);
- bgpConfigManager.onUpdateWithdrawRoute(
- protocolType,
- rd,
- prefix,
- plen,
- nexthop,
- macaddress);
- } catch (InterruptedException e1) {
- LOG.error("Interrupted exception for withdraw route", e1);
- } catch (ExecutionException e2) {
- LOG.error("Execution exception for withdraw route", e2);
- } catch (TimeoutException e3) {
- LOG.error("Timeout exception for withdraw route", e3);
- }
+ LOG.debug("Route del ** {} ** {}/{} ", rd, prefix, plen);
+ bgpConfigManager.onUpdateWithdrawRoute(
+ protocolType,
+ rd,
+ prefix,
+ plen,
+ nexthop,
+ macaddress);
}
@Override