From: Yong Sheng Gong Date: Wed, 19 Mar 2014 08:14:33 +0000 (+0800) Subject: use floatingip's ID as key instead of itself X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=fd757c79af3503b28225fe65e089ff7cda17c678;p=openstack-build%2Fneutron-build.git use floatingip's ID as key instead of itself Change-Id: I267f174a0e2e611ec007404c7b44e2c73a359c38 Closes-Bug: 1294526 (cherry picked from commit 7120325d37df414d8de084c5b41fdfbea3a06565) --- diff --git a/neutron/agent/l3_agent.py b/neutron/agent/l3_agent.py index 5b7d709d6..630e88bf9 100644 --- a/neutron/agent/l3_agent.py +++ b/neutron/agent/l3_agent.py @@ -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 diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index d390ac29b..c69fa39ee 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -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()