Fix static strings with labels for DVR
There are couple of static strings introduced for DVR configuration such as the L3 agent mode. This patch would clean up the static strings with the labels. Closes-Bug: #1411351 Change-Id: I143262e62ee994e6c01d63e4ea7d5f6292de8286
This commit is contained in:
parent
87663eb763
commit
171d4a6f00
neutron
@ -815,7 +815,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
self._snat_redirect_add(ri, gateway['fixed_ips'][0]
|
||||
['ip_address'], p, id_name)
|
||||
|
||||
if (self.conf.agent_mode == 'dvr_snat' and
|
||||
if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT and
|
||||
self.get_gw_port_host(ri.router) == self.host):
|
||||
self._create_dvr_gateway(ri, ex_gw_port, interface_name,
|
||||
snat_ports)
|
||||
@ -843,7 +843,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
def external_gateway_updated(self, ri, ex_gw_port, interface_name):
|
||||
preserve_ips = []
|
||||
if ri.router['distributed']:
|
||||
if (self.conf.agent_mode == 'dvr_snat' and
|
||||
if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT and
|
||||
self.get_gw_port_host(ri.router) == self.host):
|
||||
ns_name = self.get_snat_ns_name(ri.router['id'])
|
||||
else:
|
||||
@ -898,8 +898,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
internal_interface = self.get_internal_device_name(p['id'])
|
||||
self._snat_redirect_remove(ri, p, internal_interface)
|
||||
|
||||
if self.conf.agent_mode == 'dvr_snat' and (
|
||||
self.get_gw_port_host(ri.router) == self.host):
|
||||
if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT
|
||||
and self.get_gw_port_host(ri.router) == self.host):
|
||||
ns_name = self.get_snat_ns_name(ri.router['id'])
|
||||
else:
|
||||
# not hosting agent - no work to do
|
||||
@ -971,8 +971,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
if sn_port:
|
||||
self._snat_redirect_add(ri, sn_port['fixed_ips'][0]
|
||||
['ip_address'], port, interface_name)
|
||||
if (self.conf.agent_mode == 'dvr_snat' and
|
||||
self.get_gw_port_host(ri.router) == self.host):
|
||||
if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT
|
||||
and self.get_gw_port_host(ri.router) == self.host):
|
||||
ns_name = self.get_snat_ns_name(ri.router['id'])
|
||||
self._set_subnet_info(sn_port)
|
||||
interface_name = (
|
||||
@ -991,8 +991,8 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback,
|
||||
if ri.router['distributed'] and ri.ex_gw_port:
|
||||
# DVR handling code for SNAT
|
||||
self._snat_redirect_remove(ri, port, interface_name)
|
||||
if self.conf.agent_mode == 'dvr_snat' and (
|
||||
ri.ex_gw_port['binding:host_id'] == self.host):
|
||||
if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT
|
||||
and ri.ex_gw_port['binding:host_id'] == self.host):
|
||||
snat_port = self._map_internal_interfaces(ri, port,
|
||||
ri.snat_ports)
|
||||
if snat_port:
|
||||
|
@ -43,6 +43,10 @@ DEVICE_OWNER_LOADBALANCER = "neutron:LOADBALANCER"
|
||||
# DEVICE_OWNER_ROUTER_HA_INTF is a special case and so is not included.
|
||||
ROUTER_INTERFACE_OWNERS = (DEVICE_OWNER_ROUTER_INTF,
|
||||
DEVICE_OWNER_DVR_INTERFACE)
|
||||
L3_AGENT_MODE_DVR = 'dvr'
|
||||
L3_AGENT_MODE_DVR_SNAT = 'dvr_snat'
|
||||
L3_AGENT_MODE_LEGACY = 'legacy'
|
||||
L3_AGENT_MODE = 'agent_mode'
|
||||
|
||||
DEVICE_ID_RESERVED_DHCP_PORT = "reserved_dhcp_port"
|
||||
|
||||
|
@ -134,17 +134,21 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
"""
|
||||
is_distributed = router.get('distributed')
|
||||
agent_conf = self.get_configuration_dict(agent)
|
||||
agent_mode = agent_conf.get('agent_mode', 'legacy')
|
||||
router_type = ('distributed' if is_distributed else 'centralized')
|
||||
agent_mode = agent_conf.get(constants.L3_AGENT_MODE,
|
||||
constants.L3_AGENT_MODE_LEGACY)
|
||||
router_type = (
|
||||
'distributed' if is_distributed else
|
||||
'centralized')
|
||||
|
||||
is_agent_router_types_incompatible = (
|
||||
agent_mode == 'dvr' and not is_distributed
|
||||
or agent_mode == 'legacy' and is_distributed
|
||||
agent_mode == constants.L3_AGENT_MODE_DVR and not is_distributed
|
||||
or agent_mode == constants.L3_AGENT_MODE_LEGACY and is_distributed
|
||||
)
|
||||
if is_agent_router_types_incompatible:
|
||||
raise l3agentscheduler.RouterL3AgentMismatch(
|
||||
router_type=router_type, router_id=router['id'],
|
||||
agent_mode=agent_mode, agent_id=agent['id'])
|
||||
if agent_mode == 'dvr' and is_distributed:
|
||||
if agent_mode == constants.L3_AGENT_MODE_DVR and is_distributed:
|
||||
raise l3agentscheduler.DVRL3CannotAssignToDvrAgent(
|
||||
router_type=router_type, router_id=router['id'],
|
||||
agent_id=agent['id'])
|
||||
@ -400,8 +404,9 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
continue
|
||||
|
||||
agent_conf = self.get_configuration_dict(l3_agent)
|
||||
agent_mode = agent_conf.get('agent_mode', 'legacy')
|
||||
if agent_mode != 'dvr_snat':
|
||||
agent_mode = agent_conf.get(constants.L3_AGENT_MODE,
|
||||
constants.L3_AGENT_MODE_LEGACY)
|
||||
if agent_mode != constants.L3_AGENT_MODE_DVR_SNAT:
|
||||
continue
|
||||
|
||||
router_id = agent_conf.get('router_id', None)
|
||||
@ -436,7 +441,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
'handle_internal_only_routers', True)
|
||||
gateway_external_network_id = agent_conf.get(
|
||||
'gateway_external_network_id', None)
|
||||
agent_mode = agent_conf.get('agent_mode', 'legacy')
|
||||
agent_mode = agent_conf.get(constants.L3_AGENT_MODE,
|
||||
constants.L3_AGENT_MODE_LEGACY)
|
||||
if not use_namespaces and router_id != sync_router['id']:
|
||||
continue
|
||||
ex_net_id = (sync_router['external_gateway_info'] or {}).get(
|
||||
@ -446,10 +452,13 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
ex_net_id != gateway_external_network_id)):
|
||||
continue
|
||||
is_router_distributed = sync_router.get('distributed', False)
|
||||
if agent_mode in ('legacy', 'dvr_snat') and (
|
||||
if agent_mode in (
|
||||
constants.L3_AGENT_MODE_LEGACY,
|
||||
constants.L3_AGENT_MODE_DVR_SNAT) and (
|
||||
not is_router_distributed):
|
||||
candidates.append(l3_agent)
|
||||
elif is_router_distributed and agent_mode.startswith('dvr') and (
|
||||
elif is_router_distributed and agent_mode.startswith(
|
||||
constants.L3_AGENT_MODE_DVR) and (
|
||||
self.check_ports_exist_on_l3agent(
|
||||
context, l3_agent, sync_router['id'])):
|
||||
candidates.append(l3_agent)
|
||||
|
@ -262,7 +262,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin):
|
||||
|
||||
min_agents = cfg.CONF.min_l3_agents_per_router
|
||||
num_agents = len(self.get_l3_agents(context,
|
||||
filters={'agent_modes': ['legacy', 'dvr_snat']}))
|
||||
filters={'agent_modes': [constants.L3_AGENT_MODE_LEGACY,
|
||||
constants.L3_AGENT_MODE_DVR_SNAT]}))
|
||||
max_agents = cfg.CONF.max_l3_agents_per_router
|
||||
if max_agents:
|
||||
if max_agents > num_agents:
|
||||
|
Loading…
x
Reference in New Issue
Block a user