Merge "Remove PLURALS"

This commit is contained in:
Jenkins
2016-12-01 20:32:15 +00:00
committed by Gerrit Code Review
19 changed files with 2 additions and 44 deletions

View File

@@ -287,16 +287,8 @@ RESOURCE_FOREIGN_KEYS = {
NETWORKS: 'network_id' NETWORKS: 'network_id'
} }
# Store plural/singular mappings # Removing PLURALS breaks subprojects, but they don't need it so they
PLURALS = {NETWORKS: NETWORK, # need to be patched.
PORTS: PORT,
SUBNETS: SUBNET,
SUBNETPOOLS: SUBNETPOOL,
'dns_nameservers': 'dns_nameserver',
'host_routes': 'host_route',
'allocation_pools': 'allocation_pool',
'fixed_ips': 'fixed_ip',
'extensions': 'extension'}
def get_collection_info(collection): def get_collection_info(collection):

View File

@@ -116,8 +116,6 @@ class Address_scope(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """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() plugin = directory.get_plugin()
collection_name = ADDRESS_SCOPES.replace('_', '-') collection_name = ADDRESS_SCOPES.replace('_', '-')
params = RESOURCE_ATTRIBUTE_MAP.get(ADDRESS_SCOPES, dict()) params = RESOURCE_ATTRIBUTE_MAP.get(ADDRESS_SCOPES, dict())

View File

@@ -98,8 +98,6 @@ class Agent(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """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() plugin = directory.get_plugin()
params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's') params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's')
controller = base.create_resource(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._i18n import _
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.conf.extensions import allowedaddresspairs as addr_pair from neutron.conf.extensions import allowedaddresspairs as addr_pair
addr_pair.register_allowed_address_pair_opts() addr_pair.register_allowed_address_pair_opts()
@@ -130,8 +129,6 @@ class Allowedaddresspairs(extensions.ExtensionDescriptor):
def get_extended_resources(self, version): def get_extended_resources(self, version):
if version == "2.0": if version == "2.0":
attr.PLURALS.update({'allowed_address_pairs':
'allowed_address_pair'})
return EXTENDED_ATTRIBUTES_2_0 return EXTENDED_ATTRIBUTES_2_0
else: else:
return {} return {}

View File

@@ -22,7 +22,6 @@ import six
from neutron._i18n import _ from neutron._i18n import _
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import base from neutron.api.v2 import base
@@ -104,8 +103,6 @@ class Availability_zone(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """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() plugin = directory.get_plugin()
params = RESOURCE_ATTRIBUTE_MAP.get(AVAILABILITY_ZONES) params = RESOURCE_ATTRIBUTE_MAP.get(AVAILABILITY_ZONES)
controller = base.create_resource(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._i18n import _
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes as attr
# Extra Routes Exceptions # Extra Routes Exceptions
@@ -69,7 +68,6 @@ class Extraroute(extensions.ExtensionDescriptor):
def get_extended_resources(self, version): def get_extended_resources(self, version):
if version == "2.0": if version == "2.0":
attr.PLURALS.update({'routes': 'route'})
return EXTENDED_ATTRIBUTES_2_0 return EXTENDED_ATTRIBUTES_2_0
else: else:
return {} return {}

View File

@@ -198,7 +198,6 @@ class Flavors(extensions.ExtensionDescriptor):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP) {}, RESOURCE_ATTRIBUTE_MAP)
attr.PLURALS.update(plural_mappings)
resources = resource_helper.build_resource_info( resources = resource_helper.build_resource_info(
plural_mappings, plural_mappings,
RESOURCE_ATTRIBUTE_MAP, RESOURCE_ATTRIBUTE_MAP,

View File

@@ -190,7 +190,6 @@ class L3(extensions.ExtensionDescriptor):
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP) {}, RESOURCE_ATTRIBUTE_MAP)
plural_mappings['external_fixed_ips'] = 'external_fixed_ip' plural_mappings['external_fixed_ips'] = 'external_fixed_ip'
attr.PLURALS.update(plural_mappings)
action_map = {'router': {'add_router_interface': 'PUT', action_map = {'router': {'add_router_interface': 'PUT',
'remove_router_interface': 'PUT'}} 'remove_router_interface': 'PUT'}}
return resource_helper.build_resource_info(plural_mappings, return resource_helper.build_resource_info(plural_mappings,

View File

@@ -114,7 +114,6 @@ class Metering(extensions.ExtensionDescriptor):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
{}, RESOURCE_ATTRIBUTE_MAP) {}, RESOURCE_ATTRIBUTE_MAP)
attr.PLURALS.update(plural_mappings)
# PCM: Metering sets pagination and sorting to True. Do we have cfg # PCM: Metering sets pagination and sorting to True. Do we have cfg
# entries for these so can be read? Else, must pass in. # entries for these so can be read? Else, must pass in.
return resource_helper.build_resource_info(plural_mappings, return resource_helper.build_resource_info(plural_mappings,

View File

@@ -14,7 +14,6 @@
# limitations under the License. # limitations under the License.
import neutron.api.extensions as extensions import neutron.api.extensions as extensions
import neutron.api.v2.attributes as attr
import neutron.api.v2.base as base import neutron.api.v2.base as base
import neutron.services.network_ip_availability.plugin as plugin import neutron.services.network_ip_availability.plugin as plugin
@@ -64,7 +63,6 @@ class Network_ip_availability(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Extended Resource for service type management.""" """Returns Extended Resource for service type management."""
attr.PLURALS[RESOURCE_PLURAL] = RESOURCE_NAME
resource_attributes = RESOURCE_ATTRIBUTE_MAP[RESOURCE_PLURAL] resource_attributes = RESOURCE_ATTRIBUTE_MAP[RESOURCE_PLURAL]
controller = base.create_resource( controller = base.create_resource(
RESOURCE_PLURAL, RESOURCE_PLURAL,

View File

@@ -160,7 +160,6 @@ class Qos(extensions.ExtensionDescriptor):
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
special_mappings, itertools.chain(RESOURCE_ATTRIBUTE_MAP, special_mappings, itertools.chain(RESOURCE_ATTRIBUTE_MAP,
SUB_RESOURCE_ATTRIBUTE_MAP)) SUB_RESOURCE_ATTRIBUTE_MAP))
attr.PLURALS.update(plural_mappings)
resources = resource_helper.build_resource_info( resources = resource_helper.build_resource_info(
plural_mappings, plural_mappings,

View File

@@ -22,7 +22,6 @@ import webob
from neutron._i18n import _ from neutron._i18n import _
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.api.v2 import base from neutron.api.v2 import base
from neutron.api.v2 import resource from neutron.api.v2 import resource
from neutron.common import constants as const from neutron.common import constants as const
@@ -163,8 +162,6 @@ class Quotasv2(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_pecan_resources(cls): 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 # NOTE: plugin is not needed for quotas
return [pecan_utils.PecanResourceExtension( return [pecan_utils.PecanResourceExtension(
RESOURCE_COLLECTION, controllers.QuotasController(), None)] RESOURCE_COLLECTION, controllers.QuotasController(), None)]

View File

@@ -104,8 +104,6 @@ class Rbac(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plural_mappings = {'rbac_policies': 'rbac_policy'}
attr.PLURALS.update(plural_mappings)
plugin = directory.get_plugin() plugin = directory.get_plugin()
params = RESOURCE_ATTRIBUTE_MAP['rbac_policies'] params = RESOURCE_ATTRIBUTE_MAP['rbac_policies']
collection_name = 'rbac-policies' collection_name = 'rbac-policies'

View File

@@ -303,8 +303,6 @@ class Securitygroup(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Ext Resources.""" """Returns Ext Resources."""
my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
attr.PLURALS.update(dict(my_plurals))
exts = [] exts = []
plugin = directory.get_plugin() plugin = directory.get_plugin()
for resource_name in ['security_group', 'security_group_rule']: for resource_name in ['security_group', 'security_group_rule']:

View File

@@ -110,7 +110,6 @@ class Segment(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Extended Resource for service type management.""" """Returns Extended Resource for service type management."""
attributes.PLURALS[SEGMENTS] = SEGMENT
resource_attributes = RESOURCE_ATTRIBUTE_MAP[SEGMENTS] resource_attributes = RESOURCE_ATTRIBUTE_MAP[SEGMENTS]
controller = base.create_resource( controller = base.create_resource(
SEGMENTS, SEGMENTS,

View File

@@ -15,7 +15,6 @@
from neutron._i18n import _ from neutron._i18n import _
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.api.v2 import base from neutron.api.v2 import base
from neutron.db import servicetype_db from neutron.db import servicetype_db
@@ -63,8 +62,6 @@ class Servicetype(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_resources(cls): def get_resources(cls):
"""Returns Extended Resource for service type management.""" """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] attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
collection_name = COLLECTION_NAME.replace('_', '-') collection_name = COLLECTION_NAME.replace('_', '-')
controller = base.create_resource( controller = base.create_resource(

View File

@@ -16,7 +16,6 @@
from neutron_lib.api.definitions import trunk from neutron_lib.api.definitions import trunk
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper from neutron.api.v2 import resource_helper
@@ -44,7 +43,6 @@ class Trunk(extensions.ExtensionDescriptor):
"""Returns Ext Resources.""" """Returns Ext Resources."""
plural_mappings = resource_helper.build_plural_mappings( plural_mappings = resource_helper.build_plural_mappings(
{}, trunk.RESOURCE_ATTRIBUTE_MAP) {}, trunk.RESOURCE_ATTRIBUTE_MAP)
attr.PLURALS.update(plural_mappings)
return resource_helper.build_resource_info( return resource_helper.build_resource_info(
plural_mappings, plural_mappings,
trunk.RESOURCE_ATTRIBUTE_MAP, trunk.RESOURCE_ATTRIBUTE_MAP,

View File

@@ -113,7 +113,6 @@ class TestPolicyEnforcementHook(test_functional.PecanFunctionalTest):
super(TestPolicyEnforcementHook, self).setUp() super(TestPolicyEnforcementHook, self).setUp()
self.mock_plugin = mock.Mock() self.mock_plugin = mock.Mock()
attributes.RESOURCE_ATTRIBUTE_MAP.update(self.FAKE_RESOURCE) attributes.RESOURCE_ATTRIBUTE_MAP.update(self.FAKE_RESOURCE)
attributes.PLURALS['mehs'] = 'meh'
manager.NeutronManager.set_plugin_for_resource('mehs', manager.NeutronManager.set_plugin_for_resource('mehs',
self.mock_plugin) self.mock_plugin)
fake_controller = resource.CollectionsController('mehs', 'meh') fake_controller = resource.CollectionsController('mehs', 'meh')

View File

@@ -11,7 +11,6 @@
# under the License. # under the License.
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.api.v2 import base from neutron.api.v2 import base
from neutron.pecan_wsgi import controllers from neutron.pecan_wsgi import controllers
from neutron.pecan_wsgi.controllers import utils as pecan_utils 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: for collection_name in self.RESOURCE_ATTRIBUTE_MAP:
resource_name = collection_name[:-1] resource_name = collection_name[:-1]
params = self.RESOURCE_ATTRIBUTE_MAP.get(collection_name, {}) params = self.RESOURCE_ATTRIBUTE_MAP.get(collection_name, {})
attributes.PLURALS.update({collection_name: resource_name})
member_actions = {'put_meh': 'PUT', 'boo_meh': 'GET'} member_actions = {'put_meh': 'PUT', 'boo_meh': 'GET'}
if collection_name == self.HYPHENATED_COLLECTION: if collection_name == self.HYPHENATED_COLLECTION:
collection_name = collection_name.replace('_', '-') collection_name = collection_name.replace('_', '-')