# 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
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()