PEP 8 E111 cleanup. (#20841)

pull/18986/merge
Matt Clay 8 years ago committed by GitHub
parent 462ab6b1db
commit 23f2efbc8d

@ -257,7 +257,7 @@ class ElbManager:
are attached to self.instance_id""" are attached to self.instance_id"""
if not ec2_elbs: if not ec2_elbs:
ec2_elbs = self._get_auto_scaling_group_lbs() ec2_elbs = self._get_auto_scaling_group_lbs()
try: try:
elb = connect_to_aws(boto.ec2.elb, self.region, **self.aws_connect_params) elb = connect_to_aws(boto.ec2.elb, self.region, **self.aws_connect_params)
@ -293,24 +293,24 @@ class ElbManager:
indirectly through its auto scaling group membership""" indirectly through its auto scaling group membership"""
try: try:
asg = connect_to_aws(boto.ec2.autoscale, self.region, **self.aws_connect_params) asg = connect_to_aws(boto.ec2.autoscale, self.region, **self.aws_connect_params)
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e: except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
self.module.fail_json(msg=str(e)) self.module.fail_json(msg=str(e))
asg_instances = asg.get_all_autoscaling_instances([self.instance_id]) asg_instances = asg.get_all_autoscaling_instances([self.instance_id])
if len(asg_instances) > 1: if len(asg_instances) > 1:
self.module.fail_json(msg="Illegal state, expected one auto scaling group instance.") self.module.fail_json(msg="Illegal state, expected one auto scaling group instance.")
if not asg_instances: if not asg_instances:
asg_elbs = [] asg_elbs = []
else: else:
asg_name = asg_instances[0].group_name asg_name = asg_instances[0].group_name
asgs = asg.get_all_groups([asg_name]) asgs = asg.get_all_groups([asg_name])
if len(asg_instances) != 1: if len(asg_instances) != 1:
self.module.fail_json(msg="Illegal state, expected one auto scaling group.") self.module.fail_json(msg="Illegal state, expected one auto scaling group.")
asg_elbs = asgs[0].load_balancers asg_elbs = asgs[0].load_balancers
return asg_elbs return asg_elbs

@ -577,13 +577,13 @@ class ElbManager(object):
# instance state counts: InService or OutOfService # instance state counts: InService or OutOfService
if info['instance_health']: if info['instance_health']:
for instance_state in info['instance_health']: for instance_state in info['instance_health']:
if instance_state['state'] == "InService": if instance_state['state'] == "InService":
info['in_service_count'] += 1 info['in_service_count'] += 1
elif instance_state['state'] == "OutOfService": elif instance_state['state'] == "OutOfService":
info['out_of_service_count'] += 1 info['out_of_service_count'] += 1
else: else:
info['unknown_instance_state_count'] += 1 info['unknown_instance_state_count'] += 1
if check_elb.health_check: if check_elb.health_check:
info['health_check'] = { info['health_check'] = {
@ -940,7 +940,7 @@ class ElbManager(object):
attributes = self.elb.get_attributes() attributes = self.elb.get_attributes()
if self.access_logs: if self.access_logs:
if 's3_location' not in self.access_logs: if 's3_location' not in self.access_logs:
self.module.fail_json(msg='s3_location information required') self.module.fail_json(msg='s3_location information required')
access_logs_config = { access_logs_config = {
"enabled": True, "enabled": True,
@ -951,7 +951,7 @@ class ElbManager(object):
update_access_logs_config = False update_access_logs_config = False
for attr, desired_value in access_logs_config.items(): for attr, desired_value in access_logs_config.items():
if getattr(attributes.access_log, attr) != desired_value: if getattr(attributes.access_log, attr) != desired_value:
setattr(attributes.access_log, attr, desired_value) setattr(attributes.access_log, attr, desired_value)
update_access_logs_config = True update_access_logs_config = True
if update_access_logs_config: if update_access_logs_config:

@ -119,13 +119,13 @@ result:
''' '''
try: try:
import json import json
import time import time
import botocore import botocore
import boto3 import boto3
HAS_BOTO3 = True HAS_BOTO3 = True
except ImportError: except ImportError:
HAS_BOTO3 = False HAS_BOTO3 = False
def get_vgw_info(vgws): def get_vgw_info(vgws):
if not isinstance(vgws, list): if not isinstance(vgws, list):

@ -469,9 +469,9 @@ def main():
if command_in == 'create': if command_in == 'create':
if ( weight_in is not None or region_in is not None or failover_in is not None ) and identifier_in is None: if ( weight_in is not None or region_in is not None or failover_in is not None ) and identifier_in is None:
module.fail_json(msg= "If you specify failover, region or weight you must also specify identifier") module.fail_json(msg= "If you specify failover, region or weight you must also specify identifier")
elif ( weight_in is None and region_in is None and failover_in is None ) and identifier_in is not None: elif ( weight_in is None and region_in is None and failover_in is None ) and identifier_in is not None:
module.fail_json(msg= "You have specified identifier which makes sense only if you specify one of: weight, region or failover.") module.fail_json(msg= "You have specified identifier which makes sense only if you specify one of: weight, region or failover.")
@ -536,15 +536,15 @@ def main():
if hosted_zone_id_in: if hosted_zone_id_in:
record['hosted_zone_id'] = hosted_zone_id_in record['hosted_zone_id'] = hosted_zone_id_in
if rset.alias_dns_name: if rset.alias_dns_name:
record['alias'] = True record['alias'] = True
record['value'] = rset.alias_dns_name record['value'] = rset.alias_dns_name
record['values'] = [rset.alias_dns_name] record['values'] = [rset.alias_dns_name]
record['alias_hosted_zone_id'] = rset.alias_hosted_zone_id record['alias_hosted_zone_id'] = rset.alias_hosted_zone_id
record['alias_evaluate_target_health'] = rset.alias_evaluate_target_health record['alias_evaluate_target_health'] = rset.alias_evaluate_target_health
else: else:
record['alias'] = False record['alias'] = False
record['value'] = ','.join(sorted(rset.resource_records)) record['value'] = ','.join(sorted(rset.resource_records))
record['values'] = sorted(rset.resource_records) record['values'] = sorted(rset.resource_records)
if command_in == 'create' and rset.to_xml() == wanted_rset.to_xml(): if command_in == 'create' and rset.to_xml() == wanted_rset.to_xml():
module.exit_json(changed=False) module.exit_json(changed=False)
break break
@ -578,9 +578,9 @@ def main():
txt = e.body.split("<Message>")[1] txt = e.body.split("<Message>")[1]
txt = txt.split("</Message>")[0] txt = txt.split("</Message>")[0]
if "but it already exists" in txt: if "but it already exists" in txt:
module.exit_json(changed=False) module.exit_json(changed=False)
else: else:
module.fail_json(msg = txt) module.fail_json(msg = txt)
except TimeoutError: except TimeoutError:
module.fail_json(msg='Timeout waiting for changes to replicate') module.fail_json(msg='Timeout waiting for changes to replicate')

@ -306,12 +306,12 @@ def main():
# Default port # Default port
if port_in is None: if port_in is None:
if type_in in ['HTTP', 'HTTP_STR_MATCH']: if type_in in ['HTTP', 'HTTP_STR_MATCH']:
port_in = 80 port_in = 80
elif type_in in ['HTTPS', 'HTTPS_STR_MATCH']: elif type_in in ['HTTPS', 'HTTPS_STR_MATCH']:
port_in = 443 port_in = 443
else: else:
module.fail_json(msg="parameter 'port' is required for 'type' TCP") module.fail_json(msg="parameter 'port' is required for 'type' TCP")
# string_match in relation with type # string_match in relation with type
if type_in in ['HTTP_STR_MATCH', 'HTTPS_STR_MATCH']: if type_in in ['HTTP_STR_MATCH', 'HTTPS_STR_MATCH']:

@ -615,21 +615,21 @@ def main():
# Lets check key state. Does it exist and if it does, compute the etag md5sum. # Lets check key state. Does it exist and if it does, compute the etag md5sum.
if bucketrtn is True and keyrtn is True: if bucketrtn is True and keyrtn is True:
md5_remote = keysum(module, s3, bucket, obj) md5_remote = keysum(module, s3, bucket, obj)
md5_local = module.md5(src) md5_local = module.md5(src)
if md5_local == md5_remote: if md5_local == md5_remote:
sum_matches = True sum_matches = True
if overwrite == 'always': if overwrite == 'always':
upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, headers) upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, headers)
else:
get_download_url(module, s3, bucket, obj, expiry, changed=False)
else: else:
sum_matches = False get_download_url(module, s3, bucket, obj, expiry, changed=False)
if overwrite in ('always', 'different'): else:
upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, headers) sum_matches = False
else: if overwrite in ('always', 'different'):
module.exit_json(msg="WARNING: Checksums do not match. Use overwrite parameter to force upload.") upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, headers)
else:
module.exit_json(msg="WARNING: Checksums do not match. Use overwrite parameter to force upload.")
# If neither exist (based on bucket existence), we can create both. # If neither exist (based on bucket existence), we can create both.
if bucketrtn is False and pathrtn is True: if bucketrtn is False and pathrtn is True:

@ -61,7 +61,6 @@ lib/ansible/modules/cloud/amazon/ec2_vpc_net_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_route_table_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_subnet_facts.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py
lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py lib/ansible/modules/cloud/amazon/ec2_vpc_vgw_facts.py
lib/ansible/modules/cloud/amazon/ec2_win_password.py lib/ansible/modules/cloud/amazon/ec2_win_password.py
lib/ansible/modules/cloud/amazon/ecs_service.py lib/ansible/modules/cloud/amazon/ecs_service.py

Loading…
Cancel
Save