From 19511971eefc12ccb23c56a17e7930eed3b65409 Mon Sep 17 00:00:00 2001 From: Ryan Brown Date: Mon, 13 Mar 2017 15:45:18 -0400 Subject: [PATCH] Format ELBInfo call (#22383) Move declaration of AWSRetry of get_all_load_balancers so it isn't redeclared for every page of data. --- lib/ansible/modules/cloud/amazon/ec2_elb_facts.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py index 71688fb3392..f54933d67b4 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_elb_facts.py @@ -210,9 +210,9 @@ class ElbInformation(object): def list_elbs(self): elb_array, token = [], None - + get_elb_with_backoff = AWSRetry.backoff(tries=5, delay=5, backoff=2.0)(self.connection.get_all_load_balancers) while True: - all_elbs = AWSRetry.backoff(tries=5, delay=5, backoff=2.0)(self.connection.get_all_load_balancers)(marker=token) + all_elbs = get_elb_with_backoff(marker=token) token = all_elbs.next_token if all_elbs: @@ -244,17 +244,13 @@ def main(): module.fail_json(msg='boto required for this module') try: - region, ec2_url, aws_connect_params = get_aws_connection_info(module) - if not region: module.fail_json(msg="region must be specified") names = module.params['names'] - elb_information = ElbInformation(module, - names, - region, - **aws_connect_params) + elb_information = ElbInformation( + module, names, region, **aws_connect_params) ec2_facts_result = dict(changed=False, elbs=elb_information.list_elbs())