1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix pycodestyle E117 issues.

This commit is contained in:
Matt Clay 2019-02-13 18:39:26 -08:00
parent 7b8e814a10
commit 3e778d3f8f
40 changed files with 150 additions and 150 deletions

View file

@ -354,13 +354,13 @@ class AzureRM(object):
self.credentials.get('client_id') is not None and \
self.credentials.get('tenant') is not None:
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None:
tenant = self.credentials.get('tenant')
@ -813,7 +813,7 @@ class AzureInventory(object):
sys.exit("Error: fetching instanceview for host {0} - {1}".format(name, str(exc)))
return next((s.code.replace('PowerState/', '')
for s in vm.instance_view.statuses if s.code.startswith('PowerState')), None)
for s in vm.instance_view.statuses if s.code.startswith('PowerState')), None)
def _add_host(self, vars):

View file

@ -262,13 +262,13 @@ class AzureRM(object):
self.credentials.get('client_id') is not None and \
self.credentials.get('tenant') is not None:
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None:
tenant = self.credentials.get('tenant')

View file

@ -162,9 +162,9 @@ class TaskQueueManager:
try:
callback_obj.set_options()
except AttributeError:
display.deprecated("%s callback, does not support setting 'options', it will work for now, "
" but this will be required in the future and should be updated, "
" see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9")
display.deprecated("%s callback, does not support setting 'options', it will work for now, "
" but this will be required in the future and should be updated, "
" see the 2.4 porting guide for details." % callback_obj._load_name, version="2.9")
self._callback_plugins.append(callback_obj)
self._callbacks_loaded = True

View file

@ -1026,24 +1026,24 @@ class AzureRMAuth(object):
elif self.credentials.get('client_id') is not None and \
self.credentials.get('secret') is not None and \
self.credentials.get('tenant') is not None:
self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'],
secret=self.credentials['secret'],
tenant=self.credentials['tenant'],
cloud_environment=self._cloud_environment,
verify=self._cert_validation_mode == 'validate')
self.azure_credentials = ServicePrincipalCredentials(client_id=self.credentials['client_id'],
secret=self.credentials['secret'],
tenant=self.credentials['tenant'],
cloud_environment=self._cloud_environment,
verify=self._cert_validation_mode == 'validate')
elif self.credentials.get('ad_user') is not None and \
self.credentials.get('password') is not None and \
self.credentials.get('client_id') is not None and \
self.credentials.get('tenant') is not None:
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
self.azure_credentials = self.acquire_token_with_username_password(
self._adfs_authority_url,
self._resource,
self.credentials['ad_user'],
self.credentials['password'],
self.credentials['client_id'],
self.credentials['tenant'])
elif self.credentials.get('ad_user') is not None and self.credentials.get('password') is not None:
tenant = self.credentials.get('tenant')

View file

@ -117,7 +117,7 @@ def dict_merge(a, b):
result = deepcopy(a)
for k, v in b.items():
if k in result and isinstance(result[k], dict):
result[k] = dict_merge(result[k], v)
result[k] = dict_merge(result[k], v)
else:
result[k] = deepcopy(v)
return result

View file

@ -448,14 +448,14 @@ class LinuxHardware(Hardware):
def get_mount_info(self, mount, device, uuids):
mount_size = get_mount_size(mount)
mount_size = get_mount_size(mount)
# _udevadm_uuid is a fallback for versions of lsblk <= 2.23 that don't have --paths
# see _run_lsblk() above
# https://github.com/ansible/ansible/issues/36077
uuid = uuids.get(device, self._udevadm_uuid(device))
# _udevadm_uuid is a fallback for versions of lsblk <= 2.23 that don't have --paths
# see _run_lsblk() above
# https://github.com/ansible/ansible/issues/36077
uuid = uuids.get(device, self._udevadm_uuid(device))
return mount_size, uuid
return mount_size, uuid
def get_mount_facts(self):

View file

@ -356,7 +356,7 @@ class MSOModule(object):
if not t:
self.module.fail_json(msg="Tenant '%s' is not valid tenant name." % tenant)
if 'id' not in t:
self.module.fail_json(msg="Tenant lookup failed for tenant '%s': %s" % (tenant, t))
self.module.fail_json(msg="Tenant lookup failed for tenant '%s': %s" % (tenant, t))
return t['id']
def lookup_users(self, users):

View file

@ -315,7 +315,7 @@ def create_scalable_target(connection, module):
ScalableDimension=module.params.get('scalable_dimension')
)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe scalable targets")
module.fail_json_aws(e, msg="Failed to describe scalable targets")
# Scalable target registration will occur if:
# 1. There is no scalable target registered for this service

View file

@ -1411,7 +1411,7 @@ class CloudFrontValidationManager(object):
Comment=comment))
oai = client.create_cloud_front_origin_access_identity(**cfoai_config)['CloudFrontOriginAccessIdentity']['Id']
except Exception as e:
self.module.fail_json_aws(e, msg="Couldn't create Origin Access Identity for id %s" % origin['id'])
self.module.fail_json_aws(e, msg="Couldn't create Origin Access Identity for id %s" % origin['id'])
return "origin-access-identity/cloudfront/%s" % oai
def validate_origin(self, client, existing_config, origin, default_origin_path):

View file

@ -147,7 +147,7 @@ class CloudFrontOriginAccessIdentityServiceManager(object):
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(self.module, boto3=True)
self.client = boto3_conn(self.module, conn_type='client', resource=resource, region=region, endpoint=ec2_url, **aws_connect_kwargs)
except (ClientError, BotoCoreError) as e:
self.module.fail_json_aws(e, msg="Unable to establish connection.")
self.module.fail_json_aws(e, msg="Unable to establish connection.")
def create_origin_access_identity(self, caller_reference, comment):
try:

View file

@ -242,14 +242,14 @@ def main():
if state == 'present':
if found_log_group and module.params['overwrite'] is True:
changed = True
delete_log_group(client=logs, log_group_name=module.params['log_group_name'], module=module)
found_log_group = create_log_group(client=logs,
log_group_name=module.params['log_group_name'],
kms_key_id=module.params['kms_key_id'],
tags=module.params['tags'],
retention=module.params['retention'],
module=module)
changed = True
delete_log_group(client=logs, log_group_name=module.params['log_group_name'], module=module)
found_log_group = create_log_group(client=logs,
log_group_name=module.params['log_group_name'],
kms_key_id=module.params['kms_key_id'],
tags=module.params['tags'],
retention=module.params['retention'],
module=module)
elif not found_log_group:
changed = True
found_log_group = create_log_group(client=logs,

View file

@ -783,7 +783,7 @@ class AzureRMWebApps(AzureRMModuleBase):
if self.site_config.get(fx_version):
if not getattr(existing_config, fx_version) or \
getattr(existing_config, fx_version).upper() != self.site_config.get(fx_version).upper():
return True
return True
return False

View file

@ -671,7 +671,7 @@ class AzureRMWebAppSlots(AzureRMModuleBase):
if self.site_config.get(fx_version):
if not getattr(existing_config, fx_version) or \
getattr(existing_config, fx_version).upper() != self.site_config.get(fx_version).upper():
return True
return True
if self.auto_swap_slot_name is False and existing_config.auto_swap_slot_name is not None:
return True

View file

@ -263,7 +263,7 @@ class VmBootManager(PyVmomi):
if self.params.get('secure_boot_enabled') and \
self.params.get('boot_firmware') is None and \
self.vm.config.firmware == 'bios':
self.module.fail_json(msg="EFI secure boot cannot be enabled when boot_firmware = bios. VM's boot_firmware currently set to bios")
self.module.fail_json(msg="EFI secure boot cannot be enabled when boot_firmware = bios. VM's boot_firmware currently set to bios")
kwargs.update({'efiSecureBootEnabled': self.params.get('secure_boot_enabled')})
change_needed = True

View file

@ -100,7 +100,7 @@ class AnsibleVultrOSFacts(Vultr):
def parse_oses_list(oses_list):
return [os for id, os in oses_list.items()]
return [os for id, os in oses_list.items()]
def main():

View file

@ -190,7 +190,7 @@ def shard_find(client, shard):
else:
s = shard
for shard in client["config"].shards.find({"_id": s}):
return shard
return shard
return False

View file

@ -349,9 +349,9 @@ def main():
msg='psycopg2 must be at least 2.4.3 in order to user the ssl_rootcert parameter')
if module.check_mode and concurrent:
module.fail_json(msg="Cannot concurrently create or drop index %s "
"inside the transaction block. The check is possible "
"in not concurrent mode only" % idxname)
module.fail_json(msg="Cannot concurrently create or drop index %s "
"inside the transaction block. The check is possible "
"in not concurrent mode only" % idxname)
try:
db_connection = psycopg2.connect(**kw)

View file

@ -101,7 +101,7 @@ class Namespace(object):
changed = False
if self.state == 'present' and self.exists():
changed = True
changed = True
elif self.state == 'absent' and self.exists():
changed = True

View file

@ -319,14 +319,14 @@ def main():
if module.params['save']:
result['changed'] = True
if not module.check_mode:
cmd = {'command': 'copy running-config startup-config',
'prompt': r'\(y/n\)\s?$', 'answer': 'y'}
run_commands(module, [cmd])
result['saved'] = True
cmd = {'command': 'copy running-config startup-config',
'prompt': r'\(y/n\)\s?$', 'answer': 'y'}
run_commands(module, [cmd])
result['saved'] = True
else:
module.warn('Skipping command `copy running-config startup-config`'
'due to check_mode. Configuration not copied to '
'non-volatile storage')
module.warn('Skipping command `copy running-config startup-config`'
'due to check_mode. Configuration not copied to '
'non-volatile storage')
module.exit_json(**result)

View file

@ -144,7 +144,7 @@ def parse_key_id(line, dest):
def parse_auth(dest):
if dest == 'authenticate':
return dest
return dest
def map_config_to_obj(module):

View file

@ -332,40 +332,40 @@ def map_obj_to_commands(updates, module):
add_command_to_vrf(want['name'], cmd, commands)
if needs_update(want, have, 'route_import_ipv4'):
cmd = 'address-family ipv4'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_import_ipv4']:
cmd = 'route-target import %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
cmd = 'address-family ipv4'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_import_ipv4']:
cmd = 'route-target import %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
add_command_to_vrf(want['name'], cmd, commands)
if needs_update(want, have, 'route_export_ipv4'):
cmd = 'address-family ipv4'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_export_ipv4']:
cmd = 'route-target export %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
cmd = 'address-family ipv4'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_export_ipv4']:
cmd = 'route-target export %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
add_command_to_vrf(want['name'], cmd, commands)
if needs_update(want, have, 'route_import_ipv6'):
cmd = 'address-family ipv6'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_import_ipv6']:
cmd = 'route-target import %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
cmd = 'address-family ipv6'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_import_ipv6']:
cmd = 'route-target import %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
add_command_to_vrf(want['name'], cmd, commands)
if needs_update(want, have, 'route_export_ipv6'):
cmd = 'address-family ipv6'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_export_ipv6']:
cmd = 'route-target export %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
cmd = 'address-family ipv6'
add_command_to_vrf(want['name'], cmd, commands)
for route in want['route_export_ipv6']:
cmd = 'route-target export %s' % route
add_command_to_vrf(want['name'], cmd, commands)
cmd = 'exit-address-family'
add_command_to_vrf(want['name'], cmd, commands)
if want['interfaces'] is not None:
# handle the deletes

View file

@ -209,7 +209,7 @@ def get_admin_id(meraki, data, name=None, email=None):
admin_id = a['id']
elif meraki.params['email']:
if meraki.params['email'] == a['email']:
return a['id']
return a['id']
if admin_id is None:
meraki.fail_json(msg='No admin_id found')
return admin_id

View file

@ -144,11 +144,11 @@ def assemble_payload(meraki):
def get_rules(meraki, net_id, number):
path = meraki.construct_path('get_all', net_id=net_id)
path = path + number + '/l3FirewallRules'
response = meraki.request(path, method='GET')
if meraki.status == 200:
return response
path = meraki.construct_path('get_all', net_id=net_id)
path = path + number + '/l3FirewallRules'
response = meraki.request(path, method='GET')
if meraki.status == 200:
return response
def get_ssid_number(name, data):

View file

@ -211,10 +211,10 @@ def assemble_payload(meraki):
def get_rules(meraki, net_id):
path = meraki.construct_path('get_all', net_id=net_id)
response = meraki.request(path, method='GET')
if meraki.status == 200:
return response
path = meraki.construct_path('get_all', net_id=net_id)
response = meraki.request(path, method='GET')
if meraki.status == 200:
return response
def main():

View file

@ -181,7 +181,7 @@ def set_snmp(meraki, org_id):
meraki.params['v3_auth_pass'] is None or
meraki.params['v3_priv_mode'] is None or
meraki.params['v3_priv_pass'] is None):
meraki.fail_json(msg='v3_auth_mode, v3_auth_pass, v3_priv_mode, and v3_auth_pass are required')
meraki.fail_json(msg='v3_auth_mode, v3_auth_pass, v3_priv_mode, and v3_auth_pass are required')
payload = {'v3Enabled': meraki.params['v3_enabled'],
'v3AuthMode': meraki.params['v3_auth_mode'].upper(),
'v3AuthPass': meraki.params['v3_auth_pass'],

View file

@ -168,7 +168,7 @@ def main():
cli += ' %s community-string %s ' % (command, comm_str)
if command != 'snmp-community-delete' and community_type:
cli += ' community-type ' + community_type
cli += ' community-type ' + community_type
run_cli(module, cli, state_map)

View file

@ -272,13 +272,13 @@ def main():
commands, parents = state_absent(module, existing, proposed)
if commands:
candidate = CustomNetworkConfig(indent=3)
candidate.add(commands, parents=parents)
candidate = candidate.items_text()
if not module.check_mode:
load_config(module, candidate)
results['changed'] = True
results['commands'] = candidate
candidate = CustomNetworkConfig(indent=3)
candidate.add(commands, parents=parents)
candidate = candidate.items_text()
if not module.check_mode:
load_config(module, candidate)
results['changed'] = True
results['commands'] = candidate
else:
results['commands'] = []
module.exit_json(**results)

View file

@ -383,15 +383,15 @@ def config_igmp_interface(delta, existing, existing_oif_prefix_source):
commands.append(CMDS.get('oif_prefix').format(pf))
if existing_oif_prefix_source:
for each in existing_oif_prefix_source:
# remove stale prefix/sources
pf = each['prefix']
src = ''
if 'source' in each.keys():
src = each['source']
if src:
commands.append('no ' + CMDS.get('oif_prefix_source').format(pf, src))
else:
commands.append('no ' + CMDS.get('oif_prefix').format(pf))
# remove stale prefix/sources
pf = each['prefix']
src = ''
if 'source' in each.keys():
src = each['source']
if src:
commands.append('no ' + CMDS.get('oif_prefix_source').format(pf, src))
else:
commands.append('no ' + CMDS.get('oif_prefix').format(pf))
elif key == 'oif_routemap':
if value == 'default':
if existing.get(key):

View file

@ -196,7 +196,7 @@ def run(module, result):
result['updates'] = total_commands
if module.params['save']:
total_commands.append('configuration write')
total_commands.append('configuration write')
if total_commands:
result['changed'] = True
if not module.check_mode:

View file

@ -170,7 +170,7 @@ def map_config_to_obj(module):
obj['key'] = module.params['key']
obj['value'] = col_value_to_dict[module.params['key']]
else:
obj['value'] = str(col_value.strip())
obj['value'] = str(col_value.strip())
return obj

View file

@ -291,7 +291,7 @@ def main():
try:
smtp.ehlo()
except smtplib.SMTPException as e:
module.fail_json(rc=1, msg='Helo failed for host %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc())
module.fail_json(rc=1, msg='Helo failed for host %s:%s: %s' % (host, port, to_native(e)), exception=traceback.format_exc())
if int(code) > 0:
if not secure_state and secure in ('starttls', 'try'):

View file

@ -837,7 +837,7 @@ class DnfModule(YumDnf):
if self.allow_downgrade:
self.base.package_install(pkg)
else:
self.base.package_install(pkg)
self.base.package_install(pkg)
except Exception as e:
self.module.fail_json(
msg="Error occured attempting remote rpm operation: {0}".format(to_native(e)),

View file

@ -159,11 +159,11 @@ def run_module():
'{1} '.format(alu, to_native(e)),
**result)
else:
module.fail_json(msg='No such storage group named '
'{0}'.format(module.params['name']),
**result)
module.fail_json(msg='No such storage group named '
'{0}'.format(module.params['name']),
**result)
except VNXCredentialError as e:
module.fail_json(msg='{0}'.format(to_native(e)), **result)
module.fail_json(msg='{0}'.format(to_native(e)), **result)
module.exit_json(**result)

View file

@ -490,15 +490,15 @@ class ElementSWSnapShotSchedule(object):
if schedule_detail.frequency.days != temp_frequency.days or \
schedule_detail.frequency.hours != temp_frequency.hours or \
schedule_detail.frequency.minutes != temp_frequency.minutes:
update_schedule = True
changed = True
update_schedule = True
changed = True
elif self.schedule_type == "DaysOfMonthFrequency":
# Check if there is any change in schedule.frequency, If schedule_type is days_of_month
if len(schedule_detail.frequency.monthdays) != len(temp_frequency.monthdays) or \
schedule_detail.frequency.hours != temp_frequency.hours or \
schedule_detail.frequency.minutes != temp_frequency.minutes:
update_schedule = True
changed = True
update_schedule = True
changed = True
elif len(schedule_detail.frequency.monthdays) == len(temp_frequency.monthdays):
actual_frequency_monthday = schedule_detail.frequency.monthdays
temp_frequency_monthday = temp_frequency.monthdays
@ -511,15 +511,15 @@ class ElementSWSnapShotSchedule(object):
if len(schedule_detail.frequency.weekdays) != len(temp_frequency.weekdays) or \
schedule_detail.frequency.hours != temp_frequency.hours or \
schedule_detail.frequency.minutes != temp_frequency.minutes:
update_schedule = True
changed = True
update_schedule = True
changed = True
elif len(schedule_detail.frequency.weekdays) == len(temp_frequency.weekdays):
actual_frequency_weekdays = schedule_detail.frequency.weekdays
temp_frequency_weekdays = temp_frequency.weekdays
if len([actual_weekday for actual_weekday, temp_weekday in
zip(actual_frequency_weekdays, temp_frequency_weekdays) if actual_weekday != temp_weekday]) != 0:
update_schedule = True
changed = True
zip(actual_frequency_weekdays, temp_frequency_weekdays) if actual_weekday != temp_weekday]) != 0:
update_schedule = True
changed = True
else:
update_schedule = True
changed = True

View file

@ -340,8 +340,8 @@ class ElementOSVolume(object):
volume_qos = volume_detail.qos.__dict__
if volume_qos['min_iops'] != self.qos['minIOPS'] or volume_qos['max_iops'] != self.qos['maxIOPS'] \
or volume_qos['burst_iops'] != self.qos['burstIOPS']:
update_volume = True
changed = True
update_volume = True
changed = True
else:
# If check fails, do nothing
pass

View file

@ -233,7 +233,7 @@ class ElementOSVolumeClone(object):
result_message = ""
if self.get_account_id() is None:
self.module.fail_json(msg="Account id not found: %s" % (self.account_id))
self.module.fail_json(msg="Account id not found: %s" % (self.account_id))
# there is only one state. other operations
# are part of the volume module
@ -245,7 +245,7 @@ class ElementOSVolumeClone(object):
if self.get_src_volume_id() is not None:
# check for a valid snapshot
if self.src_snapshot_id and not self.get_snapshot_id():
self.module.fail_json(msg="Snapshot id not found: %s" % (self.src_snapshot_id))
self.module.fail_json(msg="Snapshot id not found: %s" % (self.src_snapshot_id))
# change required
changed = True
else:

View file

@ -94,12 +94,12 @@ class NetAppONTAPCommand(object):
def main():
"""
Execute action from playbook
"""
command = NetAppONTAPCommand()
command.apply()
"""
Execute action from playbook
"""
command = NetAppONTAPCommand()
command.apply()
if __name__ == '__main__':
main()
main()

View file

@ -294,8 +294,8 @@ class DataLoader:
# if path is in role and 'tasks' not there already, add it into the search
if (is_role or self._is_role(path)) and b_mydir.endswith(b'tasks'):
search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source))
search.append(os.path.join(b_mydir, b_source))
search.append(os.path.join(os.path.dirname(b_mydir), b_dirname, b_source))
search.append(os.path.join(b_mydir, b_source))
else:
# don't add dirname if user already is using it in source
if b_source.split(b'/')[0] != dirname:

View file

@ -3,8 +3,8 @@
class ModuleDocFragment(object):
# GCP doc fragment.
DOCUMENTATION = '''
# GCP doc fragment.
DOCUMENTATION = '''
options:
project:
description:

View file

@ -75,7 +75,7 @@ try:
if LooseVersion(requests.__version__) < LooseVersion('1.1.0'):
raise ImportError
except ImportError:
raise AnsibleError('This script requires python-requests 1.1 as a minimum version')
raise AnsibleError('This script requires python-requests 1.1 as a minimum version')
from requests.auth import HTTPBasicAuth