Added libcloud guard for Managed Instance Groups. (#4911)

This commit is contained in:
Tom Melendez 2016-10-13 05:33:13 -07:00 committed by Matt Clay
parent 72635db94d
commit a4077537e0

View file

@ -596,7 +596,6 @@ def get_mig(gce, name, zone):
def main(): def main():
module = AnsibleModule(argument_spec=dict( module = AnsibleModule(argument_spec=dict(
name=dict(required=True), name=dict(required=True),
template=dict(), template=dict(),
@ -619,7 +618,13 @@ def main():
msg="GCE module requires python's 'ast' module, python v2.6+") msg="GCE module requires python's 'ast' module, python v2.6+")
if not HAS_LIBCLOUD: if not HAS_LIBCLOUD:
module.fail_json( module.fail_json(
msg='libcloud with GCE Managed Instance Group support (1.1+) required for this module.') msg='libcloud with GCE Managed Instance Group support (1.2+) required for this module.')
gce = gce_connect(module)
if not hasattr(gce, 'ex_create_instancegroupmanager'):
module.fail_json(
msg='libcloud with GCE Managed Instance Group support (1.2+) required for this module.',
changed=False)
params = {} params = {}
params['state'] = module.params.get('state') params['state'] = module.params.get('state')
@ -634,7 +639,6 @@ def main():
if not valid_autoscaling: if not valid_autoscaling:
module.fail_json(msg=as_msg, changed=False) module.fail_json(msg=as_msg, changed=False)
gce = gce_connect(module)
changed = False changed = False
json_output = {'state': params['state'], 'zone': params['zone']} json_output = {'state': params['state'], 'zone': params['zone']}
mig = get_mig(gce, params['name'], params['zone']) mig = get_mig(gce, params['name'], params['zone'])