From 11c6b535a162c18908e4a41b502f1104bb0c2de7 Mon Sep 17 00:00:00 2001 From: Boden R Date: Fri, 22 Feb 2019 11:40:23 -0700 Subject: [PATCH] normalize and use ALIAS in supported_extension_aliases This patch: - Addresses a few missed by https://review.openstack.org/#/c/637962/ - Updates all the vmware_nsx.extensions.* to use ALIAS for their API extension alias variable rather than use a random or no constant name for the alias. Change-Id: Ice88f1d6a451fb0d82587a9fb6b1a6a7f285c8c6 --- vmware_nsx/dhcp_meta/modes.py | 4 +-- .../extension_drivers/dns_integration.py | 2 +- .../extensions/advancedserviceproviders.py | 4 +-- vmware_nsx/extensions/api_replay.py | 5 +++- vmware_nsx/extensions/dhcp_mtu.py | 3 +- vmware_nsx/extensions/dns_search_domain.py | 3 +- .../edge_service_gateway_bgp_peer.py | 4 +-- vmware_nsx/extensions/housekeeper.py | 3 +- vmware_nsx/extensions/lsn.py | 8 ++--- vmware_nsx/extensions/maclearning.py | 3 +- vmware_nsx/extensions/networkgw.py | 6 ++-- vmware_nsx/extensions/nsxpolicy.py | 4 +-- vmware_nsx/extensions/projectpluginmap.py | 4 +-- .../extensions/providersecuritygroup.py | 3 +- vmware_nsx/extensions/qos_queue.py | 3 +- vmware_nsx/extensions/routersize.py | 3 +- vmware_nsx/extensions/routertype.py | 3 +- .../secgroup_rule_local_ip_prefix.py | 4 ++- vmware_nsx/extensions/securitygrouplogging.py | 3 +- vmware_nsx/extensions/securitygrouppolicy.py | 4 ++- vmware_nsx/extensions/vnicindex.py | 4 +-- vmware_nsx/plugins/nsx/plugin.py | 4 +-- vmware_nsx/plugins/nsx_mh/plugin.py | 8 ++--- vmware_nsx/plugins/nsx_p/plugin.py | 11 +++---- vmware_nsx/plugins/nsx_v/plugin.py | 30 ++++++++++--------- vmware_nsx/plugins/nsx_v3/plugin.py | 17 ++++++----- .../services/dynamic_routing/bgp_plugin.py | 2 +- .../tests/unit/extensions/test_networkgw.py | 4 +-- .../test_provider_security_groups.py | 2 +- .../test_secgroup_rule_local_ip_prefix.py | 2 +- .../tests/unit/extensions/test_vnic_index.py | 2 +- .../tests/unit/nsx_v3/test_api_replay.py | 3 +- vmware_nsx/tests/unit/osc/v2/test_port.py | 9 ++++-- vmware_nsx/tests/unit/osc/v2/test_router.py | 2 +- .../tests/unit/osc/v2/test_security_group.py | 10 +++++-- vmware_nsx/tests/unit/osc/v2/test_subnet.py | 4 ++- 36 files changed, 111 insertions(+), 79 deletions(-) diff --git a/vmware_nsx/dhcp_meta/modes.py b/vmware_nsx/dhcp_meta/modes.py index 028f8f1405..b5f560bbb1 100644 --- a/vmware_nsx/dhcp_meta/modes.py +++ b/vmware_nsx/dhcp_meta/modes.py @@ -128,7 +128,7 @@ class DhcpMetadataAccess(object): LOG.warning('network_auto_schedule has been disabled') notifier = combined.DhcpAgentNotifyAPI(weakref.proxy(self), lsn_manager) - self.supported_extension_aliases.append(lsn.EXT_ALIAS) + self.supported_extension_aliases.append(lsn.ALIAS) # Add the capability to migrate dhcp and metadata services over self.migration_manager = ( migration.MigrationManager( @@ -136,7 +136,7 @@ class DhcpMetadataAccess(object): return notifier def _init_extensions(self): - extensions = (lsn.EXT_ALIAS, agent_apidef.ALIAS, + extensions = (lsn.ALIAS, agent_apidef.ALIAS, dhcpagentscheduler.ALIAS) for ext in extensions: if ext in self.supported_extension_aliases: diff --git a/vmware_nsx/extension_drivers/dns_integration.py b/vmware_nsx/extension_drivers/dns_integration.py index 4bbdf189f8..c3ab1df0ad 100644 --- a/vmware_nsx/extension_drivers/dns_integration.py +++ b/vmware_nsx/extension_drivers/dns_integration.py @@ -44,7 +44,7 @@ def _dotted_domain(dns_domain): # TODO(asarfaty) use dns-domain/nameserver from network az instead of global class DNSExtensionDriver(driver_api.ExtensionDriver): - _supported_extension_alias = 'dns-integration' + _supported_extension_alias = dns.ALIAS @property def extension_alias(self): diff --git a/vmware_nsx/extensions/advancedserviceproviders.py b/vmware_nsx/extensions/advancedserviceproviders.py index 06902f8d6e..cd2bf4e043 100644 --- a/vmware_nsx/extensions/advancedserviceproviders.py +++ b/vmware_nsx/extensions/advancedserviceproviders.py @@ -16,7 +16,7 @@ from neutron_lib.api import extensions # Attribute Map ADV_SERVICE_PROVIDERS = 'advanced_service_providers' - +ALIAS = 'advanced-service-providers' EXTENDED_ATTRIBUTES_2_0 = { 'subnets': { @@ -34,7 +34,7 @@ class Advancedserviceproviders(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "advanced-service-providers" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/api_replay.py b/vmware_nsx/extensions/api_replay.py index 2e59e1ee55..9e7d02798b 100644 --- a/vmware_nsx/extensions/api_replay.py +++ b/vmware_nsx/extensions/api_replay.py @@ -18,6 +18,9 @@ from neutron_lib.api import extensions from neutron_lib.db import constants as db_const + +ALIAS = 'api-replay' + # The attributes map is here for 2 reasons: # 1) allow posting id for the different objects we are importing # 2) make sure security-group named 'default' is also copied @@ -61,7 +64,7 @@ class Api_replay(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return 'api-replay' + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/dhcp_mtu.py b/vmware_nsx/extensions/dhcp_mtu.py index b24b682244..d5760473dd 100644 --- a/vmware_nsx/extensions/dhcp_mtu.py +++ b/vmware_nsx/extensions/dhcp_mtu.py @@ -16,6 +16,7 @@ from neutron_lib.api import extensions from neutron_lib import constants DHCP_MTU = 'dhcp_mtu' +ALIAS = 'dhcp-mtu' EXTENDED_ATTRIBUTES_2_0 = { 'subnets': { DHCP_MTU: { @@ -37,7 +38,7 @@ class Dhcp_mtu(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "dhcp-mtu" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/dns_search_domain.py b/vmware_nsx/extensions/dns_search_domain.py index a3259c8f44..8f6e5b8379 100644 --- a/vmware_nsx/extensions/dns_search_domain.py +++ b/vmware_nsx/extensions/dns_search_domain.py @@ -66,6 +66,7 @@ def _validate_dns_search_domain(data, max_len=db_const.NAME_FIELD_SIZE): validators.add_validator('dns_search_domain', _validate_dns_search_domain) +ALIAS = 'dns-search-domain' DNS_SEARCH_DOMAIN = 'dns_search_domain' EXTENDED_ATTRIBUTES_2_0 = { 'subnets': { @@ -87,7 +88,7 @@ class Dns_search_domain(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "dns-search-domain" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py b/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py index 0de8085d9e..79811ef596 100644 --- a/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py +++ b/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py @@ -22,7 +22,7 @@ from vmware_nsx._i18n import _ EDGE_SERVICE_GW = 'esg_id' EDGE_ID_MAX_LEN = 15 -ESG_BGP_PEER_EXT_ALIAS = 'edge-service-gateway-bgp-peer' +ALIAS = 'edge-service-gateway-bgp-peer' def _validate_edge_service_gw_id(esg_id, valid_values=None): @@ -87,7 +87,7 @@ class Edge_service_gateway_bgp_peer(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return ESG_BGP_PEER_EXT_ALIAS + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/housekeeper.py b/vmware_nsx/extensions/housekeeper.py index fae2c63e22..cab157dcd8 100644 --- a/vmware_nsx/extensions/housekeeper.py +++ b/vmware_nsx/extensions/housekeeper.py @@ -24,6 +24,7 @@ from vmware_nsx._i18n import _ HOUSEKEEPER_RESOURCE_NAME = "housekeeper" HOUSEKEEPERS = "housekeepers" +ALIAS = 'housekeeper' # The housekeeper tasks table is read only RESOURCE_ATTRIBUTE_MAP = { @@ -53,7 +54,7 @@ class Housekeeper(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return HOUSEKEEPER_RESOURCE_NAME + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/lsn.py b/vmware_nsx/extensions/lsn.py index 6cf3f23188..2fb35c5c96 100644 --- a/vmware_nsx/extensions/lsn.py +++ b/vmware_nsx/extensions/lsn.py @@ -21,8 +21,8 @@ from neutron_lib.api import extensions as api_extensions from neutron_lib.plugins import directory -EXT_ALIAS = 'lsn' -COLLECTION_NAME = "%ss" % EXT_ALIAS +ALIAS = 'lsn' +COLLECTION_NAME = "%ss" % ALIAS RESOURCE_ATTRIBUTE_MAP = { COLLECTION_NAME: { @@ -47,7 +47,7 @@ class Lsn(api_extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return EXT_ALIAS + return ALIAS @classmethod def get_description(cls): @@ -62,7 +62,7 @@ class Lsn(api_extensions.ExtensionDescriptor): """Returns Ext Resources.""" exts = [] plugin = directory.get_plugin() - resource_name = EXT_ALIAS + resource_name = ALIAS collection_name = resource_name.replace('_', '-') + "s" params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict()) controller = base.create_resource(collection_name, diff --git a/vmware_nsx/extensions/maclearning.py b/vmware_nsx/extensions/maclearning.py index fbe90baafa..54bdea325d 100644 --- a/vmware_nsx/extensions/maclearning.py +++ b/vmware_nsx/extensions/maclearning.py @@ -17,6 +17,7 @@ from neutron_lib.api import extensions from neutron_lib import constants +ALIAS = 'mac-learning' MAC_LEARNING = 'mac_learning_enabled' EXTENDED_ATTRIBUTES_2_0 = { 'ports': { @@ -37,7 +38,7 @@ class Maclearning(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "mac-learning" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/networkgw.py b/vmware_nsx/extensions/networkgw.py index 1941c0dbf0..d88180ba47 100644 --- a/vmware_nsx/extensions/networkgw.py +++ b/vmware_nsx/extensions/networkgw.py @@ -29,8 +29,8 @@ from vmware_nsx._i18n import _ GATEWAY_RESOURCE_NAME = "network_gateway" DEVICE_RESOURCE_NAME = "gateway_device" # Use dash for alias and collection name -EXT_ALIAS = GATEWAY_RESOURCE_NAME.replace('_', '-') -NETWORK_GATEWAYS = "%ss" % EXT_ALIAS +ALIAS = GATEWAY_RESOURCE_NAME.replace('_', '-') +NETWORK_GATEWAYS = "%ss" % ALIAS GATEWAY_DEVICES = "%ss" % DEVICE_RESOURCE_NAME.replace('_', '-') DEVICE_ID_ATTR = 'id' IFACE_NAME_ATTR = 'interface_name' @@ -173,7 +173,7 @@ class Networkgw(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return EXT_ALIAS + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/nsxpolicy.py b/vmware_nsx/extensions/nsxpolicy.py index 2bd9f5e8e1..11f70b45f2 100644 --- a/vmware_nsx/extensions/nsxpolicy.py +++ b/vmware_nsx/extensions/nsxpolicy.py @@ -23,7 +23,7 @@ from vmware_nsx._i18n import _ POLICY_RESOURCE_NAME = "nsx_policy" # Use dash for alias and collection name -EXT_ALIAS = POLICY_RESOURCE_NAME.replace('_', '-') +ALIAS = POLICY_RESOURCE_NAME.replace('_', '-') NSX_POLICIES = "nsx_policies" # The nsx-policies table is read only @@ -48,7 +48,7 @@ class Nsxpolicy(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return EXT_ALIAS + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/projectpluginmap.py b/vmware_nsx/extensions/projectpluginmap.py index 54cafb4153..ce4e0b115c 100644 --- a/vmware_nsx/extensions/projectpluginmap.py +++ b/vmware_nsx/extensions/projectpluginmap.py @@ -24,7 +24,7 @@ from vmware_nsx._i18n import _ PROJECT_PLUGIN_RESOURCE_NAME = "project_plugin_map" # Use dash for alias and collection name -EXT_ALIAS = PROJECT_PLUGIN_RESOURCE_NAME.replace('_', '-') +ALIAS = PROJECT_PLUGIN_RESOURCE_NAME.replace('_', '-') PROJECT_PLUGINS = "project_plugin_maps" @@ -69,7 +69,7 @@ class Projectpluginmap(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return EXT_ALIAS + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/providersecuritygroup.py b/vmware_nsx/extensions/providersecuritygroup.py index 83d7b9d5e6..558270c0f2 100644 --- a/vmware_nsx/extensions/providersecuritygroup.py +++ b/vmware_nsx/extensions/providersecuritygroup.py @@ -20,6 +20,7 @@ from neutron_lib import exceptions as nexception from vmware_nsx._i18n import _ +ALIAS = 'provider-security-group' PROVIDER = 'provider' PROVIDER_SECURITYGROUPS = 'provider_security_groups' @@ -75,7 +76,7 @@ class Providersecuritygroup(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "provider-security-group" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/qos_queue.py b/vmware_nsx/extensions/qos_queue.py index 9b4981ef4f..e203bad858 100644 --- a/vmware_nsx/extensions/qos_queue.py +++ b/vmware_nsx/extensions/qos_queue.py @@ -27,6 +27,7 @@ from neutron_lib.plugins import directory from vmware_nsx._i18n import _ +ALIAS = 'qos-queue' # For policy.json/Auth qos_queue_create = "create_qos_queue" qos_queue_delete = "delete_qos_queue" @@ -176,7 +177,7 @@ class Qos_queue(api_extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "qos-queue" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/routersize.py b/vmware_nsx/extensions/routersize.py index f1fbfcc640..f9ed2f3786 100644 --- a/vmware_nsx/extensions/routersize.py +++ b/vmware_nsx/extensions/routersize.py @@ -16,6 +16,7 @@ from neutron_lib.api import extensions from neutron_lib import constants +ALIAS = 'nsxv-router-size' ROUTER_SIZE = 'router_size' VALID_EDGE_SIZES = ['compact', 'large', 'xlarge', 'quadlarge'] EXTENDED_ATTRIBUTES_2_0 = { @@ -37,7 +38,7 @@ class Routersize(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "nsxv-router-size" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/routertype.py b/vmware_nsx/extensions/routertype.py index 796b82ada0..2a55399695 100644 --- a/vmware_nsx/extensions/routertype.py +++ b/vmware_nsx/extensions/routertype.py @@ -16,6 +16,7 @@ from neutron_lib.api import extensions from neutron_lib import constants +ALIAS = 'nsxv-router-type' ROUTER_TYPE = 'router_type' VALID_TYPES = ['shared', 'exclusive'] EXTENDED_ATTRIBUTES_2_0 = { @@ -37,7 +38,7 @@ class Routertype(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "nsxv-router-type" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/secgroup_rule_local_ip_prefix.py b/vmware_nsx/extensions/secgroup_rule_local_ip_prefix.py index 82b445d1af..0c99080588 100644 --- a/vmware_nsx/extensions/secgroup_rule_local_ip_prefix.py +++ b/vmware_nsx/extensions/secgroup_rule_local_ip_prefix.py @@ -17,6 +17,8 @@ from neutron.extensions import securitygroup from neutron_lib.api import extensions from neutron_lib import constants + +ALIAS = 'secgroup-rule-local-ip-prefix' LOCAL_IP_PREFIX = 'local_ip_prefix' RESOURCE_ATTRIBUTE_MAP = { @@ -43,7 +45,7 @@ class Secgroup_rule_local_ip_prefix(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "secgroup-rule-local-ip-prefix" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/securitygrouplogging.py b/vmware_nsx/extensions/securitygrouplogging.py index 8ae3af4ebd..951e28629a 100644 --- a/vmware_nsx/extensions/securitygrouplogging.py +++ b/vmware_nsx/extensions/securitygrouplogging.py @@ -15,6 +15,7 @@ from neutron_lib.api import converters from neutron_lib.api import extensions +ALIAS = 'security-group-logging' LOGGING = 'logging' RESOURCE_ATTRIBUTE_MAP = { @@ -39,7 +40,7 @@ class Securitygrouplogging(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "security-group-logging" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/securitygrouppolicy.py b/vmware_nsx/extensions/securitygrouppolicy.py index a199b0f236..f00e70b848 100644 --- a/vmware_nsx/extensions/securitygrouppolicy.py +++ b/vmware_nsx/extensions/securitygrouppolicy.py @@ -17,6 +17,8 @@ from neutron_lib import exceptions as nexception from vmware_nsx._i18n import _ + +ALIAS = 'security-group-policy' POLICY = 'policy' RESOURCE_ATTRIBUTE_MAP = { @@ -45,7 +47,7 @@ class Securitygrouppolicy(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "security-group-policy" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/extensions/vnicindex.py b/vmware_nsx/extensions/vnicindex.py index 61e3ae0849..55e752ef2b 100644 --- a/vmware_nsx/extensions/vnicindex.py +++ b/vmware_nsx/extensions/vnicindex.py @@ -17,7 +17,7 @@ from neutron_lib.api import extensions # Attribute Map VNIC_INDEX = 'vnic_index' - +ALIAS = 'vnic-index' EXTENDED_ATTRIBUTES_2_0 = { 'ports': { @@ -36,7 +36,7 @@ class Vnicindex(extensions.ExtensionDescriptor): @classmethod def get_alias(cls): - return "vnic-index" + return ALIAS @classmethod def get_description(cls): diff --git a/vmware_nsx/plugins/nsx/plugin.py b/vmware_nsx/plugins/nsx/plugin.py index fae4843b13..db4c999831 100644 --- a/vmware_nsx/plugins/nsx/plugin.py +++ b/vmware_nsx/plugins/nsx/plugin.py @@ -89,7 +89,7 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, nsx_com_az.NSXAvailabilityZonesPluginCommon, projectpluginmap.ProjectPluginMapPluginBase): - supported_extension_aliases = ['project-plugin-map'] + supported_extension_aliases = [projectpluginmap.ALIAS] __native_bulk_support = True __native_pagination_support = True @@ -173,7 +173,7 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, raise nsx_exc.NsxPluginException(err_msg=msg) for k, val in self.plugins.items(): - if "advanced-service-providers" in val.supported_extension_aliases: + if as_providers.ALIAS in val.supported_extension_aliases: self.as_providers[k] = val LOG.info("NSX-TVD plugin will use %s as the default plugin", self.default_plugin) diff --git a/vmware_nsx/plugins/nsx_mh/plugin.py b/vmware_nsx/plugins/nsx_mh/plugin.py index dd7cf46934..8d2353dba6 100644 --- a/vmware_nsx/plugins/nsx_mh/plugin.py +++ b/vmware_nsx/plugins/nsx_mh/plugin.py @@ -128,12 +128,12 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, dvr_apidef.ALIAS, "ext-gw-mode", xroute_apidef.ALIAS, - "mac-learning", - "multi-provider", - "network-gateway", + mac_ext.ALIAS, + mpnet_apidef.ALIAS, + networkgw.ALIAS, psec.ALIAS, pnet.ALIAS, - "qos-queue", + qos.ALIAS, "quotas", extnet_apidef.ALIAS, edo_ext.ALIAS, diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index bc8f4ef6e7..17567c03ee 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -30,6 +30,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 address_scope 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 @@ -121,7 +122,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): __native_sorting_support = True supported_extension_aliases = [addr_apidef.ALIAS, - "address-scope", + address_scope.ALIAS, "quotas", pbin_apidef.ALIAS, ext_edo.ALIAS, @@ -129,7 +130,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): dhcpagentscheduler.ALIAS, "ext-gw-mode", "security-group", - "secgroup-rule-local-ip-prefix", + sg_prefix.ALIAS, psec.ALIAS, pnet_apidef.ALIAS, external_net.ALIAS, @@ -139,10 +140,10 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): network_availability_zone.ALIAS, router_availability_zone.ALIAS, "subnet_allocation", - "security-group-logging", - "provider-security-group", + sg_logging.ALIAS, + provider_sg.ALIAS, "port-security-groups-filtering", - 'mac-learning'] + mac_ext.ALIAS] @resource_registry.tracked_resources( network=models_v2.Network, diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 9aac8dec4c..e10b52e11a 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -19,6 +19,7 @@ import xml.etree.ElementTree as et import netaddr from neutron_lib.agent import topics +from neutron_lib.api.definitions import address_scope 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 @@ -133,6 +134,7 @@ from vmware_nsx.extensions import nsxpolicy from vmware_nsx.extensions import projectpluginmap from vmware_nsx.extensions import providersecuritygroup as provider_sg from vmware_nsx.extensions import routersize +from vmware_nsx.extensions import routertype from vmware_nsx.extensions import secgroup_rule_local_ip_prefix from vmware_nsx.extensions import securitygrouplogging as sg_logging from vmware_nsx.extensions import securitygrouppolicy as sg_policy @@ -215,9 +217,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, supported_extension_aliases = [agent_apidef.ALIAS, addr_apidef.ALIAS, - "address-scope", + address_scope.ALIAS, pbin.ALIAS, - "dns-search-domain", + ext_dns_search_domain.ALIAS, dvr_apidef.ALIAS, "ext-gw-mode", mpnet_apidef.ALIAS, @@ -229,21 +231,21 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, extraroute.ALIAS, l3_apidef.ALIAS, "security-group", - "secgroup-rule-local-ip-prefix", - "security-group-logging", - "nsxv-router-type", - "nsxv-router-size", - "vnic-index", - "advanced-service-providers", + secgroup_rule_local_ip_prefix.ALIAS, + sg_logging.ALIAS, + routertype.ALIAS, + routersize.ALIAS, + ext_vnic_idx.ALIAS, + as_providers.ALIAS, "subnet_allocation", az_def.ALIAS, network_availability_zone.ALIAS, router_availability_zone.ALIAS, l3_flavors.ALIAS, flavors_apidef.ALIAS, - "dhcp-mtu", - "mac-learning", - "housekeeper", + ext_dhcp_mtu.ALIAS, + mac_ext.ALIAS, + hk_ext.ALIAS, "port-security-groups-filtering"] __native_bulk_support = True @@ -318,8 +320,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, # Support NSX policies in default security groups self._use_nsx_policies = True # enable the extension - self.supported_extension_aliases.append("security-group-policy") - self.supported_extension_aliases.append("nsx-policy") + self.supported_extension_aliases.append(sg_policy.ALIAS) + self.supported_extension_aliases.append(nsxpolicy.ALIAS) # Support transparent VLANS from 6.3.0 onwards. The feature is only # supported if the global configuration flag vlan_transparent is @@ -352,7 +354,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, resources.SUBNETPOOL_ADDRESS_SCOPE, events.AFTER_UPDATE) if c_utils.is_nsxv_version_6_2(self.nsx_v.vcns.get_version()): - self.supported_extension_aliases.append("provider-security-group") + self.supported_extension_aliases.append(provider_sg.ALIAS) # Bind QoS notifications qos_driver.register(self) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 32289294a2..cc9e2de389 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -18,6 +18,7 @@ import time import mock import netaddr from neutron_lib.agent import topics +from neutron_lib.api.definitions import address_scope 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 @@ -80,10 +81,12 @@ from vmware_nsx.common import nsx_constants from vmware_nsx.common import utils from vmware_nsx.db import db as nsx_db from vmware_nsx.dhcp_meta import rpc as nsx_rpc +from vmware_nsx.extensions import api_replay from vmware_nsx.extensions import housekeeper as hk_ext from vmware_nsx.extensions import maclearning as mac_ext from vmware_nsx.extensions import projectpluginmap from vmware_nsx.extensions import providersecuritygroup as provider_sg +from vmware_nsx.extensions import secgroup_rule_local_ip_prefix from vmware_nsx.extensions import securitygrouplogging as sg_logging from vmware_nsx.plugins.common.housekeeper import housekeeper from vmware_nsx.plugins.common_v3 import plugin as nsx_plugin_common @@ -139,7 +142,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, __native_sorting_support = True supported_extension_aliases = [addr_apidef.ALIAS, - "address-scope", + address_scope.ALIAS, "quotas", pbin_apidef.ALIAS, ext_edo.ALIAS, @@ -147,7 +150,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, dhcpagentscheduler.ALIAS, "ext-gw-mode", "security-group", - "secgroup-rule-local-ip-prefix", + secgroup_rule_local_ip_prefix.ALIAS, psec.ALIAS, provider_net.ALIAS, extnet_apidef.ALIAS, @@ -157,9 +160,9 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, network_availability_zone.ALIAS, router_availability_zone.ALIAS, "subnet_allocation", - "security-group-logging", - "provider-security-group", - "housekeeper", + sg_logging.ALIAS, + provider_sg.ALIAS, + hk_ext.ALIAS, "port-security-groups-filtering"] @resource_registry.tracked_resources( @@ -242,7 +245,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, self._unsubscribe_callback_events() if cfg.CONF.api_replay_mode: - self.supported_extension_aliases.append('api-replay') + self.supported_extension_aliases.append(api_replay.ALIAS) # Support transparent VLANS from 2.2.0 onwards. The feature is only # supported if the global configuration flag vlan_transparent is @@ -512,7 +515,7 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, try: self._init_mac_learning_profile() # Only expose the extension if it is supported - self.supported_extension_aliases.append('mac-learning') + self.supported_extension_aliases.append(mac_ext.ALIAS) except Exception as e: LOG.warning("Unable to initialize NSX v3 MAC Learning " "profile: %(name)s. Reason: %(reason)s", diff --git a/vmware_nsx/services/dynamic_routing/bgp_plugin.py b/vmware_nsx/services/dynamic_routing/bgp_plugin.py index 2fd0a160ab..1578c83827 100644 --- a/vmware_nsx/services/dynamic_routing/bgp_plugin.py +++ b/vmware_nsx/services/dynamic_routing/bgp_plugin.py @@ -43,7 +43,7 @@ class NSXBgpPlugin(service_base.ServicePluginBase, bgp_db.BgpDbMixin): """ supported_extension_aliases = [bgp_ext.BGP_EXT_ALIAS, - ext_esg.ESG_BGP_PEER_EXT_ALIAS] + ext_esg.ALIAS] def __init__(self): super(NSXBgpPlugin, self).__init__() diff --git a/vmware_nsx/tests/unit/extensions/test_networkgw.py b/vmware_nsx/tests/unit/extensions/test_networkgw.py index 773e8f42c9..37732ce22b 100644 --- a/vmware_nsx/tests/unit/extensions/test_networkgw.py +++ b/vmware_nsx/tests/unit/extensions/test_networkgw.py @@ -83,7 +83,7 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase): # Instantiate mock plugin and enable extensions self.plugin.return_value.supported_extension_aliases = ( - [networkgw.EXT_ALIAS]) + [networkgw.ALIAS]) directory.add_plugin(constants.CORE, self.plugin.return_value) ext_mgr = TestExtensionManager() extensions.PluginAwareExtensionManager._instance = ext_mgr @@ -1096,7 +1096,7 @@ class TestNetworkGatewayPlugin(db_base_plugin_v2.NeutronDbPluginV2, networkgw_db.NetworkGatewayMixin): """Simple plugin class for testing db support for network gateway ext.""" - supported_extension_aliases = ["network-gateway"] + supported_extension_aliases = [networkgw.ALIAS] def __init__(self, **args): super(TestNetworkGatewayPlugin, self).__init__(**args) diff --git a/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py b/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py index 3121cee84e..9c406ffaa2 100644 --- a/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py +++ b/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py @@ -42,7 +42,7 @@ class ProviderSecurityGroupTestPlugin( securitygroups_db.SecurityGroupDbMixin): supported_extension_aliases = ["security-group", - "provider-security-group"] + provider_sg.ALIAS] def create_security_group(self, context, security_group, default_sg=False): secgroup = security_group['security_group'] diff --git a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py index d0d89d6715..2f906eae86 100644 --- a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py +++ b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py @@ -45,7 +45,7 @@ class ExtendedRuleTestPlugin(db_base_plugin_v2.NeutronDbPluginV2, securitygroups_db.SecurityGroupDbMixin): supported_extension_aliases = ["security-group", - "secgroup-rule-local-ip-prefix"] + ext_loip.ALIAS] def create_security_group_rule(self, context, security_group_rule): rule = security_group_rule['security_group_rule'] diff --git a/vmware_nsx/tests/unit/extensions/test_vnic_index.py b/vmware_nsx/tests/unit/extensions/test_vnic_index.py index 490e7c9327..ce93072c6f 100644 --- a/vmware_nsx/tests/unit/extensions/test_vnic_index.py +++ b/vmware_nsx/tests/unit/extensions/test_vnic_index.py @@ -38,7 +38,7 @@ _uuid = uuidutils.generate_uuid class VnicIndexTestPlugin(db_base_plugin_v2.NeutronDbPluginV2, vnic_index_db.VnicIndexDbMixin): - supported_extension_aliases = ["vnic-index"] + supported_extension_aliases = [vnicidx.ALIAS] def update_port(self, context, id, port): p = port['port'] diff --git a/vmware_nsx/tests/unit/nsx_v3/test_api_replay.py b/vmware_nsx/tests/unit/nsx_v3/test_api_replay.py index 135956e60f..157624e0c8 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_api_replay.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_api_replay.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from vmware_nsx.extensions import api_replay from vmware_nsx.tests.unit.nsx_v3 import test_plugin from neutron_lib.api import attributes @@ -34,7 +35,7 @@ class TestApiReplay(test_plugin.NsxV3PluginTestCaseMixin): # remove the extension from the plugin directory.get_plugin().supported_extension_aliases.remove( - 'api-replay') + api_replay.ALIAS) # Revert the attributes map back to normal for attr_name in ('ports', 'networks', 'security_groups', diff --git a/vmware_nsx/tests/unit/osc/v2/test_port.py b/vmware_nsx/tests/unit/osc/v2/test_port.py index 3bdf721d5e..e94af84fc4 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_port.py +++ b/vmware_nsx/tests/unit/osc/v2/test_port.py @@ -20,12 +20,15 @@ from openstackclient.tests.unit.network.v2 import fakes as network_fakes from openstackclient.tests.unit.network.v2 import test_port from openstackclient.tests.unit import utils as tests_utils +from vmware_nsx.extensions import maclearning +from vmware_nsx.extensions import providersecuritygroup +from vmware_nsx.extensions import vnicindex from vmware_nsx.osc.v2 import port -supported_extensions = ('vnic-index', - 'provider-security-group', - 'mac-learning') +supported_extensions = (vnicindex.ALIAS, + providersecuritygroup.ALIAS, + maclearning.ALIAS) class TestCreatePort(test_port.TestCreatePort): diff --git a/vmware_nsx/tests/unit/osc/v2/test_router.py b/vmware_nsx/tests/unit/osc/v2/test_router.py index 144f6fea18..de0619d78c 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_router.py +++ b/vmware_nsx/tests/unit/osc/v2/test_router.py @@ -24,7 +24,7 @@ from vmware_nsx.extensions import routertype from vmware_nsx.osc.v2 import router -supported_extensions = ('nsxv-router-size', 'nsxv-router-type') +supported_extensions = (routersize.ALIAS, routertype.ALIAS) class TestCreateRouter(test_router.TestCreateRouter): diff --git a/vmware_nsx/tests/unit/osc/v2/test_security_group.py b/vmware_nsx/tests/unit/osc/v2/test_security_group.py index b66366f6c9..c74533c815 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_security_group.py +++ b/vmware_nsx/tests/unit/osc/v2/test_security_group.py @@ -20,12 +20,16 @@ from openstackclient.tests.unit.network.v2 import ( test_security_group_network as test_security_group) from openstackclient.tests.unit import utils as tests_utils + +from vmware_nsx.extensions import providersecuritygroup +from vmware_nsx.extensions import securitygrouplogging +from vmware_nsx.extensions import securitygrouppolicy from vmware_nsx.osc.v2 import security_group -supported_extensions = ('security-group-logging', - 'provider-security-group', - 'security-group-policy') +supported_extensions = (securitygrouplogging.ALIAS, + providersecuritygroup.ALIAS, + securitygrouppolicy.ALIAS) class TestCreateSecurityGroup( diff --git a/vmware_nsx/tests/unit/osc/v2/test_subnet.py b/vmware_nsx/tests/unit/osc/v2/test_subnet.py index 3ee76085a5..77e625bb96 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_subnet.py +++ b/vmware_nsx/tests/unit/osc/v2/test_subnet.py @@ -19,10 +19,12 @@ import mock from openstackclient.tests.unit.network.v2 import test_subnet from openstackclient.tests.unit import utils as tests_utils +from vmware_nsx.extensions import dhcp_mtu +from vmware_nsx.extensions import dns_search_domain from vmware_nsx.osc.v2 import subnet -supported_extensions = ('dhcp-mtu', 'dns-search-domain') +supported_extensions = (dhcp_mtu.ALIAS, dns_search_domain.ALIAS) class TestCreateSubnet(test_subnet.TestCreateSubnet):