Neutron-lib: use the L3_AGENT* definitions from neutron-lib
This removes deprecation warnings TrivialFix Change-Id: Ia4979c2cafa856efe0f725a74b436f690cea70c2
This commit is contained in:
parent
ee42af1011
commit
deb0e49477
@ -311,12 +311,12 @@ class L3NATAgent(ha.AgentMixin,
|
||||
kwargs['host'] = self.host
|
||||
|
||||
if router.get('distributed') and router.get('ha'):
|
||||
if self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT:
|
||||
if self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT:
|
||||
kwargs['state_change_callback'] = self.enqueue_state_change
|
||||
return dvr_edge_ha_router.DvrEdgeHaRouter(*args, **kwargs)
|
||||
|
||||
if router.get('distributed'):
|
||||
if self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT:
|
||||
if self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT:
|
||||
return dvr_router.DvrEdgeRouter(*args, **kwargs)
|
||||
else:
|
||||
return dvr_local_router.DvrLocalRouter(*args, **kwargs)
|
||||
|
@ -28,7 +28,6 @@ from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy import sql
|
||||
|
||||
from neutron._i18n import _, _LI
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import agentschedulers_db
|
||||
@ -126,8 +125,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
|
||||
def _get_agent_mode(self, agent_db):
|
||||
agent_conf = self.get_configuration_dict(agent_db)
|
||||
return agent_conf.get(n_const.L3_AGENT_MODE,
|
||||
n_const.L3_AGENT_MODE_LEGACY)
|
||||
return agent_conf.get(constants.L3_AGENT_MODE,
|
||||
constants.L3_AGENT_MODE_LEGACY)
|
||||
|
||||
def validate_agent_router_combination(self, context, agent, router):
|
||||
"""Validate if the router can be correctly assigned to the agent.
|
||||
@ -144,10 +143,10 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
|
||||
agent_mode = self._get_agent_mode(agent)
|
||||
|
||||
if agent_mode == n_const.L3_AGENT_MODE_DVR:
|
||||
if agent_mode == constants.L3_AGENT_MODE_DVR:
|
||||
raise l3agentscheduler.DVRL3CannotAssignToDvrAgent()
|
||||
|
||||
if (agent_mode == n_const.L3_AGENT_MODE_LEGACY and
|
||||
if (agent_mode == constants.L3_AGENT_MODE_LEGACY and
|
||||
router.get('distributed')):
|
||||
raise l3agentscheduler.RouterL3AgentMismatch(
|
||||
router_id=router['id'], agent_id=agent['id'])
|
||||
@ -227,7 +226,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
"""
|
||||
agent = self._get_agent(context, agent_id)
|
||||
agent_mode = self._get_agent_mode(agent)
|
||||
if agent_mode == n_const.L3_AGENT_MODE_DVR:
|
||||
if agent_mode == constants.L3_AGENT_MODE_DVR:
|
||||
raise l3agentscheduler.DVRL3CannotRemoveFromDvrAgent()
|
||||
|
||||
self._unbind_router(context, router_id, agent_id)
|
||||
@ -462,10 +461,10 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
||||
continue
|
||||
|
||||
agent_conf = self.get_configuration_dict(l3_agent)
|
||||
agent_mode = agent_conf.get(n_const.L3_AGENT_MODE,
|
||||
n_const.L3_AGENT_MODE_LEGACY)
|
||||
if (agent_mode == n_const.L3_AGENT_MODE_DVR or
|
||||
(agent_mode == n_const.L3_AGENT_MODE_LEGACY and
|
||||
agent_mode = agent_conf.get(constants.L3_AGENT_MODE,
|
||||
constants.L3_AGENT_MODE_LEGACY)
|
||||
if (agent_mode == constants.L3_AGENT_MODE_DVR or
|
||||
(agent_mode == constants.L3_AGENT_MODE_LEGACY and
|
||||
is_router_distributed)):
|
||||
continue
|
||||
|
||||
|
@ -20,7 +20,6 @@ from sqlalchemy import or_
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from neutron.common import constants as const
|
||||
from neutron.common import utils as n_utils
|
||||
|
||||
from neutron.db import agentschedulers_db
|
||||
@ -286,8 +285,8 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
||||
|
||||
# dvr routers are not explicitly scheduled to agents on hosts with
|
||||
# dvr serviceable ports, so need special handling
|
||||
if self._get_agent_mode(agent_db) in [const.L3_AGENT_MODE_DVR,
|
||||
const.L3_AGENT_MODE_DVR_SNAT]:
|
||||
if self._get_agent_mode(agent_db) in [n_const.L3_AGENT_MODE_DVR,
|
||||
n_const.L3_AGENT_MODE_DVR_SNAT]:
|
||||
if not router_ids:
|
||||
result_set |= set(self._get_dvr_router_ids_for_host(
|
||||
context, agent_db['host']))
|
||||
|
@ -1050,9 +1050,9 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
|
||||
def test_dvr_router_csnat_rescheduling(self):
|
||||
helpers.register_l3_agent(
|
||||
host=L3_HOSTA, agent_mode=n_const.L3_AGENT_MODE_DVR_SNAT)
|
||||
host=L3_HOSTA, agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
|
||||
helpers.register_l3_agent(
|
||||
host=L3_HOSTB, agent_mode=n_const.L3_AGENT_MODE_DVR_SNAT)
|
||||
host=L3_HOSTB, agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
|
||||
with self.subnet() as s:
|
||||
net_id = s['subnet']['network_id']
|
||||
self._set_net_external(net_id)
|
||||
@ -1077,9 +1077,9 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
|
||||
|
||||
def test_dvr_router_manual_rescheduling(self):
|
||||
helpers.register_l3_agent(
|
||||
host=L3_HOSTA, agent_mode=n_const.L3_AGENT_MODE_DVR_SNAT)
|
||||
host=L3_HOSTA, agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
|
||||
helpers.register_l3_agent(
|
||||
host=L3_HOSTB, agent_mode=n_const.L3_AGENT_MODE_DVR_SNAT)
|
||||
host=L3_HOSTB, agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
|
||||
with self.subnet() as s:
|
||||
net_id = s['subnet']['network_id']
|
||||
self._set_net_external(net_id)
|
||||
|
@ -23,7 +23,6 @@ from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import constants as n_const
|
||||
from neutron import context
|
||||
from neutron.db import agents_db
|
||||
from neutron.db import db_base_plugin_v2
|
||||
@ -83,9 +82,9 @@ class AgentDBTestMixIn(object):
|
||||
def _register_agent_states(self, lbaas_agents=False):
|
||||
"""Register two L3 agents and two DHCP agents."""
|
||||
l3_hosta = helpers._get_l3_agent_dict(
|
||||
L3_HOSTA, n_const.L3_AGENT_MODE_LEGACY)
|
||||
L3_HOSTA, constants.L3_AGENT_MODE_LEGACY)
|
||||
l3_hostb = helpers._get_l3_agent_dict(
|
||||
L3_HOSTB, n_const.L3_AGENT_MODE_LEGACY)
|
||||
L3_HOSTB, constants.L3_AGENT_MODE_LEGACY)
|
||||
dhcp_hosta = helpers._get_dhcp_agent_dict(DHCP_HOSTA)
|
||||
dhcp_hostc = helpers._get_dhcp_agent_dict(DHCP_HOSTC)
|
||||
helpers.register_l3_agent(host=L3_HOSTA)
|
||||
@ -118,9 +117,9 @@ class AgentDBTestMixIn(object):
|
||||
|
||||
def _register_dvr_agents(self):
|
||||
dvr_snat_agent = helpers.register_l3_agent(
|
||||
host=L3_HOSTA, agent_mode=n_const.L3_AGENT_MODE_DVR_SNAT)
|
||||
host=L3_HOSTA, agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
|
||||
dvr_agent = helpers.register_l3_agent(
|
||||
host=L3_HOSTB, agent_mode=n_const.L3_AGENT_MODE_DVR)
|
||||
host=L3_HOSTB, agent_mode=constants.L3_AGENT_MODE_DVR)
|
||||
return [dvr_snat_agent, dvr_agent]
|
||||
|
||||
def _register_l3_agent(self, host):
|
||||
|
Loading…
Reference in New Issue
Block a user