roll up of fixes for eos modules (#21406)

* fixes issue with load_provider() not checking for an existing key
* adds updates to eos_config results key
* lots of minor syntax fixes in eos shared module
* adds eos_argument_spec to eos_eapi

fixes #21402
This commit is contained in:
Peter Sprygada 2017-02-14 13:47:29 -05:00 committed by John R Barker
commit e1a2c6e1d3
7 changed files with 36 additions and 23 deletions

View file

@ -125,6 +125,7 @@ failed_conditions:
import time
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.six import string_types
from ansible.module_utils.netcli import Conditional
from ansible.module_utils.network_common import ComplexList
@ -193,7 +194,12 @@ def main():
result['warnings'] = warnings
wait_for = module.params['wait_for'] or list()
conditionals = [Conditional(c) for c in wait_for]
try:
conditionals = [Conditional(c) for c in wait_for]
except AttributeError:
exc = get_exception()
module.fail_json(msg=str(exc))
retries = module.params['retries']
interval = module.params['interval']

View file

@ -250,6 +250,7 @@ def run(module, result):
commands.extend(module.params['after'])
result['commands'] = commands
result['updates'] = commands
replace = module.params['replace'] == 'config'
commit = not module.check_mode

View file

@ -184,6 +184,7 @@ import re
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.eos import run_commands, load_config
from ansible.module_utils.six import iteritems
from ansible.module_utils.eos import eos_argument_spec, check_args
def validate_http_port(value, module):
if not 1 <= value <= 65535:
@ -198,8 +199,8 @@ def validate_local_http_port(value, module):
module.fail_json(msg='http_port must be between 1 and 65535')
def validate_vrf(value, module):
rc, out, err = run_commands(module, ['show vrf'])
configured_vrfs = re.findall('^\s+(\w+)(?=\s)', out[0],re.M)
out = run_commands(module, ['show vrf'])
configured_vrfs = re.findall('^\s+(\w+)(?=\s)', out[0], re.M)
configured_vrfs.append('default')
if value not in configured_vrfs:
module.fail_json(msg='vrf `%s` is not configured on the system' % value)
@ -255,7 +256,7 @@ def parse_state(data):
def map_config_to_obj(module):
rc, out, err = run_commands(module, ['show management api http-commands | json'])
out = run_commands(module, ['show management api http-commands | json'])
return {
'http': out[0]['httpServer']['configured'],
'http_port': out[0]['httpServer']['port'],
@ -290,7 +291,7 @@ def map_params_to_obj(module):
return obj
def collect_facts(module, result):
rc, out, err = run_commands(module, ['show management api http-commands | json'])
out = run_commands(module, ['show management api http-commands | json'])
facts = dict(eos_eapi_urls=dict())
for each in out[0]['urls']:
intf, url = each.split(' : ')
@ -320,6 +321,8 @@ def main():
state=dict(default='started', choices=['stopped', 'started']),
)
argument_spec.update(eos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)

View file

@ -143,6 +143,7 @@ import re
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network_common import ComplexList
from ansible.module_utils.eos import load_config, get_config
from ansible.module_utils.eos import eos_argument_spec
_CONFIGURED_VRFS = None
@ -304,6 +305,8 @@ def main():
state=dict(default='present', choices=['present', 'absent'])
)
argument_spec.update(eos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)