From dbb0bcd9e436b5228b7d45665a16f498bf6ca53a 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 --- cloud/google/gce_img.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cloud/google/gce_img.py b/cloud/google/gce_img.py index a4a55c16dec..8e03ee75a90 100644 --- a/cloud/google/gce_img.py +++ b/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) ) )