955fa1c075
This patch introduces an API to allocate an externally connected private tenant network on demand. The API is idempotent in that, once the topology is provisioned, further API calls keep returning the same topology to the caller. The API, as introduced by the patch, is not currently on, and its design carefully ensures minimal impact on the existing codebase. In fact the feature depends on and enhances the external-net extension, but it does so via callbacks. A subsequent patch in this series will make it available by default, and API tests will be added to validate the functionality. Partially-implements: blueprint get-me-a-network Co-Authored-By: Armando Migliaccio <armamig@gmail.com> Co-Authored-By: Henry Gessau <HenryG@gessau.net> Change-Id: I4abd45252026431452f0d2cb2805043489c2f6ad
81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
# Copyright 2015-2016 Hewlett Packard Enterprise Development Company, LP
|
|
#
|
|
# 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 import extensions
|
|
from neutron.api.v2 import attributes as attr
|
|
from neutron.api.v2 import base
|
|
from neutron.services.auto_allocate import plugin
|
|
|
|
RESOURCE_NAME = "auto_allocated_topology"
|
|
COLLECTION_NAME = "auto_allocated_topologies"
|
|
IS_DEFAULT = "is_default"
|
|
EXT_ALIAS = RESOURCE_NAME.replace('_', '-')
|
|
|
|
RESOURCE_ATTRIBUTE_MAP = {
|
|
COLLECTION_NAME: {
|
|
'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': attr.convert_to_boolean,
|
|
'enforce_policy': True,
|
|
'required_by_policy': True}},
|
|
}
|
|
|
|
|
|
class Auto_allocated_topology(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
|
|
def get_resources(cls):
|
|
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
|
|
controller = base.create_resource(COLLECTION_NAME,
|
|
EXT_ALIAS,
|
|
plugin.Plugin.get_instance(),
|
|
params, allow_bulk=False)
|
|
return [extensions.ResourceExtension(EXT_ALIAS, controller)]
|
|
|
|
def get_required_extensions(self):
|
|
return ["subnet_allocation", "external-net", "router"]
|
|
|
|
def get_extended_resources(self, version):
|
|
if version == "2.0":
|
|
return RESOURCE_ATTRIBUTE_MAP
|
|
else:
|
|
return {}
|