Merge "Refactor some l3_dvr_db code"

This commit is contained in:
Zuul 2019-01-18 03:58:13 +00:00 committed by Gerrit Code Review
commit 12cc3721a6

View File

@ -965,12 +965,8 @@ class _DVRAgentInterfaceMixin(object):
return return
fip = fips[0] fip = fips[0]
network_id = fip.get('floating_network_id') network_id = fip.get('floating_network_id')
agent_gw_port = self.create_fip_agent_gw_port_if_not_exists( self.create_fip_agent_gw_port_if_not_exists(
context.elevated(), network_id, host) context.elevated(), network_id, host)
LOG.debug("Port-in-Migration: Floatingip Agent Gateway port "
"%(gw)s created for the future host: %(dest_host)s",
{'gw': agent_gw_port,
'dest_host': host})
def create_fip_agent_gw_port_if_not_exists( def create_fip_agent_gw_port_if_not_exists(
self, context, network_id, host): self, context, network_id, host):
@ -994,11 +990,11 @@ class _DVRAgentInterfaceMixin(object):
return return
if l3_agent_db: if l3_agent_db:
LOG.debug("Agent ID exists: %s", l3_agent_db['id']) LOG.debug("Agent ID exists: %s", l3_agent_db['id'])
f_port = self._get_agent_gw_ports_exist_for_network( agent_port = self._get_agent_gw_ports_exist_for_network(
context, network_id, host, l3_agent_db['id']) context, network_id, host, l3_agent_db['id'])
if not f_port: if not agent_port:
LOG.info('Agent Gateway port does not exist,' LOG.info("Floating IP Agent Gateway port does not exist, "
' so create one: %s', f_port) "creating one")
port_data = {'tenant_id': '', port_data = {'tenant_id': '',
'network_id': network_id, 'network_id': network_id,
'device_id': l3_agent_db['id'], 'device_id': l3_agent_db['id'],
@ -1008,15 +1004,16 @@ class _DVRAgentInterfaceMixin(object):
'name': ''} 'name': ''}
agent_port = plugin_utils.create_port( agent_port = plugin_utils.create_port(
self._core_plugin, context, {'port': port_data}) self._core_plugin, context, {'port': port_data})
if agent_port: if not agent_port:
self._populate_mtu_and_subnets_for_ports(context, msg = _("Unable to create Floating IP Agent Gateway port")
[agent_port]) raise n_exc.BadRequest(resource='router', msg=msg)
return agent_port LOG.debug("Floating IP Agent Gateway port %(gw)s created "
msg = _("Unable to create the Agent Gateway Port") "for the destination host: %(dest_host)s",
raise n_exc.BadRequest(resource='router', msg=msg) {'gw': agent_port,
else: 'dest_host': host})
self._populate_mtu_and_subnets_for_ports(context, [f_port])
return f_port self._populate_mtu_and_subnets_for_ports(context, [agent_port])
return agent_port
def _generate_arp_table_and_notify_agent( def _generate_arp_table_and_notify_agent(
self, context, fixed_ip, mac_address, notifier): self, context, fixed_ip, mac_address, notifier):