]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove 'action' argument from _handle_fip_nat_rules()
authorBrian Haley <brian.haley@hp.com>
Thu, 13 Aug 2015 20:57:59 +0000 (16:57 -0400)
committerBrian Haley <brian.haley@hp.com>
Thu, 13 Aug 2015 21:02:41 +0000 (17:02 -0400)
There's only one caller of _handle_fip_nat_rules(), and they
always specify 'add_rules' as the argument, so it's not
necessary any more.  Also, the interface passed must be valid
since the caller has already used it, and would have thrown
an exception before this call was made.  Found during another
code review.

Change-Id: Ie7d4faf2d1bb8e0e8fc4ffc3f18e9214474acf5c

neutron/agent/l3/dvr_fip_ns.py
neutron/agent/l3/dvr_local_router.py

index 90e24d129d9bcaf50e67cf271ce9b88332db3c29..74981ea69b31fba95dd31ab62514a08c9f51f3df 100644 (file)
@@ -217,7 +217,7 @@ class FipNamespace(namespaces.Namespace):
         device = ip_lib.IPDevice(rtr_2_fip_name, namespace=ri.ns_name)
         device.route.add_gateway(str(fip_2_rtr.ip), table=FIP_RT_TBL)
         #setup the NAT rules and chains
-        ri._handle_fip_nat_rules(rtr_2_fip_name, 'add_rules')
+        ri._handle_fip_nat_rules(rtr_2_fip_name)
 
     def scan_fip_ports(self, ri):
         # don't scan if not dvr or count is not None
index e14fc2d172a8db9ae5c9750a83ca967b03bba883..993bfc6127da4f3e6ee5c6a053e05c4f41c9058d 100644 (file)
@@ -47,7 +47,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
         floating_ips = super(DvrLocalRouter, self).get_floating_ips()
         return [i for i in floating_ips if i['host'] == self.host]
 
-    def _handle_fip_nat_rules(self, interface_name, action):
+    def _handle_fip_nat_rules(self, interface_name):
         """Configures NAT rules for Floating IPs for DVR.
 
            Remove all the rules. This is safe because if
@@ -61,13 +61,13 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
         # Add back the jump to float-snat
         self.iptables_manager.ipv4['nat'].add_rule('snat', '-j $float-snat')
 
-        # And add them back if the action is add_rules
-        if action == 'add_rules' and interface_name:
-            rule = ('POSTROUTING', '! -i %(interface_name)s '
-                    '! -o %(interface_name)s -m conntrack ! '
-                    '--ctstate DNAT -j ACCEPT' %
-                    {'interface_name': interface_name})
-            self.iptables_manager.ipv4['nat'].add_rule(*rule)
+        # And add the NAT rule back
+        rule = ('POSTROUTING', '! -i %(interface_name)s '
+                '! -o %(interface_name)s -m conntrack ! '
+                '--ctstate DNAT -j ACCEPT' %
+                {'interface_name': interface_name})
+        self.iptables_manager.ipv4['nat'].add_rule(*rule)
+
         self.iptables_manager.apply()
 
     def floating_ip_added_dist(self, fip, fip_cidr):