summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2017-07-28 09:02:02 +0530
committerGitHub <noreply@github.com>2017-07-28 09:02:02 +0530
commita49c419651ef78c571dfd69d576c8f0c227abdd6 (patch)
tree641a894f857bf69d3f1c7414d8e9525f75bbaf7d
parent87d434ed6886a399bfcacd9c17817eb3acfad377 (diff)
downloadansible-a49c419651ef78c571dfd69d576c8f0c227abdd6.tar.gz
fix nxos_vrf_af nxapi & cli (#27307)
* fix nxapi failure #27142 Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * fix nxos_vrf_af nxapi and cli Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
-rw-r--r--lib/ansible/modules/network/nxos/nxos_vrf_af.py24
-rw-r--r--test/units/modules/network/nxos/test_nxos_vrf_af.py10
2 files changed, 10 insertions, 24 deletions
diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_af.py b/lib/ansible/modules/network/nxos/nxos_vrf_af.py
index 0c411f3b5c..0809b36196 100644
--- a/lib/ansible/modules/network/nxos/nxos_vrf_af.py
+++ b/lib/ansible/modules/network/nxos/nxos_vrf_af.py
@@ -80,9 +80,7 @@ commands:
description: commands sent to the device
returned: always
type: list
- sample: ["vrf context ntc", "address-family ipv4 unicast",
- "afi ipv4", "route-target both auto evpn", "vrf ntc",
- "safi unicast"]
+ sample: ["vrf context ntc", "address-family ipv4 unicast"]
'''
import re
@@ -95,9 +93,6 @@ from ansible.module_utils.netcfg import CustomNetworkConfig
BOOL_PARAMS = ['route_target_both_auto_evpn']
PARAM_TO_COMMAND_KEYMAP = {
- 'vrf': 'vrf',
- 'safi': 'safi',
- 'afi': 'afi',
'route_target_both_auto_evpn': 'route-target both auto evpn'
}
PARAM_TO_DEFAULT_KEYMAP = {}
@@ -179,11 +174,10 @@ def state_present(module, existing, proposed, candidate):
command = '{0} {1}'.format(key, value.lower())
commands.append(command)
- if commands:
- parents = ['vrf context {0}'.format(module.params['vrf'])]
- parents.append('address-family {0} {1}'.format(module.params['afi'],
- module.params['safi']))
- candidate.add(commands, parents=parents)
+ parents = ['vrf context {0}'.format(module.params['vrf'])]
+ parents.append('address-family {0} {1}'.format(module.params['afi'],
+ module.params['safi']))
+ candidate.add(commands, parents=parents)
def state_absent(module, existing, proposed, candidate):
@@ -201,10 +195,7 @@ def main():
afi=dict(required=True, type='str', choices=['ipv4', 'ipv6']),
route_target_both_auto_evpn=dict(required=False, type='bool'),
m_facts=dict(required=False, default=False, type='bool'),
- state=dict(choices=['present', 'absent'], default='present', required=False),
- include_defaults=dict(default=False),
- config=dict(),
- save=dict(type='bool', default=False)
+ state=dict(choices=['present', 'absent'], default='present', required=False)
)
argument_spec.update(nxos_argument_spec)
@@ -238,9 +229,10 @@ def main():
state_absent(module, existing, proposed, candidate)
if candidate:
+ candidate = candidate.items_text()
load_config(module, candidate)
result['changed'] = True
- result['commands'] = candidate.items_text()
+ result['commands'] = candidate
else:
result['commands'] = []
diff --git a/test/units/modules/network/nxos/test_nxos_vrf_af.py b/test/units/modules/network/nxos/test_nxos_vrf_af.py
index d2a890e4e1..7a3e7a329b 100644
--- a/test/units/modules/network/nxos/test_nxos_vrf_af.py
+++ b/test/units/modules/network/nxos/test_nxos_vrf_af.py
@@ -51,10 +51,7 @@ class TestNxosVrfafModule(TestNxosModule):
set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='present'))
result = self.execute_module(changed=True)
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
- 'address-family ipv4 unicast',
- 'afi ipv4',
- 'vrf ntc',
- 'safi unicast']))
+ 'address-family ipv4 unicast']))
def test_nxos_vrf_af_absent(self):
set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='absent'))
@@ -66,7 +63,4 @@ class TestNxosVrfafModule(TestNxosModule):
result = self.execute_module(changed=True)
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
'address-family ipv4 unicast',
- 'afi ipv4',
- 'route-target both auto evpn',
- 'vrf ntc',
- 'safi unicast']))
+ 'route-target both auto evpn']))