raise n_exc.FloatingIpSetupException('L3 agent failure to setup '
'NAT for floating IPs')
- def _configure_fip_addresses(self, ri, ex_gw_port):
+ def _configure_fip_addresses(self, ri, interface_name):
try:
return self.process_router_floating_ip_addresses(
- ri, ex_gw_port)
+ ri, interface_name)
except Exception:
# TODO(salv-orlando): Less broad catching
raise n_exc.FloatingIpSetupException('L3 agent failure to setup '
# Once NAT rules for floating IPs are safely in place
# configure their addresses on the external gateway port
- fip_statuses = self._configure_fip_addresses(ri, ex_gw_port)
+ interface_name = self._get_external_device_interface_name(
+ ri, ex_gw_port)
+ fip_statuses = self._configure_fip_addresses(ri, interface_name)
except (n_exc.FloatingIpSetupException, n_exc.IpTablesApplyException):
# All floating IPs must be put in error state
else:
return set([addr['cidr'] for addr in device.addr.list()])
- def process_router_floating_ip_addresses(self, ri, ex_gw_port):
+ def process_router_floating_ip_addresses(self, ri, interface_name):
"""Configure IP addresses on router's external gateway interface.
Ensures addresses for existing floating IPs and cleans up
"""
fip_statuses = {}
- interface_name = self._get_external_device_interface_name(
- ri, ex_gw_port)
if interface_name is None:
return fip_statuses
def external_gateway_removed(self, ri, ex_gw_port, interface_name):
if ri.router['distributed']:
self.process_router_floating_ip_nat_rules(ri)
- self.process_router_floating_ip_addresses(ri, ex_gw_port)
+ interface_name = self._get_external_device_interface_name(
+ ri, ex_gw_port)
+ self.process_router_floating_ip_addresses(ri, interface_name)
for p in ri.internal_ports:
internal_interface = self.get_internal_device_name(p['id'])
self._snat_redirect_remove(ri, p, internal_interface)
'port_id': _uuid(),
'host': HOSTNAME}]}
agent.process_router(ri)
- ex_gw_port = agent._get_ex_gw_port(ri)
agent.process_router_floating_ip_addresses.assert_called_with(
- ri, ex_gw_port)
+ ri, mock.ANY)
agent.process_router_floating_ip_addresses.reset_mock()
agent.process_router_floating_ip_nat_rules.assert_called_with(ri)
agent.process_router_floating_ip_nat_rules.reset_mock()
router[l3_constants.FLOATINGIP_KEY] = fake_floatingips2['floatingips']
agent.process_router(ri)
- ex_gw_port = agent._get_ex_gw_port(ri)
agent.process_router_floating_ip_addresses.assert_called_with(
- ri, ex_gw_port)
+ ri, mock.ANY)
agent.process_router_floating_ip_addresses.reset_mock()
agent.process_router_floating_ip_nat_rules.assert_called_with(ri)
agent.process_router_floating_ip_nat_rules.reset_mock()
ri.router['gw_port']['fixed_ips'][0]['ip_address'] = str(old_ip + 1)
agent.process_router(ri)
- ex_gw_port = agent._get_ex_gw_port(ri)
agent.process_router_floating_ip_addresses.reset_mock()
agent.process_router_floating_ip_nat_rules.reset_mock()
self.assertEqual(agent.external_gateway_added.call_count, 0)
# remove just the floating ips
del router[l3_constants.FLOATINGIP_KEY]
agent.process_router(ri)
- ex_gw_port = agent._get_ex_gw_port(ri)
agent.process_router_floating_ip_addresses.assert_called_with(
- ri, ex_gw_port)
+ ri, mock.ANY)
agent.process_router_floating_ip_addresses.reset_mock()
agent.process_router_floating_ip_nat_rules.assert_called_with(ri)
agent.process_router_floating_ip_nat_rules.reset_mock()