From 04efe69c34608859708e2d25e42cdca7baefd71d Mon Sep 17 00:00:00 2001 From: daniel-sc Date: Sun, 11 Oct 2015 17:18:38 +0200 Subject: [PATCH] configurable timeout for creating gce image --- lib/ansible/modules/extras/cloud/google/gce_img.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ansible/modules/extras/cloud/google/gce_img.py b/lib/ansible/modules/extras/cloud/google/gce_img.py index a4a55c16de..8e03ee75a9 100644 --- a/lib/ansible/modules/extras/cloud/google/gce_img.py +++ b/lib/ansible/modules/extras/cloud/google/gce_img.py @@ -59,6 +59,12 @@ options: required: false default: "us-central1-a" aliases: [] + timeout: + description: + - timeout for the operation + required: false + default: 180 + aliases: [] service_account_email: description: - service account email @@ -130,6 +136,7 @@ def create_image(gce, name, module): source = module.params.get('source') zone = module.params.get('zone') desc = module.params.get('description') + timeout = module.params.get('timeout') if not source: module.fail_json(msg='Must supply a source', changed=False) @@ -149,13 +156,17 @@ def create_image(gce, name, module): except GoogleBaseError, e: module.fail_json(msg=str(e), changed=False) + old_timeout = gce.connection.timeout try: + gce.connection.timeout = timeout gce.ex_create_image(name, volume, desc, False) return True except ResourceExistsError: return False except GoogleBaseError, e: module.fail_json(msg=str(e), changed=False) + finally: + gce.connection.timeout = old_timeout def delete_image(gce, name, module): @@ -180,6 +191,7 @@ def main(): service_account_email=dict(), pem_file=dict(), project_id=dict(), + timeout=dict(type='int', default=180) ) )