2f2f2de159480f852b1390faad6872c3ab01b6dd
[openstack-build/neutron-build.git] / neutron / tests / unit / extensions / extendedattribute.py
1 # Copyright 2013 VMware, Inc.  All rights reserved.
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
4 #    not use this file except in compliance with the License. You may obtain
5 #    a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 #    License for the specific language governing permissions and limitations
13 #    under the License.
14
15 from neutron.api import extensions
16
17 EXTENDED_ATTRIBUTE = 'extended_attribute'
18 EXTENDED_ATTRIBUTES_2_0 = {
19     'ext_test_resources': {
20         EXTENDED_ATTRIBUTE: {'allow_post': True, 'allow_put': False,
21                              'validate': {'type:uuid_or_none': None},
22                              'default': None, 'is_visible': True},
23     }
24 }
25
26
27 class Extendedattribute(extensions.ExtensionDescriptor):
28     """Extension class supporting extended attribute for router."""
29
30     @classmethod
31     def get_name(cls):
32         return "Extended Extension Attributes"
33
34     @classmethod
35     def get_alias(cls):
36         return "extended-ext-attr"
37
38     @classmethod
39     def get_description(cls):
40         return "Provides extended_attr attribute to router"
41
42     @classmethod
43     def get_updated(cls):
44         return "2013-02-05T00:00:00-00:00"
45
46     def get_extended_resources(self, version):
47         if version == "2.0":
48             return EXTENDED_ATTRIBUTES_2_0
49         else:
50             return {}