nxos_vrf fix (#25812)

* Fixes #25031

* Slight cleanup and add tests
This commit is contained in:
Nathaniel Case
2017-06-20 10:59:03 -04:00
committed by GitHub
parent aa32f4e80c
commit 0296c2285b
5 changed files with 47 additions and 19 deletions

View File

@@ -98,7 +98,7 @@ commands:
'''
import re
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
@@ -190,6 +190,7 @@ def get_vrf(vrf, module):
return {}
parsed_vrf = apply_key_map(vrf_key, vrf_table)
parsed_vrf['admin_state'] = parsed_vrf['admin_state'].lower()
command = 'show run all | section vrf.context.{0}'.format(vrf)
body = execute_show_command(command, module)[0]
@@ -259,13 +260,13 @@ def main():
if proposed.get('vni'):
if existing.get('vni') and existing.get('vni') != '':
commands.insert(1, 'no vni {0}'.format(existing['vni']))
if module.check_mode:
module.exit_json(changed=True, commands=commands)
else:
if not module.check_mode:
load_config(module, commands)
results['changed'] = True
if 'configure' in commands:
commands.pop(0)
results['changed'] = True
if 'configure' in commands:
commands.pop(0)
results['commands'] = commands