mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00: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:
committed by
John R Barker
parent
d13d7e9404
commit
c57a7f05e1
@@ -187,6 +187,7 @@ from ansible.module_utils.network.eos.eos import run_commands, load_config
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.network.eos.eos import eos_argument_spec, check_args
|
||||
|
||||
|
||||
def check_transport(module):
|
||||
transport = module.params['transport']
|
||||
provider_transport = (module.params['provider'] or {}).get('transport')
|
||||
@@ -194,18 +195,22 @@ def check_transport(module):
|
||||
if 'eapi' in (transport, provider_transport):
|
||||
module.fail_json(msg='eos_eapi module is only supported over cli transport')
|
||||
|
||||
|
||||
def validate_http_port(value, module):
|
||||
if not 1 <= value <= 65535:
|
||||
module.fail_json(msg='http_port must be between 1 and 65535')
|
||||
|
||||
|
||||
def validate_https_port(value, module):
|
||||
if not 1 <= value <= 65535:
|
||||
module.fail_json(msg='http_port must be between 1 and 65535')
|
||||
|
||||
|
||||
def validate_local_http_port(value, module):
|
||||
if not 1 <= value <= 65535:
|
||||
module.fail_json(msg='http_port must be between 1 and 65535')
|
||||
|
||||
|
||||
def validate_vrf(value, module):
|
||||
out = run_commands(module, ['show vrf'])
|
||||
configured_vrfs = re.findall(r'^\s+(\w+)(?=\s)', out[0], re.M)
|
||||
@@ -213,11 +218,12 @@ def validate_vrf(value, module):
|
||||
if value not in configured_vrfs:
|
||||
module.fail_json(msg='vrf `%s` is not configured on the system' % value)
|
||||
|
||||
|
||||
def map_obj_to_commands(updates, module, warnings):
|
||||
commands = list()
|
||||
want, have = updates
|
||||
|
||||
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))
|
||||
|
||||
def add(cmd):
|
||||
if 'management api http-commands' not in commands:
|
||||
@@ -266,7 +272,6 @@ def map_obj_to_commands(updates, module, warnings):
|
||||
elif want['state'] == 'started':
|
||||
add('no shutdown')
|
||||
|
||||
|
||||
if needs_update('vrf'):
|
||||
add('vrf %s' % want['vrf'])
|
||||
# switching operational vrfs here
|
||||
@@ -278,6 +283,7 @@ def map_obj_to_commands(updates, module, warnings):
|
||||
|
||||
return commands
|
||||
|
||||
|
||||
def parse_state(data):
|
||||
if data[0]['enabled']:
|
||||
return 'started'
|
||||
@@ -299,6 +305,7 @@ def map_config_to_obj(module):
|
||||
'state': parse_state(out)
|
||||
}
|
||||
|
||||
|
||||
def map_params_to_obj(module):
|
||||
obj = {
|
||||
'http': module.params['http'],
|
||||
@@ -320,6 +327,7 @@ def map_params_to_obj(module):
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
def verify_state(updates, module):
|
||||
want, have = updates
|
||||
|
||||
@@ -348,6 +356,7 @@ def verify_state(updates, module):
|
||||
if timeout == 0:
|
||||
module.fail_json(msg='timeout expired before eapi running state changed')
|
||||
|
||||
|
||||
def collect_facts(module, result):
|
||||
out = run_commands(module, ['show management api http-commands | json'])
|
||||
facts = dict(eos_eapi_urls=dict())
|
||||
@@ -359,6 +368,7 @@ def collect_facts(module, result):
|
||||
facts['eos_eapi_urls'][key].append(str(url).strip())
|
||||
result['ansible_facts'] = facts
|
||||
|
||||
|
||||
def main():
|
||||
""" main entry point for module execution
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user