- /*public synchronized void startBgpSync() {
- boolean getRoutes = true;
- readBgpConfiguration();
- try {
- pushConfigurationToBgp();
-
- } catch (BgpRouterException b) {
- s_logger.error("Failed to push configuration to BGP due to BgpRouter Exception number " + b.getErrorCode());
- s_logger.error("BgpRouterException trace ", b);
- if(b.getErrorCode() == BgpRouterException.BGP_ERR_INACTIVE)
- getRoutes = false;
- } catch (Exception e) {
- s_logger.error("Failed to push configuration to bgp ", e);
- }
- if(getRoutes == true)
- pullConfigurationFromBgp();
- //controllerResyncLatch.countDown();
- }*/
-
- /*public void waitForControllerBgpResync() {
- try {
- controllerResyncLatch.await();
- } catch (InterruptedException e) {
- }
- }*/
-
- /*private void pullConfigurationFromBgp() {
- //get routes from bgp server
- s_logger.info("Starting bgp route sync");
- try {
- bgpThriftClient.doRouteSync();
- } catch (BgpRouterException b) {
- s_logger.error("Failed BGP Route sync due to BgpRouter Exception number " + b.getErrorCode());
- s_logger.error("BgpRouterException trace ", b);
- } catch (Exception e) {
- s_logger.error("Failed to pull configuration from bgp ", e);
- }
- }*/
-
- /*private BgpConfiguration readBgpConfiguration() {
- if (cache != null) {
- bgpConfiguration = cache.get("bgpConfiguration");
- if (bgpConfiguration == null) {
- s_logger.info("Created bgp configuration cache");
- bgpConfiguration = new BgpConfiguration();
- cache.put("bgpConfiguration", bgpConfiguration);
- } else {
- s_logger.info("Using bgp configuration cache");
- }
- }
- return bgpConfiguration;
- }*/
-
- /*public synchronized void pushConfigurationToBgp() throws Exception {
- if (bgpConfiguration.getAsNum() == 0) {
- s_logger.error("No as num configured, Skipping the push configuration to bgp ");
- throw new BgpRouterException(BgpRouterException.BGP_ERR_INACTIVE);
- //return;
- }
- if(bgpThriftClient == null) {
- s_logger.error("bgpThriftClient is null. Skipping the push configuration to bgp.");
- throw new BgpRouterException(BgpRouterException.BGP_ERR_INACTIVE);
- //return;
- }
-
- try {
- bgpThriftClient.startBgp((int)bgpConfiguration.getAsNum(), bgpConfiguration.getRouterId());
- s_logger.info("Started BGP with AS number " + (int)bgpConfiguration.getAsNum() + " and router id " + bgpConfiguration.getRouterId());
- } catch (BgpRouterException be) {
- if(be.getErrorCode() == BgpRouterException.BGP_ERR_ACTIVE) {
- s_logger.info("bgp server already active");
- return; //the assumption here is that bgp server is configured already with neighbor, vrfs and routes as well
- } if(be.getErrorCode() == BgpRouterException.BGP_ERR_INACTIVE) {
- s_logger.info("bgp server inactive");
- throw be;
- }
-
- else {
- s_logger.error("application error while starting bgp server %d", be.getErrorCode());
- return;
- }
-
- } catch (SocketTimeoutException to) {
- s_logger.error("Socket Timeout error while starting bgp server", to);
- return;
- } catch (TException t) {
- s_logger.error("Transport error while starting bgp server ", t);
- return;
- } catch (Exception e) {
- s_logger.error("Error while starting bgp server", e);
- }
-
- if (bgpConfiguration.getNeighbourIp().trim().length() > 0) {
- try {
- bgpThriftClient.addNeighbor(bgpConfiguration.getNeighbourIp(), bgpConfiguration.getNeighbourAsNum());
- } catch (TException t) {
- s_logger.error("Failed to push vrf to bgp due to Transport error" );
- //retry connection
- reInitConn();
- addNeighbor(bgpConfiguration.getNeighbourIp(), bgpConfiguration.getNeighbourAsNum());
- } catch (Exception e) {
- s_logger.error("Error while starting bgp server", e);
- }
- }
-
- Tenant tenant;
- try {
- tenant = tenantManager.getTenant("NEUTRON");
- } catch (TenantNotFoundException e) {
- s_logger.error("Tenant not found. Skipping push configuration to bgp.");
- return;
- }
- if (tenant != null) {
- int tenantId = tenant.getTenantId();
-
- Set<VpnInstanceInfo> vpnInfos = l3Manager.getVpnInstanceManager().getVpnsForTenant(tenantId);
- s_logger.info("Number of vpns to configure is "+vpnInfos.size());
- for (VpnInstanceInfo vpnInfo: vpnInfos) {
- try {
- bgpThriftClient.addVrf(vpnInfo.getRouteDistinguisher(),
- new ArrayList<>(vpnInfo.getRtImportList()),
- new ArrayList<>(vpnInfo.getRtExportList()));
- } catch (TException t) {
- s_logger.error("Failed to push vrf to bgp due to Transport error" );
- //retry connection
- reInitConn();
- addVrf(vpnInfo.getRouteDistinguisher(), new ArrayList<>(vpnInfo.getRtImportList()),
- new ArrayList<>(vpnInfo.getRtExportList()));
- } catch (Exception e) {
- s_logger.error("Failed to push vrf to bgp ", e);
- }
- }
- for (VpnInstanceInfo vpnInfo: vpnInfos) {
- ConcurrentMap<FibInfo, Object> fibInfos = l3Manager.getVpnInstanceManager().
- getLocalFibInfosForRdCache(vpnInfo.getRouteDistinguisher());
- s_logger.info("Number of fib infos to configure is "+fibInfos.size());
- for (FibInfo fibInfo : fibInfos.keySet()) {
- try {
- bgpThriftClient.addPrefix(vpnInfo.getRouteDistinguisher(), fibInfo.getDestinationPrefix(),
- fibInfo.getNextHopPrefix(), (int) fibInfo.getLabel());
- } catch (TException t) {
- s_logger.error("Failed to push route to bgp due to Transport error" );
- reInitConn();
- addPrefix(vpnInfo.getRouteDistinguisher(), fibInfo.getDestinationPrefix(),
- fibInfo.getNextHopPrefix(), (int) fibInfo.getLabel());
- } catch (Exception e) {
- s_logger.error("Failed to push route to bgp ", e);
- }
- }
- }
- }
-
- }
- */
-