Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Allow custom configs with LBaaS
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 Allow custom configs with LBaaS This fix checks if custom_attributes is not specified or not in the create config. If not specified, it skips Closes Bug: #1475393 Change-Id: I55d524586fb906e801922af137309bfcdedf9a89
- Loading branch information
Varun Lodaya
committed
Nov 6, 2015
1 parent
77b7d4e
commit 3b9d389
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