Skip to content

Commit

Permalink
ec2_elb_lb: fixed latest Ansible standards compliance
Browse files Browse the repository at this point in the history
Update to current pep8 standards, fix module imports
and remove module from exclusion file
  • Loading branch information
Will Thames committed Mar 8, 2017
1 parent 8c55e1b commit c482368
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/ansible/modules/cloud/amazon/ec2_elb_lb.py
Expand Up @@ -397,14 +397,17 @@
import boto.vpc
from boto.ec2.elb.healthcheck import HealthCheck
from boto.ec2.tag import Tag
from boto.regioninfo import RegionInfo
HAS_BOTO = True
except ImportError:
HAS_BOTO = False

import time
import random

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import ec2_argument_spec, connect_to_aws, AnsibleAWSError
from ansible.module_utils.ec2 import get_aws_connection_info

def _throttleable_operation(max_retries):
def _operation_wrapper(op):
def _do_op(*args, **kwargs):
Expand Down Expand Up @@ -633,7 +636,7 @@ def _wait_for_elb_removed(self):

for x in range(0, max_retries):
try:
result = self.elb_conn.get_all_lb_attributes(self.name)
self.elb_conn.get_all_lb_attributes(self.name)
except (boto.exception.BotoServerError, StandardError) as e:
if "LoadBalancerNotFound" in e.code:
status_achieved = True
Expand Down Expand Up @@ -1033,7 +1036,7 @@ def select_stickiness_policy(self):
policy = []
policy_type = 'LBCookieStickinessPolicyType'

if self.module.boolean(self.stickiness['enabled']) is True:
if self.module.boolean(self.stickiness['enabled']):

if 'expiration' not in self.stickiness:
self.module.fail_json(msg='expiration must be set when type is loadbalancer')
Expand All @@ -1050,7 +1053,7 @@ def select_stickiness_policy(self):
policy.append(self._policy_name(policy_attrs['type']))

self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs)
elif self.module.boolean(self.stickiness['enabled']) is False:
elif not self.module.boolean(self.stickiness['enabled']):
if len(elb_info.policies.lb_cookie_stickiness_policies):
if elb_info.policies.lb_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type):
self.changed = True
Expand All @@ -1062,7 +1065,7 @@ def select_stickiness_policy(self):
elif self.stickiness['type'] == 'application':
policy = []
policy_type = 'AppCookieStickinessPolicyType'
if self.module.boolean(self.stickiness['enabled']) is True:
if self.module.boolean(self.stickiness['enabled']):

if 'cookie' not in self.stickiness:
self.module.fail_json(msg='cookie must be set when type is application')
Expand All @@ -1076,7 +1079,7 @@ def select_stickiness_policy(self):
}
policy.append(self._policy_name(policy_attrs['type']))
self._set_stickiness_policy(elb_info, listeners_dict, policy, **policy_attrs)
elif self.module.boolean(self.stickiness['enabled']) is False:
elif not self.module.boolean(self.stickiness['enabled']):
if len(elb_info.policies.app_cookie_stickiness_policies):
if elb_info.policies.app_cookie_stickiness_policies[0].policy_name == self._policy_name(policy_type):
self.changed = True
Expand Down Expand Up @@ -1299,7 +1302,7 @@ def main():
if security_group_names:
security_group_ids = []
try:
ec2 = ec2_connect(module)
ec2 = connect_to_aws(boto.ec2, region, **aws_connect_params)
if subnets: # We have at least one subnet, ergo this is a VPC
vpc_conn = _get_vpc_connection(module=module, region=region, aws_connect_params=aws_connect_params)
vpc_id = vpc_conn.get_all_subnets([subnets[0]])[0].vpc_id
Expand Down Expand Up @@ -1350,9 +1353,6 @@ def main():

module.exit_json(**ec2_facts_result)

# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *

if __name__ == '__main__':
main()

0 comments on commit c482368

Please sign in to comment.