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
This commit is contained in:
Henry Gessau 2016-11-16 11:50:27 -05:00
parent 9355d73ead
commit f33bada2a9
19 changed files with 2 additions and 44 deletions

View File

@ -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):

View File

@ -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())

View File

@ -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',

View File

@ -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 {}

View File

@ -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,

View File

@ -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 {}

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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)]

View File

@ -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'

View File

@ -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']:

View File

@ -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,

View File

@ -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(

View File

@ -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,

View File

@ -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')

View File

@ -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('_', '-')