3e09bb302c3d75a79b40d283a8a8caf20e3d88e3
[openstack-build/neutron-build.git] / neutron / extensions / router_availability_zone.py
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 #    http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 # implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 import abc
16
17 import six
18
19 from neutron.api import extensions
20 from neutron.extensions import availability_zone as az_ext
21
22
23 EXTENDED_ATTRIBUTES_2_0 = {
24     'routers': {
25         az_ext.AVAILABILITY_ZONES: {'allow_post': False, 'allow_put': False,
26                                     'is_visible': True},
27         az_ext.AZ_HINTS: {
28                 'allow_post': True, 'allow_put': False, 'is_visible': True,
29                 'validate': {'type:availability_zone_hints': None},
30                 'default': []}}
31 }
32
33
34 class Router_availability_zone(extensions.ExtensionDescriptor):
35     """Router availability zone extension."""
36
37     @classmethod
38     def get_name(cls):
39         return "Router Availability Zone"
40
41     @classmethod
42     def get_alias(cls):
43         return "router_availability_zone"
44
45     @classmethod
46     def get_description(cls):
47         return "Availability zone support for router."
48
49     @classmethod
50     def get_updated(cls):
51         return "2015-01-01T10:00:00-00:00"
52
53     def get_required_extensions(self):
54         return ["router", "availability_zone"]
55
56     def get_extended_resources(self, version):
57         if version == "2.0":
58             return EXTENDED_ATTRIBUTES_2_0
59         else:
60             return {}
61
62
63 @six.add_metaclass(abc.ABCMeta)
64 class RouterAvailabilityZonePluginBase(object):
65
66     @abc.abstractmethod
67     def get_router_availability_zones(self, router):
68         """Return availability zones which a router belongs to."""