"Fossies" - the Fresh Open Source Software Archive

Member "tacker-2.0.0/tacker/tests/unit/extensions/extensionattribute.py" (16 Oct 2019, 3127 Bytes) of package /linux/misc/openstack/tacker-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Copyright 2013 VMware, Inc.
    2 # All rights reserved.
    3 #
    4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    5 #    not use this file except in compliance with the License. You may obtain
    6 #    a copy of the License at
    7 #
    8 #         http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 #    Unless required by applicable law or agreed to in writing, software
   11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 #    License for the specific language governing permissions and limitations
   14 #    under the License.
   15 
   16 import abc
   17 
   18 from tacker.api import extensions
   19 from tacker.api.v1 import base
   20 from tacker import manager
   21 
   22 
   23 # Attribute Map
   24 RESOURCE_ATTRIBUTE_MAP = {
   25     'ext_test_resources': {
   26         'id': {'allow_post': False, 'allow_put': False,
   27                'validate': {'type:uuid': None},
   28                'is_visible': True},
   29         'name': {'allow_post': True, 'allow_put': True,
   30                  'validate': {'type:string': None},
   31                  'is_visible': True, 'default': ''},
   32         'tenant_id': {'allow_post': True, 'allow_put': False,
   33                       'required_by_policy': True,
   34                       'validate': {'type:string': None},
   35                       'is_visible': True},
   36     }
   37 }
   38 
   39 
   40 class Extensionattribute(extensions.ExtensionDescriptor):
   41 
   42     @classmethod
   43     def get_name(cls):
   44         return "Extension Test Resource"
   45 
   46     @classmethod
   47     def get_alias(cls):
   48         return "ext-obj-test"
   49 
   50     @classmethod
   51     def get_description(cls):
   52         return "Extension Test Resource"
   53 
   54     @classmethod
   55     def get_namespace(cls):
   56         return ""
   57 
   58     @classmethod
   59     def get_updated(cls):
   60         return "2013-02-05T10:00:00-00:00"
   61 
   62     def update_attributes_map(self, attributes):
   63         super(Extensionattribute, self).update_attributes_map(
   64             attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)
   65 
   66     @classmethod
   67     def get_resources(cls):
   68         """Returns Ext Resources."""
   69         exts = []
   70         plugin = manager.TackerManager.get_plugin()
   71         resource_name = 'ext_test_resource'
   72         collection_name = resource_name + "s"
   73         params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
   74 
   75         controller = base.create_resource(collection_name,
   76                                           resource_name,
   77                                           plugin, params,
   78                                           member_actions={})
   79 
   80         ex = extensions.ResourceExtension(collection_name,
   81                                           controller,
   82                                           member_actions={})
   83         exts.append(ex)
   84 
   85         return exts
   86 
   87     def get_extended_resources(self, version):
   88         if version == "2.0":
   89             return RESOURCE_ATTRIBUTE_MAP
   90         else:
   91             return {}
   92 
   93 
   94 class ExtensionObjectTestPluginBase(object):
   95 
   96     @abc.abstractmethod
   97     def create_ext_test_resource(self, context, router):
   98         pass
   99 
  100     @abc.abstractmethod
  101     def get_ext_test_resource(self, context, id, fields=None):
  102         pass