use api def ALIAS in supported_extension_aliases

Today a number of classes define their supported_extension_aliases
using static strings rather than API definition ALIASes. This patch
switches them to use the ALIAS where applicable.

Change-Id: Ic82a971a41993e4a555132b6363b2cc96e64ba2a
This commit is contained in:
Boden R 2019-02-19 11:33:34 -07:00
parent 214d7e831e
commit 0f20c9594f
7 changed files with 128 additions and 96 deletions

View File

@ -18,6 +18,8 @@
import weakref
from neutron_lib.agent import topics
from neutron_lib.api.definitions import agent as agent_apidef
from neutron_lib.api.definitions import dhcpagentscheduler
from neutron_lib import constants as const
from neutron_lib import rpc as n_rpc
from oslo_concurrency import lockutils
@ -101,7 +103,7 @@ class DhcpMetadataAccess(object):
cfg.CONF.network_scheduler_driver
)
self.supported_extension_aliases.extend(
['agent', 'dhcp_agent_scheduler'])
[agent_apidef.ALIAS, dhcpagentscheduler.ALIAS])
def _setup_nsx_dhcp_metadata(self):
self._check_services_requirements()
@ -134,7 +136,8 @@ class DhcpMetadataAccess(object):
return notifier
def _init_extensions(self):
extensions = (lsn.EXT_ALIAS, 'agent', 'dhcp_agent_scheduler')
extensions = (lsn.EXT_ALIAS, agent_apidef.ALIAS,
dhcpagentscheduler.ALIAS)
for ext in extensions:
if ext in self.supported_extension_aliases:
self.supported_extension_aliases.remove(ext)

View File

@ -14,10 +14,22 @@
# under the License.
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
from neutron_lib.api.definitions import external_net as enet_apidef
from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
from neutron_lib.api import validators
from neutron_lib import constants
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
from neutron_lib.exceptions import port_security as psec_exc
from neutron_lib.plugins import utils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
@ -38,16 +50,7 @@ from neutron.db import vlantransparent_db as vlan_ext_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.quota import resource_registry
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
from neutron_lib.api import validators
from neutron_lib import constants
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import utils
import vmware_nsx
from vmware_nsx._i18n import _
@ -80,16 +83,16 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
dns_db.DNSDbMixin,
vlan_ext_db.Vlantransparent_db_mixin):
supported_extension_aliases = ["allowed-address-pairs",
"binding",
"external-net",
"multi-provider",
"port-security",
"provider",
supported_extension_aliases = [addr_apidef.ALIAS,
pbin.ALIAS,
enet_apidef.ALIAS,
mpnet_apidef.ALIAS,
psec.ALIAS,
pnet.ALIAS,
"quotas",
"router",
l3_apidef.ALIAS,
"security-group",
"vlan-transparent"]
vlan_apidef.ALIAS]
__native_bulk_support = True
__native_pagination_support = True

View File

@ -16,17 +16,30 @@
import weakref
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
from neutron_lib.api.definitions import dvr as dvr_apidef
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
from neutron_lib.api.definitions import extraroute as xroute_apidef
from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api import faults
from neutron_lib.api import validators
from neutron_lib import constants
from neutron_lib import context as q_context
from neutron_lib.db import api as db_api
from neutron_lib.db import model_query
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
from neutron_lib.exceptions import extraroute as xroute_exc
from neutron_lib.exceptions import l3 as l3_exc
from neutron_lib.exceptions import multiprovidernet as mpnet_exc
from neutron_lib.exceptions import port_security as psec_exc
from neutron_lib.plugins import utils
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
@ -60,17 +73,6 @@ from neutron.db import securitygroups_db
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.quota import resource_registry
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
from neutron_lib.api.definitions import extraroute as xroute_apidef
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.db import api as db_api
from neutron_lib.db import model_query
from neutron_lib.db import resource_extend
from neutron_lib.exceptions import extraroute as xroute_exc
from neutron_lib.exceptions import multiprovidernet as mpnet_exc
from neutron_lib.plugins import utils
import vmware_nsx
from vmware_nsx._i18n import _
@ -121,21 +123,21 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
securitygroups_db.SecurityGroupDbMixin,
dns_db.DNSDbMixin):
supported_extension_aliases = ["allowed-address-pairs",
"binding",
"dvr",
supported_extension_aliases = [addr_apidef.ALIAS,
pbin.ALIAS,
dvr_apidef.ALIAS,
"ext-gw-mode",
xroute_apidef.ALIAS,
"mac-learning",
"multi-provider",
"network-gateway",
"port-security",
"provider",
psec.ALIAS,
pnet.ALIAS,
"qos-queue",
"quotas",
"external-net",
"extra_dhcp_opt",
"router",
extnet_apidef.ALIAS,
edo_ext.ALIAS,
l3_apidef.ALIAS,
"security-group",
constants.SUBNET_ALLOCATION_EXT_ALIAS]

View File

@ -30,11 +30,19 @@ from neutron.db import models_v2
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.quota import resource_registry
from neutron_lib.api.definitions import agent as agent_apidef
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
from neutron_lib.api.definitions import availability_zone as az_apidef
from neutron_lib.api.definitions import dhcpagentscheduler
from neutron_lib.api.definitions import external_net
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
from neutron_lib.api.definitions import extraroute
from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.api.definitions import network_availability_zone
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings as pbin_apidef
from neutron_lib.api.definitions import provider_net as pnet_apidef
from neutron_lib.api.definitions import router_availability_zone
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
from neutron_lib.api import extensions
from neutron_lib.api import validators
@ -112,24 +120,24 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
__native_pagination_support = True
__native_sorting_support = True
supported_extension_aliases = ["allowed-address-pairs",
supported_extension_aliases = [addr_apidef.ALIAS,
"address-scope",
"quotas",
"binding",
"extra_dhcp_opt",
"agent",
"dhcp_agent_scheduler",
pbin_apidef.ALIAS,
ext_edo.ALIAS,
agent_apidef.ALIAS,
dhcpagentscheduler.ALIAS,
"ext-gw-mode",
"security-group",
"secgroup-rule-local-ip-prefix",
"port-security",
"provider",
"external-net",
"extraroute",
"router",
"availability_zone",
"network_availability_zone",
"router_availability_zone",
psec.ALIAS,
pnet_apidef.ALIAS,
external_net.ALIAS,
extraroute.ALIAS,
l3_apidef.ALIAS,
az_apidef.ALIAS,
network_availability_zone.ALIAS,
router_availability_zone.ALIAS,
"subnet_allocation",
"security-group-logging",
"provider-security-group",
@ -178,7 +186,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
# Support transparent VLANS only if the global configuration flag
# vlan_transparent is True
if cfg.CONF.vlan_transparent:
self.supported_extension_aliases.append("vlan-transparent")
self.supported_extension_aliases.append(vlan_apidef.ALIAS)
nsxlib_utils.set_inject_headers_callback(v3_utils.inject_headers)
self._validate_nsx_policy_version()

View File

@ -19,16 +19,23 @@ import xml.etree.ElementTree as et
import netaddr
from neutron_lib.agent import topics
from neutron_lib.api.definitions import agent as agent_apidef
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
from neutron_lib.api.definitions import availability_zone as az_def
from neutron_lib.api.definitions import dvr as dvr_apidef
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
from neutron_lib.api.definitions import extraroute
from neutron_lib.api.definitions import flavors as flavors_apidef
from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.api.definitions import l3_flavors
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
from neutron_lib.api.definitions import network_availability_zone
from neutron_lib.api.definitions import port as port_def
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings as pbin
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api.definitions import router_availability_zone
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
@ -206,21 +213,21 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
mac_db.MacLearningDbMixin,
hk_ext.Housekeeper):
supported_extension_aliases = ["agent",
"allowed-address-pairs",
supported_extension_aliases = [agent_apidef.ALIAS,
addr_apidef.ALIAS,
"address-scope",
"binding",
pbin.ALIAS,
"dns-search-domain",
"dvr",
dvr_apidef.ALIAS,
"ext-gw-mode",
"multi-provider",
"port-security",
"provider",
mpnet_apidef.ALIAS,
psec.ALIAS,
pnet.ALIAS,
"quotas",
"external-net",
"extra_dhcp_opt",
"extraroute",
"router",
extnet_apidef.ALIAS,
ext_edo.ALIAS,
extraroute.ALIAS,
l3_apidef.ALIAS,
"security-group",
"secgroup-rule-local-ip-prefix",
"security-group-logging",
@ -229,11 +236,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"vnic-index",
"advanced-service-providers",
"subnet_allocation",
"availability_zone",
"network_availability_zone",
"router_availability_zone",
"l3-flavors",
"flavors",
az_def.ALIAS,
network_availability_zone.ALIAS,
router_availability_zone.ALIAS,
l3_flavors.ALIAS,
flavors_apidef.ALIAS,
"dhcp-mtu",
"mac-learning",
"housekeeper",
@ -319,7 +326,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# True
if cfg.CONF.vlan_transparent:
if c_utils.is_nsxv_version_6_3(self.nsx_v.vcns.get_version()):
self.supported_extension_aliases.append("vlan-transparent")
self.supported_extension_aliases.append(vlan_apidef.ALIAS)
else:
LOG.warning("Transparent support only from "
"NSX 6.3 onwards")

View File

@ -18,14 +18,32 @@ import time
import mock
import netaddr
from neutron_lib.agent import topics
from neutron_lib.api.definitions import agent as agent_apidef
from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef
from neutron_lib.api.definitions import availability_zone
from neutron_lib.api.definitions import dhcpagentscheduler
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
from neutron_lib.api.definitions import extraroute
from neutron_lib.api.definitions import l3 as l3_apidef
from neutron_lib.api.definitions import network_availability_zone
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings as pbin_apidef
from neutron_lib.api.definitions import provider_net
from neutron_lib.api.definitions import router_availability_zone
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.callbacks import events
from neutron_lib.callbacks import exceptions as callback_exc
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants as const
from neutron_lib import context as q_context
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib.db import utils as db_utils
from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import l3 as l3_exc
from neutron_lib.plugins import constants as plugin_const
from neutron_lib.plugins import directory
@ -43,16 +61,7 @@ from neutron.db import models_v2
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
from neutron.quota import resource_registry
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
from neutron_lib.api import validators
from neutron_lib.callbacks import events
from neutron_lib.callbacks import exceptions as callback_exc
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import constants as const
from neutron_lib import context as q_context
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_log import log
@ -129,24 +138,24 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
__native_pagination_support = True
__native_sorting_support = True
supported_extension_aliases = ["allowed-address-pairs",
supported_extension_aliases = [addr_apidef.ALIAS,
"address-scope",
"quotas",
"binding",
"extra_dhcp_opt",
"agent",
"dhcp_agent_scheduler",
pbin_apidef.ALIAS,
ext_edo.ALIAS,
agent_apidef.ALIAS,
dhcpagentscheduler.ALIAS,
"ext-gw-mode",
"security-group",
"secgroup-rule-local-ip-prefix",
"port-security",
"provider",
"external-net",
"extraroute",
"router",
"availability_zone",
"network_availability_zone",
"router_availability_zone",
psec.ALIAS,
provider_net.ALIAS,
extnet_apidef.ALIAS,
extraroute.ALIAS,
l3_apidef.ALIAS,
availability_zone.ALIAS,
network_availability_zone.ALIAS,
router_availability_zone.ALIAS,
"subnet_allocation",
"security-group-logging",
"provider-security-group",
@ -240,7 +249,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
# True
if cfg.CONF.vlan_transparent:
if self.nsxlib.feature_supported(nsxlib_consts.FEATURE_TRUNK_VLAN):
self.supported_extension_aliases.append("vlan-transparent")
self.supported_extension_aliases.append(vlan_apidef.ALIAS)
else:
LOG.warning("Current NSX version %s doesn't support "
"transparent vlans", self.nsxlib.get_version())

View File

@ -15,7 +15,7 @@
# under the License.
from neutron.services.qos import qos_plugin
from neutron_lib.api.definitions import qos as qos_apidef
from oslo_config import cfg
from oslo_log import log as logging
@ -29,7 +29,7 @@ class NsxVQosPlugin(qos_plugin.QoSPlugin):
"""Service plugin for VMware NSX-v to implement Neutron's Qos API."""
supported_extension_aliases = ["qos"]
supported_extension_aliases = [qos_apidef.ALIAS]
def __init__(self):
LOG.info("Loading VMware NSX-V Qos Service Plugin")