]> 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)
committerYong Sheng Gong <gongysh@unitedstack.com>
Wed, 2 Apr 2014 00:44:38 +0000 (08:44 +0800)
Change-Id: I267f174a0e2e611ec007404c7b44e2c73a359c38
Closes-Bug: 1294526

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

index 6fa97ea8cd1d239498bf1a401f1eb8496febdc96..ff6ec788ee8982afc888ee728464fe5e7402f22e 100644 (file)
@@ -473,7 +473,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 201e9d74c04e6b1726dba8862c064ce9663217df..cb5c3ed80c8412ae903468c45f218579a0f3a9a8 100644 (file)
@@ -744,6 +744,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()