Bulk autopep8 (modules)

As agreed in 2017-12-07 Core meeting bulk fix pep8 issues

Generated using:
autopep8 1.3.3 (pycodestyle: 2.3.1)
autopep8 -r  --max-line-length 160 --in-place --ignore E305,E402,E722,E741 lib/ansible/modules

Manually fix issues that autopep8 has introduced
This commit is contained in:
John Barker 2017-12-07 16:27:06 +00:00 committed by John R Barker
parent d13d7e9404
commit c57a7f05e1
314 changed files with 3462 additions and 3383 deletions

View file

@ -125,6 +125,7 @@ from ansible.module_utils.network.common.utils import ComplexList
_CONFIGURED_VRFS = None
def has_vrf(module, vrf):
global _CONFIGURED_VRFS
if _CONFIGURED_VRFS is not None:
@ -133,20 +134,23 @@ def has_vrf(module, vrf):
_CONFIGURED_VRFS = re.findall(r'vrf definition (\S+)', config)
return vrf in _CONFIGURED_VRFS
def requires_vrf(module, vrf):
if not has_vrf(module, vrf):
module.fail_json(msg='vrf %s is not configured' % vrf)
def diff_list(want, have):
adds = [w for w in want if w not in have]
removes = [h for h in have if h not in want]
return (adds, removes)
def map_obj_to_commands(want, have, module):
commands = list()
state = module.params['state']
needs_update = lambda x: want.get(x) is not None and (want.get(x) != have.get(x))
def needs_update(x): return want.get(x) is not None and (want.get(x) != have.get(x))
if state == 'absent':
if have['hostname'] != 'Router':
@ -226,7 +230,6 @@ def map_obj_to_commands(want, have, module):
else:
commands.append('ip domain list %s' % item['name'])
if want['name_servers']:
adds, removes = diff_list(want['name_servers'], have['name_servers'])
for item in removes:
@ -243,10 +246,12 @@ def map_obj_to_commands(want, have, module):
return commands
def parse_hostname(config):
match = re.search(r'^hostname (\S+)', config, re.M)
return match.group(1)
def parse_domain_name(config):
match = re.findall(r'^ip domain name (?:vrf (\S+) )*(\S+)', config, re.M)
matches = list()
@ -256,6 +261,7 @@ def parse_domain_name(config):
matches.append({'name': name, 'vrf': vrf})
return matches
def parse_domain_search(config):
match = re.findall(r'^ip domain list (?:vrf (\S+) )*(\S+)', config, re.M)
matches = list()
@ -265,6 +271,7 @@ def parse_domain_search(config):
matches.append({'name': name, 'vrf': vrf})
return matches
def parse_name_servers(config):
match = re.findall(r'^ip name-server (?:vrf (\S+) )*(.*)', config, re.M)
matches = list()
@ -275,11 +282,13 @@ def parse_name_servers(config):
matches.append({'server': server, 'vrf': vrf})
return matches
def parse_lookup_source(config):
match = re.search(r'ip domain lookup source-interface (\S+)', config, re.M)
if match:
return match.group(1)
def map_config_to_obj(module):
config = get_config(module)
return {
@ -291,6 +300,7 @@ def map_config_to_obj(module):
'name_servers': parse_name_servers(config)
}
def map_params_to_obj(module):
obj = {
'hostname': module.params['hostname'],
@ -324,6 +334,7 @@ def map_params_to_obj(module):
return obj
def main():
""" Main entry point for Ansible module execution
"""