mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
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:
parent
d13d7e9404
commit
c57a7f05e1
314 changed files with 3462 additions and 3383 deletions
|
@ -166,6 +166,7 @@ def validate_roles(value, module):
|
|||
if item not in VALID_ROLES:
|
||||
module.fail_json(msg='invalid role specified')
|
||||
|
||||
|
||||
def map_obj_to_commands(updates, module):
|
||||
commands = list()
|
||||
state = module.params['state']
|
||||
|
@ -174,9 +175,11 @@ def map_obj_to_commands(updates, module):
|
|||
for update in updates:
|
||||
want, have = update
|
||||
|
||||
needs_update = lambda x: want.get(x) and (want.get(x) != have.get(x))
|
||||
add = lambda x: commands.append('username %s %s' % (want['name'], x))
|
||||
remove = lambda x: commands.append('no username %s %s' % (want['name'], x))
|
||||
def needs_update(x): return want.get(x) and (want.get(x) != have.get(x))
|
||||
|
||||
def add(x): return commands.append('username %s %s' % (want['name'], x))
|
||||
|
||||
def remove(x): return commands.append('no username %s %s' % (want['name'], x))
|
||||
|
||||
if want['state'] == 'absent':
|
||||
commands.append('no username %s' % want['name'])
|
||||
|
@ -192,7 +195,6 @@ def map_obj_to_commands(updates, module):
|
|||
if needs_update('sshkey'):
|
||||
add('sshkey %s' % want['sshkey'])
|
||||
|
||||
|
||||
if want['roles']:
|
||||
if have:
|
||||
for item in set(have['roles']).difference(want['roles']):
|
||||
|
@ -204,13 +206,14 @@ def map_obj_to_commands(updates, module):
|
|||
for item in want['roles']:
|
||||
add('role %s' % item)
|
||||
|
||||
|
||||
return commands
|
||||
|
||||
|
||||
def parse_password(data):
|
||||
if not data.get('remote_login'):
|
||||
return '<PASSWORD>'
|
||||
|
||||
|
||||
def parse_roles(data):
|
||||
configured_roles = data.get('TABLE_role')['ROW_role']
|
||||
roles = list()
|
||||
|
@ -219,6 +222,7 @@ def parse_roles(data):
|
|||
roles.append(item['role'])
|
||||
return roles
|
||||
|
||||
|
||||
def map_config_to_obj(module):
|
||||
out = run_commands(module, ['show user-account | json'])
|
||||
data = out[0]
|
||||
|
@ -235,6 +239,7 @@ def map_config_to_obj(module):
|
|||
})
|
||||
return objects
|
||||
|
||||
|
||||
def get_param_value(key, item, module):
|
||||
# if key doesn't exist in the item, get it from module.params
|
||||
if not item.get(key):
|
||||
|
@ -249,6 +254,7 @@ def get_param_value(key, item, module):
|
|||
|
||||
return value
|
||||
|
||||
|
||||
def map_params_to_obj(module):
|
||||
aggregate = module.params['aggregate']
|
||||
if not aggregate:
|
||||
|
@ -290,6 +296,7 @@ def map_params_to_obj(module):
|
|||
|
||||
return objects
|
||||
|
||||
|
||||
def update_objects(want, have):
|
||||
updates = list()
|
||||
for entry in want:
|
||||
|
@ -302,6 +309,7 @@ def update_objects(want, have):
|
|||
updates.append((entry, item))
|
||||
return updates
|
||||
|
||||
|
||||
def main():
|
||||
""" main entry point for module execution
|
||||
"""
|
||||
|
@ -328,7 +336,6 @@ def main():
|
|||
mutually_exclusive=mutually_exclusive,
|
||||
supports_check_mode=True)
|
||||
|
||||
|
||||
result = {'changed': False}
|
||||
|
||||
warnings = list()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue