vmware-nsx/vmware_nsx/extensions/lsn.py
Henry Gessau 37487161bd Use ExtensionDescriptor from neutron-lib
ExtensionDescriptor has been rehomed to neutron-lib and is being
removed from neutron core.

See https://review.openstack.org/398113

Depends-On: I5a111e0033e518e39b3042f047ee9eebba77a0d5

Change-Id: I0f8b11bebed9bbb06273c0f9257ec1916e0201ea
2016-11-28 01:30:38 -08:00

80 lines
2.5 KiB
Python

# Copyright 2014 VMware, Inc.
#
# 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 base
from neutron_lib.api import extensions as api_extensions
from neutron_lib.plugins import directory
EXT_ALIAS = 'lsn'
COLLECTION_NAME = "%ss" % EXT_ALIAS
RESOURCE_ATTRIBUTE_MAP = {
COLLECTION_NAME: {
'network': {'allow_post': True, 'allow_put': False,
'validate': {'type:string': None},
'is_visible': True},
'report': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False,
'required_by_policy': True,
'validate': {'type:string': None}, 'is_visible': True},
},
}
class Lsn(api_extensions.ExtensionDescriptor):
"""Enable LSN configuration for Neutron NSX networks."""
@classmethod
def get_name(cls):
return "Logical Service Node configuration"
@classmethod
def get_alias(cls):
return EXT_ALIAS
@classmethod
def get_description(cls):
return "Enables configuration of NSX Logical Services Node."
@classmethod
def get_updated(cls):
return "2013-10-05T10:00:00-00:00"
@classmethod
def get_resources(cls):
"""Returns Ext Resources."""
exts = []
plugin = directory.get_plugin()
resource_name = EXT_ALIAS
collection_name = resource_name.replace('_', '-') + "s"
params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
controller = base.create_resource(collection_name,
resource_name,
plugin, params, allow_bulk=False)
ex = extensions.ResourceExtension(collection_name, controller)
exts.append(ex)
return exts
def get_extended_resources(self, version):
if version == "2.0":
return RESOURCE_ATTRIBUTE_MAP
else:
return {}