Enable SNAT flows on router update 55/72155/3
authorStephen Kitt <skitt@redhat.com>
Tue, 22 May 2018 10:15:42 +0000 (12:15 +0200)
committerSam Hague <shague@redhat.com>
Fri, 25 May 2018 17:14:34 +0000 (17:14 +0000)
Currently, flows are removed on router update, and never
re-installed. This patch ensures that the flows are enabled.

Change-Id: I14226f7ca92dff58d7e133f50eb6c4d92f8140b5
JIRA: NETVIRT-1279
Signed-off-by: Stephen Kitt <skitt@redhat.com>
natservice/impl/src/main/java/org/opendaylight/netvirt/natservice/ha/SnatCentralizedSwitchChangeListener.java

index 9cfff4d7599fcf24d49330f5b5cb381b8efa551b..40f8ee30a2a547e58ad8012fbd157f59de95046e 100644 (file)
@@ -72,10 +72,16 @@ public class SnatCentralizedSwitchChangeListener
     protected void update(InstanceIdentifier<RouterToNaptSwitch> key, RouterToNaptSwitch origRouterToNaptSwitch,
             RouterToNaptSwitch updatedRouterToNaptSwitch) {
         LOG.debug("Updating old {} new {}", origRouterToNaptSwitch, updatedRouterToNaptSwitch);
-        BigInteger primarySwitchId = origRouterToNaptSwitch.getPrimarySwitchId();
-        Routers router = NatUtil.getRoutersFromConfigDS(dataBroker, origRouterToNaptSwitch.getRouterName());
-        natDataUtil.updateRouterMap(router);
-        snatServiceManger.notify(router, primarySwitchId, null, SnatServiceManager.Action.SNAT_ALL_SWITCH_DISBL);
+        BigInteger origPrimarySwitchId = origRouterToNaptSwitch.getPrimarySwitchId();
+        Routers origRouter = NatUtil.getRoutersFromConfigDS(dataBroker, origRouterToNaptSwitch.getRouterName());
+        snatServiceManger.notify(origRouter, origPrimarySwitchId, null,
+                SnatServiceManager.Action.SNAT_ALL_SWITCH_DISBL);
+        natDataUtil.removeFromRouterMap(origRouter);
+        BigInteger updatedPrimarySwitchId = updatedRouterToNaptSwitch.getPrimarySwitchId();
+        Routers updatedRouter = NatUtil.getRoutersFromConfigDS(dataBroker, updatedRouterToNaptSwitch.getRouterName());
+        natDataUtil.updateRouterMap(updatedRouter);
+        snatServiceManger.notify(updatedRouter, updatedPrimarySwitchId, null,
+                SnatServiceManager.Action.SNAT_ALL_SWITCH_ENBL);
     }
 
     @Override