use neutron-lib auto allocated topology apidef
neutron-lib contains the auto allocated topology API definition. This patch moves neutron over to lib's API def for it. Note that we don't have any external (out-of-tree) consumers of this. Change-Id: I01a3c99ae958bf0f57d27b4437065ba5b8de7908
This commit is contained in:
parent
e489c50f9c
commit
e993a26292
@ -14,69 +14,25 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron_lib.api import converters
|
from neutron_lib.api.definitions import auto_allocated_topology
|
||||||
from neutron_lib.api import extensions as api_extensions
|
from neutron_lib.api import extensions as api_extensions
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
|
|
||||||
from neutron.api import extensions
|
from neutron.api import extensions
|
||||||
from neutron.api.v2 import base
|
from neutron.api.v2 import base
|
||||||
|
|
||||||
RESOURCE_NAME = "auto_allocated_topology"
|
|
||||||
COLLECTION_NAME = "auto_allocated_topologies"
|
|
||||||
IS_DEFAULT = "is_default"
|
|
||||||
EXT_ALIAS = RESOURCE_NAME.replace('_', '-')
|
|
||||||
|
|
||||||
RESOURCE_ATTRIBUTE_MAP = {
|
class Auto_allocated_topology(api_extensions.APIExtensionDescriptor):
|
||||||
COLLECTION_NAME: {
|
api_definition = auto_allocated_topology
|
||||||
'id': {'allow_post': False, 'allow_put': False,
|
|
||||||
'validate': {'type:uuid': None},
|
|
||||||
'is_visible': True},
|
|
||||||
'tenant_id': {'allow_post': False, 'allow_put': False,
|
|
||||||
'validate': {'type:uuid': None},
|
|
||||||
'is_visible': True},
|
|
||||||
},
|
|
||||||
'networks': {IS_DEFAULT: {'allow_post': True,
|
|
||||||
'allow_put': True,
|
|
||||||
'default': False,
|
|
||||||
'is_visible': True,
|
|
||||||
'convert_to': converters.convert_to_boolean,
|
|
||||||
'enforce_policy': True,
|
|
||||||
'required_by_policy': True}},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Auto_allocated_topology(api_extensions.ExtensionDescriptor):
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_name(cls):
|
|
||||||
return "Auto Allocated Topology Services"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_alias(cls):
|
|
||||||
return EXT_ALIAS
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_description(cls):
|
|
||||||
return "Auto Allocated Topology Services."
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_updated(cls):
|
|
||||||
return "2016-01-01T00:00:00-00:00"
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resources(cls):
|
def get_resources(cls):
|
||||||
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
|
params = auto_allocated_topology.RESOURCE_ATTRIBUTE_MAP.get(
|
||||||
controller = base.create_resource(COLLECTION_NAME,
|
auto_allocated_topology.COLLECTION_NAME, dict())
|
||||||
EXT_ALIAS,
|
controller = base.create_resource(
|
||||||
directory.get_plugin(EXT_ALIAS),
|
auto_allocated_topology.COLLECTION_NAME,
|
||||||
params, allow_bulk=False)
|
auto_allocated_topology.ALIAS,
|
||||||
return [extensions.ResourceExtension(EXT_ALIAS, controller)]
|
directory.get_plugin(auto_allocated_topology.ALIAS),
|
||||||
|
params, allow_bulk=False)
|
||||||
def get_required_extensions(self):
|
return [extensions.ResourceExtension(
|
||||||
return ["subnet_allocation", "external-net", "router"]
|
auto_allocated_topology.ALIAS, controller)]
|
||||||
|
|
||||||
def get_extended_resources(self, version):
|
|
||||||
if version == "2.0":
|
|
||||||
return RESOURCE_ATTRIBUTE_MAP
|
|
||||||
else:
|
|
||||||
return {}
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from neutron_lib.api.definitions import auto_allocated_topology
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from tempest.lib import decorators
|
from tempest.lib import decorators
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
|
|||||||
# all tests are added under TestAutoAllocatedTopology,
|
# all tests are added under TestAutoAllocatedTopology,
|
||||||
# nothing bad should happen.
|
# nothing bad should happen.
|
||||||
force_tenant_isolation = True
|
force_tenant_isolation = True
|
||||||
required_extensions = ['auto-allocated-topology']
|
required_extensions = [auto_allocated_topology.ALIAS]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_setup(cls):
|
def resource_setup(cls):
|
||||||
@ -84,7 +85,7 @@ class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
|
|||||||
self.assertEqual((0, 0, 0), resources_before)
|
self.assertEqual((0, 0, 0), resources_before)
|
||||||
|
|
||||||
body = self.client.get_auto_allocated_topology()
|
body = self.client.get_auto_allocated_topology()
|
||||||
topology = body['auto_allocated_topology']
|
topology = body[auto_allocated_topology.RESOURCE_NAME]
|
||||||
self.assertIsNotNone(topology)
|
self.assertIsNotNone(topology)
|
||||||
self._add_topology_cleanup(self.client)
|
self._add_topology_cleanup(self.client)
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
|
|||||||
self.assertEqual((1, self.num_subnetpools, 1), resources_after1)
|
self.assertEqual((1, self.num_subnetpools, 1), resources_after1)
|
||||||
|
|
||||||
body = self.client.get_auto_allocated_topology()
|
body = self.client.get_auto_allocated_topology()
|
||||||
topology = body['auto_allocated_topology']
|
topology = body[auto_allocated_topology.RESOURCE_NAME]
|
||||||
network_id2 = topology['id']
|
network_id2 = topology['id']
|
||||||
resources_after2 = self._count_topology_resources()
|
resources_after2 = self._count_topology_resources()
|
||||||
# After the initial GET, the API should be idempotent
|
# After the initial GET, the API should be idempotent
|
||||||
@ -109,7 +110,7 @@ class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
|
|||||||
resources_before = self._count_topology_resources()
|
resources_before = self._count_topology_resources()
|
||||||
self.assertEqual((0, 0, 0), resources_before)
|
self.assertEqual((0, 0, 0), resources_before)
|
||||||
body = self.client.get_auto_allocated_topology()
|
body = self.client.get_auto_allocated_topology()
|
||||||
topology = body['auto_allocated_topology']
|
topology = body[auto_allocated_topology.RESOURCE_NAME]
|
||||||
self.assertIsNotNone(topology)
|
self.assertIsNotNone(topology)
|
||||||
self.client.delete_auto_allocated_topology()
|
self.client.delete_auto_allocated_topology()
|
||||||
resources_after = self._count_topology_resources()
|
resources_after = self._count_topology_resources()
|
||||||
|
Loading…
Reference in New Issue
Block a user