Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added key_value pair as a list of dict. Modified the behavior of pool-update, only support bulk-update for kvps. Incorporated Prakash's comments. Closes Bug: #1475393 Change-Id: Ib7381b30eba3fffd03e9a11e57510b04653e4ac3
- Loading branch information
Varun Lodaya
authored and
Varun Lodaya
committed
Aug 17, 2015
1 parent
7e7a7ce
commit 6588ebf
Showing
3 changed files
with
96 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters