From f33bada2a9290126020a761a60446963e46d448d Mon Sep 17 00:00:00 2001 From: Henry Gessau Date: Wed, 16 Nov 2016 11:50:27 -0500 Subject: [PATCH] Remove PLURALS It's written to but never read from! Related-Bug: #1642426 This patch is required by neutron-lib adoption because it is part of rehoming neutron/api/v2/attributes.py. All subprojects that reference PLURALS must be patched to remove the reference. NeutronLibImpact Change-Id: Ifdf29b8fc4c824c0ee840c4f51593a5aa8a22127 --- neutron/api/v2/attributes.py | 12 ++---------- neutron/extensions/address_scope.py | 2 -- neutron/extensions/agent.py | 2 -- neutron/extensions/allowedaddresspairs.py | 3 --- neutron/extensions/availability_zone.py | 3 --- neutron/extensions/extraroute.py | 2 -- neutron/extensions/flavors.py | 1 - neutron/extensions/l3.py | 1 - neutron/extensions/metering.py | 1 - neutron/extensions/network_ip_availability.py | 2 -- neutron/extensions/qos.py | 1 - neutron/extensions/quotasv2.py | 3 --- neutron/extensions/rbac.py | 2 -- neutron/extensions/securitygroup.py | 2 -- neutron/extensions/segment.py | 1 - neutron/extensions/servicetype.py | 3 --- neutron/extensions/trunk.py | 2 -- neutron/tests/functional/pecan_wsgi/test_hooks.py | 1 - neutron/tests/functional/pecan_wsgi/utils.py | 2 -- 19 files changed, 2 insertions(+), 44 deletions(-) diff --git a/neutron/api/v2/attributes.py b/neutron/api/v2/attributes.py index fcc9d6df6e9..5d715070e0e 100644 --- a/neutron/api/v2/attributes.py +++ b/neutron/api/v2/attributes.py @@ -287,16 +287,8 @@ RESOURCE_FOREIGN_KEYS = { NETWORKS: 'network_id' } -# Store plural/singular mappings -PLURALS = {NETWORKS: NETWORK, - PORTS: PORT, - SUBNETS: SUBNET, - SUBNETPOOLS: SUBNETPOOL, - 'dns_nameservers': 'dns_nameserver', - 'host_routes': 'host_route', - 'allocation_pools': 'allocation_pool', - 'fixed_ips': 'fixed_ip', - 'extensions': 'extension'} +# Removing PLURALS breaks subprojects, but they don't need it so they +# need to be patched. def get_collection_info(collection): diff --git a/neutron/extensions/address_scope.py b/neutron/extensions/address_scope.py index 61a979255fe..50ef3a770a1 100644 --- a/neutron/extensions/address_scope.py +++ b/neutron/extensions/address_scope.py @@ -116,8 +116,6 @@ class Address_scope(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Ext Resources.""" - my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()] - attr.PLURALS.update(dict(my_plurals)) plugin = directory.get_plugin() collection_name = ADDRESS_SCOPES.replace('_', '-') params = RESOURCE_ATTRIBUTE_MAP.get(ADDRESS_SCOPES, dict()) diff --git a/neutron/extensions/agent.py b/neutron/extensions/agent.py index 1073939d1aa..5697eb63aab 100644 --- a/neutron/extensions/agent.py +++ b/neutron/extensions/agent.py @@ -98,8 +98,6 @@ class Agent(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Ext Resources.""" - my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()] - attr.PLURALS.update(dict(my_plurals)) plugin = directory.get_plugin() params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's') controller = base.create_resource(RESOURCE_NAME + 's', diff --git a/neutron/extensions/allowedaddresspairs.py b/neutron/extensions/allowedaddresspairs.py index a97bb795b38..d2170fcbd59 100644 --- a/neutron/extensions/allowedaddresspairs.py +++ b/neutron/extensions/allowedaddresspairs.py @@ -21,7 +21,6 @@ import webob.exc from neutron._i18n import _ from neutron.api import extensions -from neutron.api.v2 import attributes as attr from neutron.conf.extensions import allowedaddresspairs as addr_pair addr_pair.register_allowed_address_pair_opts() @@ -130,8 +129,6 @@ class Allowedaddresspairs(extensions.ExtensionDescriptor): def get_extended_resources(self, version): if version == "2.0": - attr.PLURALS.update({'allowed_address_pairs': - 'allowed_address_pair'}) return EXTENDED_ATTRIBUTES_2_0 else: return {} diff --git a/neutron/extensions/availability_zone.py b/neutron/extensions/availability_zone.py index 98dbedc40d5..1644c7dc635 100644 --- a/neutron/extensions/availability_zone.py +++ b/neutron/extensions/availability_zone.py @@ -22,7 +22,6 @@ import six from neutron._i18n import _ from neutron.api import extensions -from neutron.api.v2 import attributes as attr from neutron.api.v2 import base @@ -104,8 +103,6 @@ class Availability_zone(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Ext Resources.""" - my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()] - attr.PLURALS.update(dict(my_plurals)) plugin = directory.get_plugin() params = RESOURCE_ATTRIBUTE_MAP.get(AVAILABILITY_ZONES) controller = base.create_resource(AVAILABILITY_ZONES, diff --git a/neutron/extensions/extraroute.py b/neutron/extensions/extraroute.py index 867c7d4489b..c4eb5fe2e0b 100644 --- a/neutron/extensions/extraroute.py +++ b/neutron/extensions/extraroute.py @@ -19,7 +19,6 @@ from neutron_lib import exceptions as nexception from neutron._i18n import _ from neutron.api import extensions -from neutron.api.v2 import attributes as attr # Extra Routes Exceptions @@ -69,7 +68,6 @@ class Extraroute(extensions.ExtensionDescriptor): def get_extended_resources(self, version): if version == "2.0": - attr.PLURALS.update({'routes': 'route'}) return EXTENDED_ATTRIBUTES_2_0 else: return {} diff --git a/neutron/extensions/flavors.py b/neutron/extensions/flavors.py index 3ebc43bce07..3fcaadabf43 100644 --- a/neutron/extensions/flavors.py +++ b/neutron/extensions/flavors.py @@ -198,7 +198,6 @@ class Flavors(extensions.ExtensionDescriptor): """Returns Ext Resources.""" plural_mappings = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) - attr.PLURALS.update(plural_mappings) resources = resource_helper.build_resource_info( plural_mappings, RESOURCE_ATTRIBUTE_MAP, diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index 325db2a1bfb..693f1e7583e 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -190,7 +190,6 @@ class L3(extensions.ExtensionDescriptor): plural_mappings = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) plural_mappings['external_fixed_ips'] = 'external_fixed_ip' - attr.PLURALS.update(plural_mappings) action_map = {'router': {'add_router_interface': 'PUT', 'remove_router_interface': 'PUT'}} return resource_helper.build_resource_info(plural_mappings, diff --git a/neutron/extensions/metering.py b/neutron/extensions/metering.py index 1ef299875fe..816ea1347bb 100644 --- a/neutron/extensions/metering.py +++ b/neutron/extensions/metering.py @@ -114,7 +114,6 @@ class Metering(extensions.ExtensionDescriptor): """Returns Ext Resources.""" plural_mappings = resource_helper.build_plural_mappings( {}, RESOURCE_ATTRIBUTE_MAP) - attr.PLURALS.update(plural_mappings) # PCM: Metering sets pagination and sorting to True. Do we have cfg # entries for these so can be read? Else, must pass in. return resource_helper.build_resource_info(plural_mappings, diff --git a/neutron/extensions/network_ip_availability.py b/neutron/extensions/network_ip_availability.py index c7410abc109..a39f5f0a6cb 100644 --- a/neutron/extensions/network_ip_availability.py +++ b/neutron/extensions/network_ip_availability.py @@ -14,7 +14,6 @@ # limitations under the License. import neutron.api.extensions as extensions -import neutron.api.v2.attributes as attr import neutron.api.v2.base as base import neutron.services.network_ip_availability.plugin as plugin @@ -64,7 +63,6 @@ class Network_ip_availability(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Extended Resource for service type management.""" - attr.PLURALS[RESOURCE_PLURAL] = RESOURCE_NAME resource_attributes = RESOURCE_ATTRIBUTE_MAP[RESOURCE_PLURAL] controller = base.create_resource( RESOURCE_PLURAL, diff --git a/neutron/extensions/qos.py b/neutron/extensions/qos.py index 9b0ebd116c9..201413c54bd 100644 --- a/neutron/extensions/qos.py +++ b/neutron/extensions/qos.py @@ -160,7 +160,6 @@ class Qos(extensions.ExtensionDescriptor): plural_mappings = resource_helper.build_plural_mappings( special_mappings, itertools.chain(RESOURCE_ATTRIBUTE_MAP, SUB_RESOURCE_ATTRIBUTE_MAP)) - attr.PLURALS.update(plural_mappings) resources = resource_helper.build_resource_info( plural_mappings, diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index e90f5c43188..7c7f991b1f0 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -22,7 +22,6 @@ import webob from neutron._i18n import _ from neutron.api import extensions -from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.api.v2 import resource from neutron.common import constants as const @@ -163,8 +162,6 @@ class Quotasv2(extensions.ExtensionDescriptor): @classmethod def get_pecan_resources(cls): - # NOTE: quotas in PLURALS is needed because get_resources never sets it - attributes.PLURALS[RESOURCE_COLLECTION] = RESOURCE_NAME # NOTE: plugin is not needed for quotas return [pecan_utils.PecanResourceExtension( RESOURCE_COLLECTION, controllers.QuotasController(), None)] diff --git a/neutron/extensions/rbac.py b/neutron/extensions/rbac.py index b37ae844cdb..03ed5c53f87 100644 --- a/neutron/extensions/rbac.py +++ b/neutron/extensions/rbac.py @@ -104,8 +104,6 @@ class Rbac(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Ext Resources.""" - plural_mappings = {'rbac_policies': 'rbac_policy'} - attr.PLURALS.update(plural_mappings) plugin = directory.get_plugin() params = RESOURCE_ATTRIBUTE_MAP['rbac_policies'] collection_name = 'rbac-policies' diff --git a/neutron/extensions/securitygroup.py b/neutron/extensions/securitygroup.py index 2955937e1f8..c02ff76b537 100644 --- a/neutron/extensions/securitygroup.py +++ b/neutron/extensions/securitygroup.py @@ -303,8 +303,6 @@ class Securitygroup(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Ext Resources.""" - my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()] - attr.PLURALS.update(dict(my_plurals)) exts = [] plugin = directory.get_plugin() for resource_name in ['security_group', 'security_group_rule']: diff --git a/neutron/extensions/segment.py b/neutron/extensions/segment.py index 6dd12ada8fb..a178c9f5562 100644 --- a/neutron/extensions/segment.py +++ b/neutron/extensions/segment.py @@ -110,7 +110,6 @@ class Segment(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Extended Resource for service type management.""" - attributes.PLURALS[SEGMENTS] = SEGMENT resource_attributes = RESOURCE_ATTRIBUTE_MAP[SEGMENTS] controller = base.create_resource( SEGMENTS, diff --git a/neutron/extensions/servicetype.py b/neutron/extensions/servicetype.py index b7f18718ec0..ef18f09cd5b 100644 --- a/neutron/extensions/servicetype.py +++ b/neutron/extensions/servicetype.py @@ -15,7 +15,6 @@ from neutron._i18n import _ from neutron.api import extensions -from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.db import servicetype_db @@ -63,8 +62,6 @@ class Servicetype(extensions.ExtensionDescriptor): @classmethod def get_resources(cls): """Returns Extended Resource for service type management.""" - my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()] - attributes.PLURALS.update(dict(my_plurals)) attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME] collection_name = COLLECTION_NAME.replace('_', '-') controller = base.create_resource( diff --git a/neutron/extensions/trunk.py b/neutron/extensions/trunk.py index 5a92ec4774c..bc5a162b73c 100644 --- a/neutron/extensions/trunk.py +++ b/neutron/extensions/trunk.py @@ -16,7 +16,6 @@ from neutron_lib.api.definitions import trunk from neutron.api import extensions -from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper @@ -44,7 +43,6 @@ class Trunk(extensions.ExtensionDescriptor): """Returns Ext Resources.""" plural_mappings = resource_helper.build_plural_mappings( {}, trunk.RESOURCE_ATTRIBUTE_MAP) - attr.PLURALS.update(plural_mappings) return resource_helper.build_resource_info( plural_mappings, trunk.RESOURCE_ATTRIBUTE_MAP, diff --git a/neutron/tests/functional/pecan_wsgi/test_hooks.py b/neutron/tests/functional/pecan_wsgi/test_hooks.py index 056a1b25639..bbdedd8a6b0 100644 --- a/neutron/tests/functional/pecan_wsgi/test_hooks.py +++ b/neutron/tests/functional/pecan_wsgi/test_hooks.py @@ -113,7 +113,6 @@ class TestPolicyEnforcementHook(test_functional.PecanFunctionalTest): super(TestPolicyEnforcementHook, self).setUp() self.mock_plugin = mock.Mock() attributes.RESOURCE_ATTRIBUTE_MAP.update(self.FAKE_RESOURCE) - attributes.PLURALS['mehs'] = 'meh' manager.NeutronManager.set_plugin_for_resource('mehs', self.mock_plugin) fake_controller = resource.CollectionsController('mehs', 'meh') diff --git a/neutron/tests/functional/pecan_wsgi/utils.py b/neutron/tests/functional/pecan_wsgi/utils.py index ca2a6ea3b5d..1188c5ee6a6 100644 --- a/neutron/tests/functional/pecan_wsgi/utils.py +++ b/neutron/tests/functional/pecan_wsgi/utils.py @@ -11,7 +11,6 @@ # under the License. from neutron.api import extensions -from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.pecan_wsgi import controllers from neutron.pecan_wsgi.controllers import utils as pecan_utils @@ -164,7 +163,6 @@ class FakeExtension(extensions.ExtensionDescriptor): for collection_name in self.RESOURCE_ATTRIBUTE_MAP: resource_name = collection_name[:-1] params = self.RESOURCE_ATTRIBUTE_MAP.get(collection_name, {}) - attributes.PLURALS.update({collection_name: resource_name}) member_actions = {'put_meh': 'PUT', 'boo_meh': 'GET'} if collection_name == self.HYPHENATED_COLLECTION: collection_name = collection_name.replace('_', '-')