/
loadbalancer.py
56 lines (43 loc) · 1.49 KB
/
loadbalancer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from neutron.api.v2 import attributes as attr
from neutron.api import extensions
def _validate_custom_attributes(data, valid_values=None):
if not isinstance(data, list):
msg = _("Invalid data format for custom_attributes: '%s'") % data
return msg
def convert_none_to_empty_list(value):
return [] if value is None else value
attr.validators['type:customattributes'] = _validate_custom_attributes
# Extended_Attribute MAP
EXTENDED_ATTRIBUTES_2_0 = {
'pools': {
'custom_attributes': {'allow_post': True, 'allow_put': True,
'convert_to': convert_none_to_empty_list,
'default': attr.ATTR_NOT_SPECIFIED,
'validate': {'type:customattributes': None},
'is_visible': True},
}
}
class Loadbalancer(object):
@classmethod
def get_name(cls):
return "Loadbalancer as a Service"
@classmethod
def get_alias(cls):
return "extra_lbaas_opts"
@classmethod
def get_description(cls):
return "Custom LBaaS attributes"
@classmethod
def get_namespace(cls):
return "http://docs.openstack.org/TODO"
@classmethod
def get_updated(cls):
return "2015-07-17T15:00:00-00:00"
@classmethod
def get_extended_resources(self, version):
"""Returns Ext Resources"""
if version == "2.0":
return EXTENDED_ATTRIBUTES_2_0
else:
return {}
#end class Loadbalancer