]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move update_fip_statuses to Router class
authorCarl Baldwin <carl.baldwin@hpe.com>
Mon, 5 Oct 2015 21:35:37 +0000 (21:35 +0000)
committerCarl Baldwin <carl@ecbaldwin.net>
Fri, 6 Nov 2015 18:58:03 +0000 (18:58 +0000)
I noticed that ri.floating_ips was being accessed from the agent.  It
didn't seem right.  Also, noticed that this set gets passed around too
much between methods.  It all boils down to saving the previous set
and then doing set difference to see which ones went away.  This patch
set makes it simpler.

Partially-Implements: blueprint address-scopes

Change-Id: I73424620e196200c70f221871c34e33ccfe73261

neutron/agent/l3/agent.py
neutron/agent/l3/router_info.py

index 9948f3b401fafe8fe1f1d9e9d4f2058a1531931e..2ade79910dad3bbd2e0e11e9dbbaa378c8a3ec13 100644 (file)
@@ -33,7 +33,6 @@ from neutron.agent.l3 import ha_router
 from neutron.agent.l3 import legacy_router
 from neutron.agent.l3 import namespace_manager
 from neutron.agent.l3 import namespaces
-from neutron.agent.l3 import router_info as rinf
 from neutron.agent.l3 import router_processing_queue as queue
 from neutron.agent.linux import external_process
 from neutron.agent.linux import ip_lib
@@ -369,21 +368,6 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
 
         registry.notify(resources.ROUTER, events.AFTER_DELETE, self, router=ri)
 
-    def update_fip_statuses(self, ri, existing_floating_ips, fip_statuses):
-        # Identify floating IPs which were disabled
-        ri.floating_ips = set(fip_statuses.keys())
-        for fip_id in existing_floating_ips - ri.floating_ips:
-            fip_statuses[fip_id] = l3_constants.FLOATINGIP_STATUS_DOWN
-        # filter out statuses that didn't change
-        fip_statuses = {f: stat for f, stat in fip_statuses.items()
-                        if stat != rinf.FLOATINGIP_STATUS_NOCHANGE}
-        if not fip_statuses:
-            return
-        LOG.debug('Sending floating ip statuses: %s', fip_statuses)
-        # Update floating IP status on the neutron server
-        self.plugin_rpc.update_floatingip_statuses(
-            self.context, ri.router_id, fip_statuses)
-
     def router_deleted(self, context, router_id):
         """Deal with router deletion RPC message."""
         LOG.debug('Got router deleted notification for %s', router_id)
index 30d01122cfb84827420e0bb15bf01289c0cd20c9..038b3d715057717458c32da5685a5dca5e445ddd 100644 (file)
@@ -653,7 +653,6 @@ class RouterInfo(object):
 
     def process_external(self, agent):
         fip_statuses = {}
-        existing_floating_ips = self.floating_ips
         try:
             with self.iptables_manager.defer_apply():
                 ex_gw_port = self.get_ex_gw_port()
@@ -676,8 +675,23 @@ class RouterInfo(object):
                 LOG.exception(_LE("Failed to process floating IPs."))
                 fip_statuses = self.put_fips_in_error_state()
         finally:
-            agent.update_fip_statuses(
-                self, existing_floating_ips, fip_statuses)
+            self.update_fip_statuses(agent, fip_statuses)
+
+    def update_fip_statuses(self, agent, fip_statuses):
+        # Identify floating IPs which were disabled
+        existing_floating_ips = self.floating_ips
+        self.floating_ips = set(fip_statuses.keys())
+        for fip_id in existing_floating_ips - self.floating_ips:
+            fip_statuses[fip_id] = l3_constants.FLOATINGIP_STATUS_DOWN
+        # filter out statuses that didn't change
+        fip_statuses = {f: stat for f, stat in fip_statuses.items()
+                        if stat != FLOATINGIP_STATUS_NOCHANGE}
+        if not fip_statuses:
+            return
+        LOG.debug('Sending floating ip statuses: %s', fip_statuses)
+        # Update floating IP status on the neutron server
+        agent.plugin_rpc.update_floatingip_statuses(
+            agent.context, self.router_id, fip_statuses)
 
     @common_utils.exception_logger()
     def process(self, agent):