mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
PEP 8 E111 & E114 cleanup. (#20838)
This commit is contained in:
@@ -184,9 +184,9 @@ def do_grant(kms, keyarn, role_arn, granttypes, mode='grant', dry_run=True, clea
|
||||
if not dry_run:
|
||||
statement['Principal']['AWS'].append(role_arn)
|
||||
elif role_arn in statement['Principal']['AWS']: # not one the places the role should be
|
||||
changes_needed[granttype] = 'remove'
|
||||
if not dry_run:
|
||||
statement['Principal']['AWS'].remove(role_arn)
|
||||
changes_needed[granttype] = 'remove'
|
||||
if not dry_run:
|
||||
statement['Principal']['AWS'].remove(role_arn)
|
||||
|
||||
elif mode == 'deny' and statement['Sid'] == statement_label[granttype] and role_arn in statement['Principal']['AWS']:
|
||||
# we don't selectively deny. that's a grant with a
|
||||
|
||||
@@ -222,7 +222,7 @@ class CloudFormationServiceManager:
|
||||
result = response.get(result_key)
|
||||
next_token = response.get('NextToken')
|
||||
if not next_token:
|
||||
return result
|
||||
return result
|
||||
return result + self.paginated_response(func, result_key, next_token)
|
||||
|
||||
def to_dict(items, key, value):
|
||||
@@ -246,7 +246,7 @@ def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
# Describe the stack
|
||||
service_mgr = CloudFormationServiceManager(module)
|
||||
|
||||
@@ -388,7 +388,7 @@ def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
service_mgr = CloudFrontServiceManager(module)
|
||||
|
||||
|
||||
@@ -139,13 +139,13 @@ class CloudTrailManager:
|
||||
ret = self.conn.describe_trails(trail_name_list=[name])
|
||||
trailList = ret.get('trailList', [])
|
||||
if len(trailList) == 1:
|
||||
return trailList[0]
|
||||
return trailList[0]
|
||||
return None
|
||||
|
||||
def exists(self, name=None):
|
||||
ret = self.view(name)
|
||||
if ret:
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def enable_logging(self, name):
|
||||
@@ -180,7 +180,7 @@ def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_together=required_together)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
ec2_url, access_key, secret_key, region = get_ec2_creds(module)
|
||||
aws_connect_params = dict(aws_access_key_id=access_key,
|
||||
|
||||
@@ -344,7 +344,7 @@ def validate_index(index, module):
|
||||
module.fail_json(msg='%s is not a valid option for an index' % key)
|
||||
for required_option in INDEX_REQUIRED_OPTIONS:
|
||||
if required_option not in index:
|
||||
module.fail_json(msg='%s is a required option for an index' % required_option)
|
||||
module.fail_json(msg='%s is a required option for an index' % required_option)
|
||||
if index['type'] not in INDEX_TYPE_OPTIONS:
|
||||
module.fail_json(msg='%s is not a valid index type, must be one of %s' % (index['type'], INDEX_TYPE_OPTIONS))
|
||||
|
||||
|
||||
@@ -1033,7 +1033,7 @@ def create_instances(module, ec2, vpc, override_count=None):
|
||||
grp_details = ec2.get_all_security_groups(group_ids=group_id)
|
||||
group_name = [grp_item.name for grp_item in grp_details]
|
||||
except boto.exception.NoAuthHandlerFound as e:
|
||||
module.fail_json(msg = str(e))
|
||||
module.fail_json(msg = str(e))
|
||||
|
||||
# Lookup any instances that much our run id.
|
||||
|
||||
@@ -1065,11 +1065,11 @@ def create_instances(module, ec2, vpc, override_count=None):
|
||||
'user_data': user_data}
|
||||
|
||||
if ebs_optimized:
|
||||
params['ebs_optimized'] = ebs_optimized
|
||||
params['ebs_optimized'] = ebs_optimized
|
||||
|
||||
# 'tenancy' always has a default value, but it is not a valid parameter for spot instance request
|
||||
if not spot_price:
|
||||
params['tenancy'] = tenancy
|
||||
params['tenancy'] = tenancy
|
||||
|
||||
if boto_supports_profile_name_arg(ec2):
|
||||
params['instance_profile_name'] = instance_profile_name
|
||||
@@ -1184,8 +1184,8 @@ def create_instances(module, ec2, vpc, override_count=None):
|
||||
if boto_supports_param_in_spot_request(ec2, 'placement_group'):
|
||||
params['placement_group'] = placement_group
|
||||
elif placement_group :
|
||||
module.fail_json(
|
||||
msg="placement_group parameter requires Boto version 2.3.0 or higher.")
|
||||
module.fail_json(
|
||||
msg="placement_group parameter requires Boto version 2.3.0 or higher.")
|
||||
|
||||
# You can't tell spot instances to 'stop'; they will always be
|
||||
# 'terminate'd. For convenience, we'll ignore the latter value.
|
||||
|
||||
@@ -178,7 +178,7 @@ def list_launch_configs(connection, module):
|
||||
launch_config['CreatedTime'] = str(launch_config['CreatedTime'])
|
||||
|
||||
if sort:
|
||||
snaked_launch_configs.sort(key=lambda e: e[sort], reverse=(sort_order=='descending'))
|
||||
snaked_launch_configs.sort(key=lambda e: e[sort], reverse=(sort_order=='descending'))
|
||||
|
||||
try:
|
||||
if sort and sort_start and sort_end:
|
||||
|
||||
@@ -176,12 +176,12 @@ def main():
|
||||
module.fail_json(msg="tags argument is required when state is absent")
|
||||
for (key, value) in set(tags.items()):
|
||||
if (key, value) not in set(tagdict.items()):
|
||||
baddict[key] = value
|
||||
if set(baddict) == set(tags):
|
||||
module.exit_json(msg="Nothing to remove here. Move along.", changed=False)
|
||||
baddict[key] = value
|
||||
if set(baddict) == set(tags):
|
||||
module.exit_json(msg="Nothing to remove here. Move along.", changed=False)
|
||||
for (key, value) in set(tags.items()):
|
||||
if (key, value) in set(tagdict.items()):
|
||||
dictremove[key] = value
|
||||
dictremove[key] = value
|
||||
tagger = ec2.delete_tags(resource, dictremove)
|
||||
gettags = ec2.get_all_tags(filters=filters)
|
||||
module.exit_json(msg="Tags %s removed for resource %s." % (dictremove,resource), changed=True)
|
||||
|
||||
@@ -333,7 +333,7 @@ def main():
|
||||
supplied_options = connection.get_all_dhcp_options(filters={'dhcp-options-id':params['dhcp_options_id']})
|
||||
if len(supplied_options) != 1:
|
||||
if params['state'] != 'absent':
|
||||
module.fail_json(msg=" a dhcp_options_id was supplied, but does not exist")
|
||||
module.fail_json(msg=" a dhcp_options_id was supplied, but does not exist")
|
||||
else:
|
||||
found = True
|
||||
dhcp_option = supplied_options[0]
|
||||
|
||||
@@ -131,7 +131,7 @@ def list_dhcp_options(client, module):
|
||||
|
||||
snaked_dhcp_options_array = []
|
||||
for dhcp_option in all_dhcp_options_array:
|
||||
snaked_dhcp_options_array.append(camel_dict_to_snake_dict(dhcp_option))
|
||||
snaked_dhcp_options_array.append(camel_dict_to_snake_dict(dhcp_option))
|
||||
|
||||
module.exit_json(dhcp_options=snaked_dhcp_options_array)
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ def get_nat_gateways(client, subnet_id=None, nat_gateway_id=None,
|
||||
err_msg = '{0} Retrieving gateways'.format(DRY_RUN_MSGS)
|
||||
|
||||
except botocore.exceptions.ClientError as e:
|
||||
err_msg = str(e)
|
||||
err_msg = str(e)
|
||||
|
||||
return gateways_retrieved, err_msg, existing_gateways
|
||||
|
||||
@@ -592,7 +592,7 @@ def get_eip_allocation_id_by_address(client, eip_address, check_mode=False):
|
||||
)
|
||||
|
||||
except botocore.exceptions.ClientError as e:
|
||||
err_msg = str(e)
|
||||
err_msg = str(e)
|
||||
|
||||
return allocation_id, err_msg
|
||||
|
||||
|
||||
@@ -353,10 +353,10 @@ def main():
|
||||
)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
service_mgr = EcsServiceManager(module)
|
||||
|
||||
|
||||
@@ -217,10 +217,10 @@ def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
show_details = module.params.get('details', False)
|
||||
|
||||
|
||||
@@ -248,10 +248,10 @@ def main():
|
||||
|
||||
# Validate Requirements
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
# Validate Inputs
|
||||
if module.params['operation'] == 'run':
|
||||
|
||||
@@ -224,10 +224,10 @@ def main():
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
if not HAS_BOTO:
|
||||
module.fail_json(msg='boto is required.')
|
||||
module.fail_json(msg='boto is required.')
|
||||
|
||||
if not HAS_BOTO3:
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
module.fail_json(msg='boto3 is required.')
|
||||
|
||||
task_to_describe = None
|
||||
task_mgr = EcsTaskManager(module)
|
||||
|
||||
@@ -314,7 +314,7 @@ def main():
|
||||
# If VPC configuration is desired
|
||||
if vpc_subnet_ids or vpc_security_group_ids:
|
||||
if len(vpc_subnet_ids) < 1:
|
||||
module.fail_json(msg='At least 1 subnet is required')
|
||||
module.fail_json(msg='At least 1 subnet is required')
|
||||
|
||||
if len(vpc_security_group_ids) < 1:
|
||||
module.fail_json(msg='At least 1 security group is required')
|
||||
|
||||
@@ -352,7 +352,7 @@ class RDSConnection:
|
||||
try:
|
||||
self.connection = connect_to_aws(boto.rds, region, **aws_connect_params)
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg=e.error_message)
|
||||
module.fail_json(msg=e.error_message)
|
||||
|
||||
def get_db_instance(self, instancename):
|
||||
try:
|
||||
@@ -438,7 +438,7 @@ class RDS2Connection:
|
||||
try:
|
||||
self.connection = connect_to_aws(boto.rds2, region, **aws_connect_params)
|
||||
except boto.exception.BotoServerError as e:
|
||||
module.fail_json(msg=e.error_message)
|
||||
module.fail_json(msg=e.error_message)
|
||||
|
||||
def get_db_instance(self, instancename):
|
||||
try:
|
||||
|
||||
@@ -282,8 +282,8 @@ def gather_files(fileroot, include=None, exclude=None):
|
||||
if include:
|
||||
found = False
|
||||
for x in include.split(','):
|
||||
if fnmatch.fnmatch(fn, x):
|
||||
found = True
|
||||
if fnmatch.fnmatch(fn, x):
|
||||
found = True
|
||||
if not found:
|
||||
# not on the include list, so we don't want it.
|
||||
continue
|
||||
@@ -376,7 +376,7 @@ def filter_list(s3, bucket, s3filelist, strategy):
|
||||
keeplist = list(s3filelist)
|
||||
|
||||
for e in keeplist:
|
||||
e['_strategy'] = strategy
|
||||
e['_strategy'] = strategy
|
||||
|
||||
# init/fetch info from S3 if we're going to use it for comparisons
|
||||
if not strategy == 'force':
|
||||
|
||||
@@ -319,10 +319,10 @@ class SnsTopicManager(object):
|
||||
def ensure_gone(self):
|
||||
self.arn_topic = self._arn_topic_lookup()
|
||||
if self.arn_topic:
|
||||
self._get_topic_subs()
|
||||
if self.subscriptions_existing:
|
||||
self._delete_subscriptions()
|
||||
self._delete_topic()
|
||||
self._get_topic_subs()
|
||||
if self.subscriptions_existing:
|
||||
self._delete_subscriptions()
|
||||
self._delete_topic()
|
||||
|
||||
|
||||
def get_info(self):
|
||||
|
||||
Reference in New Issue
Block a user