Merge pull request #1082 from daniel-sc/devel

configurable timeout for creating gce image
reviewable/pr18780/r1
Brian Coca 9 years ago
commit 6342d35c48

@ -59,6 +59,12 @@ options:
required: false required: false
default: "us-central1-a" default: "us-central1-a"
aliases: [] aliases: []
timeout:
description:
- timeout for the operation
required: false
default: 180
aliases: []
service_account_email: service_account_email:
description: description:
- service account email - service account email
@ -130,6 +136,7 @@ def create_image(gce, name, module):
source = module.params.get('source') source = module.params.get('source')
zone = module.params.get('zone') zone = module.params.get('zone')
desc = module.params.get('description') desc = module.params.get('description')
timeout = module.params.get('timeout')
if not source: if not source:
module.fail_json(msg='Must supply a source', changed=False) module.fail_json(msg='Must supply a source', changed=False)
@ -149,13 +156,17 @@ def create_image(gce, name, module):
except GoogleBaseError, e: except GoogleBaseError, e:
module.fail_json(msg=str(e), changed=False) module.fail_json(msg=str(e), changed=False)
old_timeout = gce.connection.timeout
try: try:
gce.connection.timeout = timeout
gce.ex_create_image(name, volume, desc, False) gce.ex_create_image(name, volume, desc, False)
return True return True
except ResourceExistsError: except ResourceExistsError:
return False return False
except GoogleBaseError, e: except GoogleBaseError, e:
module.fail_json(msg=str(e), changed=False) module.fail_json(msg=str(e), changed=False)
finally:
gce.connection.timeout = old_timeout
def delete_image(gce, name, module): def delete_image(gce, name, module):
@ -180,6 +191,7 @@ def main():
service_account_email=dict(), service_account_email=dict(),
pem_file=dict(), pem_file=dict(),
project_id=dict(), project_id=dict(),
timeout=dict(type='int', default=180)
) )
) )

Loading…
Cancel
Save