Fix for Bug 3387 - Delete VPN should clear corresponding VrfTable in FIB
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / BgpManager.java
index d8e387eaf58e52478b4e2d215045a37b2bf8bcf3..55085413eecf3c775373a8bc1af0a1c43d79a338 100644 (file)
@@ -238,12 +238,15 @@ public class BgpManager implements BindingAwareProvider, AutoCloseable, IBgpMana
 
     @Override
     public void deleteVrf(String rd) throws Exception {
-        if(bgpThriftClient == null) {
-            LOGGER.info("Delete BGP vrf - bgpThriftClient is null. Unable to delete BGP vrf.");
+        if(bgpThriftClient == null || !hasBgpServiceStarted) {
+            LOGGER.debug("Delete BGP vrf - Unable to delete BGP vrf in BGP Server. Removing Vrf from local DS");
+            fibDSWriter.removeVrfFromDS(rd);
             return;
         }
+
         try {
             bgpThriftClient.delVrf(rd);
+            fibDSWriter.removeVrfFromDS(rd);
         } catch (BgpRouterException b) {
             LOGGER.error("Failed to delete BGP vrf " + rd + "due to BgpRouter Exception number " + b.getErrorCode());
             LOGGER.debug("BgpRouterException trace ", b);