From 1453f7b013393678b8a616d7cfbda1b68b2c31db Mon Sep 17 00:00:00 2001 From: James Martin Date: Fri, 25 Jul 2014 10:56:25 -0400 Subject: [PATCH 1/2] Fixes #8290. --- library/cloud/ec2_eip | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/library/cloud/ec2_eip b/library/cloud/ec2_eip index e118210809..eaaf4330d9 100644 --- a/library/cloud/ec2_eip +++ b/library/cloud/ec2_eip @@ -138,11 +138,23 @@ def disassociate_ip_and_instance(ec2, address, instance_id, module): def find_address(ec2, public_ip, module): """ Find an existing Elastic IP address """ - try: - addresses = ec2.get_all_addresses([public_ip]) - except boto.exception.EC2ResponseError, e: - module.fail_json(msg=str(e.message)) - + wait_timeout = 600 + wait_timeout = time.time() + wait_timeout + + while wait_timeout > time.time(): + try: + addresses = ec2.get_all_addresses([public_ip]) + break + except boto.exception.EC2ResponseError, e: + if "Address '%s' not found." % public_ip in e.message : + pass + else: + module.fail_json(msg=str(e.message)) + time.sleep(5) + + if wait_timeout <= time.time(): + module.fail_json(msg = "wait for EIPs timeout on %s" % time.asctime()) + return addresses[0] From 1134f6169c17f49fb62b04083a9d4808fb033824 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 25 Jul 2014 12:41:25 -0500 Subject: [PATCH 2/2] Minor indentation fixes on ec2_eip --- library/cloud/ec2_eip | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/cloud/ec2_eip b/library/cloud/ec2_eip index eaaf4330d9..92e249b66c 100644 --- a/library/cloud/ec2_eip +++ b/library/cloud/ec2_eip @@ -143,13 +143,13 @@ def find_address(ec2, public_ip, module): while wait_timeout > time.time(): try: - addresses = ec2.get_all_addresses([public_ip]) - break + addresses = ec2.get_all_addresses([public_ip]) + break except boto.exception.EC2ResponseError, e: - if "Address '%s' not found." % public_ip in e.message : - pass - else: - module.fail_json(msg=str(e.message)) + if "Address '%s' not found." % public_ip in e.message : + pass + else: + module.fail_json(msg=str(e.message)) time.sleep(5) if wait_timeout <= time.time():