Merge "use is_extension_supported from neutron-lib"
This commit is contained in:
commit
7f07c05c30
|
@ -13,6 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
|
@ -24,7 +25,6 @@ import oslo_messaging
|
|||
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -148,7 +148,7 @@ class DhcpAgentNotifyAPI(object):
|
|||
def _notify_agents(self, context, method, payload, network_id):
|
||||
"""Notify all the agents that are hosting the network."""
|
||||
# fanout is required as we do not know who is "listening"
|
||||
no_agents = not utils.is_extension_supported(
|
||||
no_agents = not extensions.is_extension_supported(
|
||||
self.plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS)
|
||||
fanout_required = method == 'network_delete_end' or no_agents
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import random
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -24,7 +25,6 @@ import oslo_messaging
|
|||
from neutron.api.rpc.agentnotifiers import utils as ag_utils
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -90,7 +90,7 @@ class L3AgentNotifyAPI(object):
|
|||
LOG.error('No plugin for L3 routing registered. Cannot notify '
|
||||
'agents with the message %s', method)
|
||||
return
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
adminContext = (context.is_admin and
|
||||
context or context.elevated())
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -20,7 +21,6 @@ import oslo_messaging
|
|||
|
||||
from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron.common import utils
|
||||
from neutron.db import agentschedulers_db
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -81,7 +81,7 @@ class MeteringAgentNotifyAPI(object):
|
|||
def _notification(self, context, method, routers):
|
||||
"""Notify all the agents that are hosting the routers."""
|
||||
plugin = directory.get_plugin(plugin_constants.L3)
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
self._agent_notification(context, method, routers)
|
||||
else:
|
||||
|
|
|
@ -18,6 +18,7 @@ import itertools
|
|||
import operator
|
||||
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.callbacks import resources
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions
|
||||
|
@ -80,7 +81,7 @@ class DhcpRpcCallback(object):
|
|||
"""Retrieve and return a list of the active networks."""
|
||||
host = kwargs.get('host')
|
||||
plugin = directory.get_plugin()
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
if cfg.CONF.network_auto_schedule:
|
||||
plugin.auto_schedule_networks(context, host)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context as neutron_context
|
||||
from neutron_lib import exceptions
|
||||
|
@ -25,7 +26,6 @@ from oslo_log import log as logging
|
|||
import oslo_messaging
|
||||
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import utils
|
||||
from neutron.db import api as db_api
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ class L3RpcCallback(object):
|
|||
that the port is indeed ACTIVE by reacting to the port update and
|
||||
calling update_device_up.
|
||||
"""
|
||||
if not utils.is_extension_supported(
|
||||
if not extensions.is_extension_supported(
|
||||
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
|
||||
return
|
||||
device_filter = {
|
||||
|
@ -98,7 +98,7 @@ class L3RpcCallback(object):
|
|||
This will autoschedule unhosted routers to l3 agent on <host> and then
|
||||
return all ids of routers scheduled to it.
|
||||
"""
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
if cfg.CONF.router_auto_schedule:
|
||||
self.l3plugin.auto_schedule_routers(context, host)
|
||||
|
@ -116,14 +116,14 @@ class L3RpcCallback(object):
|
|||
router_ids = kwargs.get('router_ids')
|
||||
host = kwargs.get('host')
|
||||
context = neutron_context.get_admin_context()
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
|
||||
routers = (
|
||||
self.l3plugin.list_active_sync_routers_on_active_l3_agent(
|
||||
context, host, router_ids))
|
||||
else:
|
||||
routers = self.l3plugin.get_sync_data(context, router_ids)
|
||||
if utils.is_extension_supported(
|
||||
if extensions.is_extension_supported(
|
||||
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
|
||||
self._ensure_host_set_on_ports(context, host, routers)
|
||||
return routers
|
||||
|
|
|
@ -121,11 +121,6 @@ def get_first_host_ip(net, ip_version):
|
|||
return str(netaddr.IPAddress(net.first + 1, ip_version))
|
||||
|
||||
|
||||
def is_extension_supported(plugin, ext_alias):
|
||||
return ext_alias in getattr(
|
||||
plugin, "supported_extension_aliases", [])
|
||||
|
||||
|
||||
def log_opt_values(log):
|
||||
cfg.CONF.log_opt_values(log, logging.DEBUG)
|
||||
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
from neutron_lib.plugins import constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import utils
|
||||
from neutron.db import _resource_extend as resource_extend
|
||||
from neutron.db import l3_attrs_db
|
||||
|
||||
|
@ -33,8 +33,8 @@ class RouterAvailabilityZoneMixin(l3_attrs_db.ExtraAttributesMixin):
|
|||
@resource_extend.extends([l3_apidef.ROUTERS])
|
||||
def _add_az_to_response(router_res, router_db):
|
||||
l3_plugin = directory.get_plugin(constants.L3)
|
||||
if not utils.is_extension_supported(l3_plugin,
|
||||
'router_availability_zone'):
|
||||
if not extensions.is_extension_supported(
|
||||
l3_plugin, 'router_availability_zone'):
|
||||
return
|
||||
router_res['availability_zones'] = (
|
||||
l3_plugin.get_router_availability_zones(router_db))
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
from neutron_lib.api.definitions import dns as dns_apidef
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import dns as dns_exc
|
||||
|
@ -22,7 +23,6 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.common import utils
|
||||
from neutron.db import _resource_extend as resource_extend
|
||||
from neutron.objects import floatingip as fip_obj
|
||||
from neutron.objects import network
|
||||
|
@ -118,8 +118,8 @@ class DNSDbMixin(object):
|
|||
def _process_dns_floatingip_update_precommit(self, context,
|
||||
floatingip_data):
|
||||
# expects to be called within a plugin's session
|
||||
if not utils.is_extension_supported(self._core_plugin,
|
||||
dns_apidef.ALIAS):
|
||||
if not extensions.is_extension_supported(
|
||||
self._core_plugin, dns_apidef.ALIAS):
|
||||
return
|
||||
if not self.dns_driver:
|
||||
return
|
||||
|
@ -175,11 +175,11 @@ class DNSDbMixin(object):
|
|||
[floatingip_data['floating_ip_address']])
|
||||
|
||||
def _process_dns_floatingip_delete(self, context, floatingip_data):
|
||||
if not utils.is_extension_supported(self._core_plugin,
|
||||
dns_apidef.ALIAS):
|
||||
if not extensions.is_extension_supported(
|
||||
self._core_plugin, dns_apidef.ALIAS):
|
||||
return
|
||||
dns_data_db = fip_obj.FloatingIPDNS.get_object(context,
|
||||
floatingip_id=floatingip_data['id'])
|
||||
dns_data_db = fip_obj.FloatingIPDNS.get_object(
|
||||
context, floatingip_id=floatingip_data['id'])
|
||||
if dns_data_db:
|
||||
self._delete_floatingip_from_external_dns_service(
|
||||
context, dns_data_db['published_dns_domain'],
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
|
@ -22,7 +23,6 @@ from oslo_log import log as logging
|
|||
import oslo_messaging
|
||||
|
||||
from neutron.agent.common import utils as agent_utils
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.conf.db import l3_agentschedulers_db
|
||||
from neutron.db import agentschedulers_db
|
||||
from neutron.db.models import l3agent as rb_model
|
||||
|
@ -274,8 +274,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||
|
||||
def _get_active_l3_agent_routers_sync_data(self, context, host, agent,
|
||||
router_ids):
|
||||
if n_utils.is_extension_supported(self,
|
||||
constants.L3_HA_MODE_EXT_ALIAS):
|
||||
if extensions.is_extension_supported(
|
||||
self, constants.L3_HA_MODE_EXT_ALIAS):
|
||||
return self.get_ha_sync_data_for_host(context, host, agent,
|
||||
router_ids=router_ids,
|
||||
active=True)
|
||||
|
|
|
@ -18,6 +18,7 @@ import random
|
|||
import netaddr
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import exceptions
|
||||
|
@ -108,17 +109,17 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
def _is_dns_integration_supported(self):
|
||||
if self._dns_integration is None:
|
||||
self._dns_integration = (
|
||||
utils.is_extension_supported(self._core_plugin,
|
||||
'dns-integration') or
|
||||
utils.is_extension_supported(self._core_plugin,
|
||||
'dns-domain-ports'))
|
||||
extensions.is_extension_supported(
|
||||
self._core_plugin, 'dns-integration') or
|
||||
extensions.is_extension_supported(
|
||||
self._core_plugin, 'dns-domain-ports'))
|
||||
return self._dns_integration
|
||||
|
||||
@property
|
||||
def _is_fip_qos_supported(self):
|
||||
if self._fip_qos is None:
|
||||
# Check L3 service plugin
|
||||
self._fip_qos = utils.is_extension_supported(
|
||||
self._fip_qos = extensions.is_extension_supported(
|
||||
self, qos_fip.FIP_QOS_ALIAS)
|
||||
return self._fip_qos
|
||||
|
||||
|
@ -327,7 +328,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||
# first get plugin supporting l3 agent scheduling
|
||||
# (either l3 service plugin or core_plugin)
|
||||
l3_plugin = directory.get_plugin(plugin_constants.L3)
|
||||
if (not utils.is_extension_supported(
|
||||
if (not extensions.is_extension_supported(
|
||||
l3_plugin,
|
||||
constants.L3_AGENT_SCHEDULER_EXT_ALIAS) or
|
||||
l3_plugin.router_scheduler is None):
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
|
@ -226,7 +227,8 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
|||
|
||||
def _get_active_l3_agent_routers_sync_data(self, context, host, agent,
|
||||
router_ids):
|
||||
if n_utils.is_extension_supported(self, n_const.L3_HA_MODE_EXT_ALIAS):
|
||||
if extensions.is_extension_supported(
|
||||
self, n_const.L3_HA_MODE_EXT_ALIAS):
|
||||
return self.get_ha_sync_data_for_host(context, host, agent,
|
||||
router_ids=router_ids,
|
||||
active=True)
|
||||
|
|
|
@ -19,6 +19,7 @@ import netaddr
|
|||
from neutron_lib.api.definitions import port as port_def
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api.definitions import provider_net as providernet
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
|
@ -629,7 +630,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
|||
agent_mode in [constants.L3_AGENT_MODE_DVR_SNAT,
|
||||
constants.L3_AGENT_MODE_DVR,
|
||||
constants.L3_AGENT_MODE_DVR_NO_EXTERNAL])
|
||||
if (dvr_agent_mode and n_utils.is_extension_supported(
|
||||
if (dvr_agent_mode and extensions.is_extension_supported(
|
||||
self, constants.L3_DISTRIBUTED_EXT_ALIAS)):
|
||||
# DVR has to be handled differently
|
||||
sync_data = self._get_dvr_sync_data(context, host, agent,
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import constants as consts
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
from neutron.common import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -37,7 +37,7 @@ class MeteringRpcCallbacks(object):
|
|||
|
||||
metering_data = self.meter_plugin.get_sync_data_metering(context)
|
||||
host = kwargs.get('host')
|
||||
if not utils.is_extension_supported(
|
||||
if not extensions.is_extension_supported(
|
||||
l3_plugin, consts.L3_AGENT_SCHEDULER_EXT_ALIAS) or not host:
|
||||
return metering_data
|
||||
else:
|
||||
|
|
|
@ -24,6 +24,7 @@ from neutron_lib.api.definitions import port_security as psec
|
|||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api.definitions import subnet as subnet_def
|
||||
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.api.validators import availability_zone as az_validator
|
||||
from neutron_lib.callbacks import events
|
||||
|
@ -811,7 +812,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
self.type_manager.extend_network_dict_provider(context, result)
|
||||
|
||||
# Update the transparent vlan if configured
|
||||
if utils.is_extension_supported(self, 'vlan-transparent'):
|
||||
if extensions.is_extension_supported(self, 'vlan-transparent'):
|
||||
vlt = vlan_apidef.get_vlan_transparent(net_data)
|
||||
net_db['vlan_transparent'] = vlt
|
||||
result['vlan_transparent'] = vlt
|
||||
|
@ -1272,7 +1273,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups()
|
||||
elif (not
|
||||
self._check_update_deletes_security_groups(port)):
|
||||
if not utils.is_extension_supported(self, 'security-group'):
|
||||
if not extensions.is_extension_supported(self, 'security-group'):
|
||||
return
|
||||
# Update did not have security groups passed in. Check
|
||||
# that port does not have any security groups already on it.
|
||||
|
|
|
@ -17,13 +17,13 @@ import collections
|
|||
from neutron_lib.api import converters
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.api.definitions import provider_net as provider
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.plugins.ml2 import api
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.objects import trunk as trunk_objects
|
||||
from neutron.services.trunk import constants
|
||||
from neutron.services.trunk import exceptions as trunk_exc
|
||||
|
@ -200,8 +200,8 @@ class SubPortsValidator(object):
|
|||
|
||||
core_plugin = directory.get_plugin()
|
||||
if (any_has_inherit and
|
||||
not n_utils.is_extension_supported(core_plugin,
|
||||
provider.ALIAS)):
|
||||
not extensions.is_extension_supported(
|
||||
core_plugin, provider.ALIAS)):
|
||||
msg = _("Cannot accept segmentation type %s") % constants.INHERIT
|
||||
raise n_exc.InvalidInput(error_message=msg)
|
||||
|
||||
|
@ -223,7 +223,7 @@ class SubPortsValidator(object):
|
|||
# To speed up the request, record the network MTU for each
|
||||
# subport to avoid hitting the DB more than necessary. Do
|
||||
# that only if the extension is available.
|
||||
if n_utils.is_extension_supported(core_plugin, 'net-mtu'):
|
||||
if extensions.is_extension_supported(core_plugin, 'net-mtu'):
|
||||
subport_mtus[port['port_id']] = net[api.MTU]
|
||||
return subport_mtus
|
||||
|
||||
|
@ -235,7 +235,7 @@ class SubPortsValidator(object):
|
|||
"""
|
||||
core_plugin = directory.get_plugin()
|
||||
|
||||
if not n_utils.is_extension_supported(core_plugin, 'net-mtu'):
|
||||
if not extensions.is_extension_supported(core_plugin, 'net-mtu'):
|
||||
return
|
||||
|
||||
try:
|
||||
|
|
|
@ -12,16 +12,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from neutron.common import utils
|
||||
|
||||
|
||||
def get_agent_types_by_host(context, host):
|
||||
"""Return the agent types registered on the host."""
|
||||
agent_types = []
|
||||
core_plugin = directory.get_plugin()
|
||||
if utils.is_extension_supported(core_plugin, 'agent'):
|
||||
if extensions.is_extension_supported(core_plugin, 'agent'):
|
||||
agents = core_plugin.get_agents(
|
||||
context.elevated(), filters={'host': [host]})
|
||||
agent_types = [a['agent_type'] for a in agents]
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import datetime
|
||||
|
||||
import mock
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
|
@ -24,7 +25,6 @@ from oslo_utils import timeutils
|
|||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
|
||||
from neutron.common import utils
|
||||
from neutron.db.agentschedulers_db import cfg
|
||||
from neutron.objects import agent as agent_obj
|
||||
from neutron.tests import base
|
||||
|
@ -37,7 +37,7 @@ class TestDhcpAgentNotifyAPI(base.BaseTestCase):
|
|||
self.notifier = (
|
||||
dhcp_rpc_agent_api.DhcpAgentNotifyAPI(plugin=mock.Mock()))
|
||||
|
||||
mock_util_p = mock.patch.object(utils, 'is_extension_supported')
|
||||
mock_util_p = mock.patch.object(extensions, 'is_extension_supported')
|
||||
mock_log_p = mock.patch.object(dhcp_rpc_agent_api, 'LOG')
|
||||
mock_fanout_p = mock.patch.object(self.notifier, '_fanout_message')
|
||||
mock_cast_p = mock.patch.object(self.notifier, '_cast_message')
|
||||
|
|
Loading…
Reference in New Issue