Make a few enhancements to the rax_scaling_group module

* Cast loadbalancer id and port to integers
* Do not attempt to base64 encode NoneType values
This commit is contained in:
Matt Martz 2014-12-10 14:37:38 -06:00 committed by Matt Clay
parent 63b18ae618
commit 411e4cfae8

View file

@ -209,8 +209,16 @@ def rax_asg(module, cooldown=300, disk_config=None, files={}, flavor=None,
lbs = [] lbs = []
if loadbalancers: if loadbalancers:
for lb in loadbalancers: for lb in loadbalancers:
lb_id = lb.get('id') try:
port = lb.get('port') lb_id = int(lb.get('id'))
except (ValueError, TypeError):
module.fail_json(msg='Load balancer ID is not an integer: '
'%s' % lb.get('id'))
try:
port = int(lb.get('port'))
except (ValueError, TypeError):
module.fail_json(msg='Load balancer port is not an '
'integer: %s' % lb.get('port'))
if not lb_id or not port: if not lb_id or not port:
continue continue
lbs.append((lb_id, port)) lbs.append((lb_id, port))
@ -294,7 +302,8 @@ def rax_asg(module, cooldown=300, disk_config=None, files={}, flavor=None,
if config_drive != lc.get('config_drive'): if config_drive != lc.get('config_drive'):
lc_args['config_drive'] = config_drive lc_args['config_drive'] = config_drive
if base64.b64encode(user_data) != lc.get('user_data'): if (user_data and
base64.b64encode(user_data) != lc.get('user_data')):
lc_args['user_data'] = user_data lc_args['user_data'] = user_data
if lc_args: if lc_args: