]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
use floatingip's ID as key instead of itself
authorYong Sheng Gong <gongysh@unitedstack.com>
Wed, 19 Mar 2014 08:14:33 +0000 (16:14 +0800)
committerMark McClain <mmcclain@yahoo-inc.com>
Fri, 4 Apr 2014 23:18:55 +0000 (19:18 -0400)
Change-Id: I267f174a0e2e611ec007404c7b44e2c73a359c38
Closes-Bug: 1294526
(cherry picked from commit 7120325d37df414d8de084c5b41fdfbea3a06565)

neutron/agent/l3_agent.py
neutron/tests/unit/test_l3_agent.py

index 5b7d709d6bfa6be310e65bc58a19dd53fcb27f30..630e88bf9bfce9224111d508c63ecf3f6ef0ef98 100644 (file)
@@ -504,7 +504,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
             # TODO(salv-orlando): Less broad catching
             # All floating IPs must be put in error state
             for fip in ri.router.get(l3_constants.FLOATINGIP_KEY, []):
-                fip_statuses[fip] = l3_constants.FLOATINGIP_STATUS_ERROR
+                fip_statuses[fip['id']] = l3_constants.FLOATINGIP_STATUS_ERROR
 
         if ex_gw_port:
             # Identify floating IPs which were disabled
index d390ac29bd6e83161cd04a2f1cbbccedf1767384..c69fa39eecdc0bdd75f8c7a991e530753d59c150 100644 (file)
@@ -745,6 +745,31 @@ class TestBasicRouterOperations(base.BaseTestCase):
                 mock.ANY, ri.router_id,
                 {fip_id: l3_constants.FLOATINGIP_STATUS_DOWN})
 
+    def test_process_router_floatingip_exception(self):
+        agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
+        agent.process_router_floating_ip_addresses = mock.Mock()
+        agent.process_router_floating_ip_addresses.side_effect = RuntimeError
+        with mock.patch.object(
+            agent.plugin_rpc,
+            'update_floatingip_statuses') as mock_update_fip_status:
+            fip_id = _uuid()
+            router = self._prepare_router_data(num_internal_ports=1)
+            router[l3_constants.FLOATINGIP_KEY] = [
+                {'id': fip_id,
+                 'floating_ip_address': '8.8.8.8',
+                 'fixed_ip_address': '7.7.7.7',
+                 'port_id': router[l3_constants.INTERFACE_KEY][0]['id']}]
+
+            ri = l3_agent.RouterInfo(router['id'], self.conf.root_helper,
+                                     self.conf.use_namespaces, router=router)
+            agent.external_gateway_added = mock.Mock()
+            agent.process_router(ri)
+            # Assess the call for putting the floating IP into Error
+            # was performed
+            mock_update_fip_status.assert_called_once_with(
+                mock.ANY, ri.router_id,
+                {fip_id: l3_constants.FLOATINGIP_STATUS_ERROR})
+
     def test_handle_router_snat_rules_add_back_jump(self):
         agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
         ri = mock.MagicMock()