consume neutron-lib resources attr map
Today we shim the RESOURCE_ATTRIBUTE_MAP in neutron; it references the equivelant in neutron-lib named RESOURCES. This patch removes neutron's RESOURCE_ATTRIBUTE_MAP and cleans up neutron.api.v2.attributes in prep to delete it. To do so: - CORE_RESOURCES and RESOURCE_FOREIGN_KEYS are moved to the single module that references them respectively and the are made private (no consumers use them). - get_collection_info is removed and instead the 2 uses in neutron just use the get() method of the RESOURCES map. There are no external uses of get_collection_info. - References using RESOURCE_ATTRIBUTE_MAP are switched over to neutron-lib's RESOURCES. - The neutron.api.v2.attributes module is removed as it's empty now. - A few api attribute UTs are removed; there's nothing to test as per this patch. NeutronLibImpact Change-Id: Iaacee584d499c4d33d6d2dd9609c7ac0f2cfc386changes/02/533002/7
parent
6e65876138
commit
44292f4c9a
@ -1,43 +0,0 @@
|
||||
# Copyright (c) 2012 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import attributes as attrs
|
||||
from neutron_lib.api.definitions import network as net_def
|
||||
from neutron_lib.api.definitions import port as port_def
|
||||
from neutron_lib.api.definitions import subnet as subnet_def
|
||||
from neutron_lib.api.definitions import subnetpool as subnetpool_def
|
||||
|
||||
|
||||
# Define constants for base resource name
|
||||
CORE_RESOURCES = {net_def.RESOURCE_NAME: net_def.COLLECTION_NAME,
|
||||
subnet_def.RESOURCE_NAME: subnet_def.COLLECTION_NAME,
|
||||
subnetpool_def.RESOURCE_NAME: subnetpool_def.COLLECTION_NAME,
|
||||
port_def.RESOURCE_NAME: port_def.COLLECTION_NAME}
|
||||
|
||||
RESOURCE_ATTRIBUTE_MAP = attrs.RESOURCES
|
||||
|
||||
# Identify the attribute used by a resource to reference another resource
|
||||
|
||||
RESOURCE_FOREIGN_KEYS = {
|
||||
net_def.COLLECTION_NAME: 'network_id'
|
||||
}
|
||||
|
||||
|
||||
def get_collection_info(collection):
|
||||
"""Helper function to retrieve attribute info.
|
||||
|
||||
:param collection: Collection or plural name of the resource
|
||||
"""
|
||||
return RESOURCE_ATTRIBUTE_MAP.get(collection)
|
@ -1,32 +0,0 @@
|
||||
# Copyright 2012 OpenStack Foundation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestHelpers(base.DietTestCase):
|
||||
|
||||
def _verify_port_attributes(self, attrs):
|
||||
for test_attribute in ('id', 'name', 'mac_address', 'network_id',
|
||||
'tenant_id', 'fixed_ips', 'status'):
|
||||
self.assertIn(test_attribute, attrs)
|
||||
|
||||
def test_get_collection_info(self):
|
||||
attrs = attributes.get_collection_info('ports')
|
||||
self._verify_port_attributes(attrs)
|
||||
|
||||
def test_get_collection_info_missing(self):
|
||||
self.assertFalse(attributes.get_collection_info('meh'))
|
Loading…
Reference in New Issue