]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
fix remap of floating-ip within l3-agent polling interval
authorDan Wendlandt <dan@nicira.com>
Thu, 29 Nov 2012 06:10:41 +0000 (22:10 -0800)
committerDan Wendlandt <dan@nicira.com>
Thu, 29 Nov 2012 06:10:41 +0000 (22:10 -0800)
bug 1083990

Change-Id: I1bb365fe6accc24a223acd2b31d4eacdb6809410

quantum/agent/l3_agent.py

index 154d7c4fce321d3e1001ec14e2b2b8a2eee94a6c..daab70b76e6d6ec0223fb2c0c44d8ee56d262a50 100644 (file)
@@ -315,7 +315,7 @@ class L3NATAgent(object):
         existing_floating_ip_ids = set([fip['id'] for fip in ri.floating_ips])
         cur_floating_ip_ids = set([fip['id'] for fip in floating_ips])
 
-        id_to_fixed_map = {}
+        id_to_fip_map = {}
 
         for fip in floating_ips:
             if fip['port_id']:
@@ -326,7 +326,7 @@ class L3NATAgent(object):
                                            fip['fixed_ip_address'])
 
                 # store to see if floatingip was remapped
-                id_to_fixed_map[fip['id']] = fip['fixed_ip_address']
+                id_to_fip_map[fip['id']] = fip
 
         floating_ip_ids_to_remove = (existing_floating_ip_ids -
                                      cur_floating_ip_ids)
@@ -338,15 +338,18 @@ class L3NATAgent(object):
                                          fip['fixed_ip_address'])
             else:
                 # handle remapping of a floating IP
-                cur_fixed_ip = id_to_fixed_map[fip['id']]
+                new_fip = id_to_fip_map[fip['id']]
+                new_fixed_ip = new_fip['fixed_ip_address']
                 existing_fixed_ip = fip['fixed_ip_address']
-                if (cur_fixed_ip and existing_fixed_ip and
-                        cur_fixed_ip != existing_fixed_ip):
+                if (new_fixed_ip and existing_fixed_ip and
+                        new_fixed_ip != existing_fixed_ip):
                     floating_ip = fip['floating_ip_address']
                     self.floating_ip_removed(ri, ri.ex_gw_port,
                                              floating_ip, existing_fixed_ip)
                     self.floating_ip_added(ri, ri.ex_gw_port,
-                                           floating_ip, cur_fixed_ip)
+                                           floating_ip, new_fixed_ip)
+                    ri.floating_ips.remove(fip)
+                    ri.floating_ips.append(new_fip)
 
     def _get_ex_gw_port(self, ri):
         ports = self.qclient.list_ports(