ex_gw_port['network_id'])
LOG.debug("FloatingIP agent gateway port received from the plugin: "
"%s", fip_agent_port)
+ is_first = False
if floating_ips:
is_first = self.fip_ns.subscribe(self.router_id)
if is_first and fip_agent_port:
self.fip_ns.create_gateway_port(fip_agent_port)
if self.fip_ns.agent_gateway_port and floating_ips:
- if self.dist_fip_count == 0:
+ if self.dist_fip_count == 0 or is_first:
self.fip_ns.create_rtr_2_fip_link(self)
# kicks the FW Agent to add rules for the IR namespace if
ri.fip_ns = agent.get_fip_ns(ext_gw_port['network_id'])
ri.dist_fip_count = 0
ri.fip_ns.subscribe = mock.Mock()
+ ri.fip_ns.agent_router_gateway = mock.Mock()
with contextlib.nested(mock.patch.object(ri,
'get_floating_ips'),
self.assertTrue(fips.called)
self.assertEqual(ri.fip_ns.agent_gateway_port,
agent_gateway_port[0])
+ self.assertTrue(ri.rtr_fip_subnet)
+
+ def test_create_dvr_fip_interfaces_for_restart_l3agent_case(self):
+ fake_floatingips = {'floatingips': [
+ {'id': _uuid(),
+ 'floating_ip_address': '20.0.0.3',
+ 'fixed_ip_address': '192.168.0.1',
+ 'floating_network_id': _uuid(),
+ 'port_id': _uuid(),
+ 'host': HOSTNAME}]}
+ agent_gateway_port = (
+ [{'fixed_ips': [
+ {'ip_address': '20.0.0.30',
+ 'prefixlen': 24,
+ 'subnet_id': 'subnet_id'}],
+ 'subnets': [
+ {'id': 'subnet_id',
+ 'gateway_ip': '20.0.0.1'}],
+ 'id': _uuid(),
+ 'network_id': 'fake_network_id',
+ 'mac_address': 'ca:fe:de:ad:be:ef'}]
+ )
+
+ router = prepare_router_data(enable_snat=True)
+ router[l3_constants.FLOATINGIP_KEY] = fake_floatingips['floatingips']
+ router[l3_constants.FLOATINGIP_AGENT_INTF_KEY] = agent_gateway_port
+ router['distributed'] = True
+ agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
+ ri = dvr_router.DvrRouter(
+ agent, HOSTNAME, router['id'], router, **self.ri_kwargs)
+ ext_gw_port = ri.router.get('gw_port')
+ ri.fip_ns = agent.get_fip_ns(ext_gw_port['network_id'])
+ ri.fip_ns.subscribe = mock.Mock(return_value=True)
+ ri.fip_ns.agent_router_gateway = mock.Mock()
+ ri.rtr_fip_subnet = None
+ ri.dist_fip_count = 1
+
+ with contextlib.nested(mock.patch.object(
+ ri, 'get_floating_ips'),
+ mock.patch.object(
+ ri, 'get_floating_agent_gw_interface')
+ ) as (fips,
+ fip_gw_port):
+ fips.return_value = fake_floatingips
+ fip_gw_port.return_value = agent_gateway_port[0]
+ ri.create_dvr_fip_interfaces(ext_gw_port)
+ self.assertTrue(fip_gw_port.called)
+ self.assertTrue(fips.called)
+ self.assertEqual(ri.fip_ns.agent_gateway_port,
+ agent_gateway_port[0])
+ self.assertTrue(ri.rtr_fip_subnet)
def test_process_router_cent_floating_ip_add(self):
fake_floatingips = {'floatingips': [