mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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>
This commit is contained in:
parent
87d434ed68
commit
a49c419651
2 changed files with 10 additions and 24 deletions
|
@ -80,9 +80,7 @@ commands:
|
||||||
description: commands sent to the device
|
description: commands sent to the device
|
||||||
returned: always
|
returned: always
|
||||||
type: list
|
type: list
|
||||||
sample: ["vrf context ntc", "address-family ipv4 unicast",
|
sample: ["vrf context ntc", "address-family ipv4 unicast"]
|
||||||
"afi ipv4", "route-target both auto evpn", "vrf ntc",
|
|
||||||
"safi unicast"]
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
@ -95,9 +93,6 @@ from ansible.module_utils.netcfg import CustomNetworkConfig
|
||||||
|
|
||||||
BOOL_PARAMS = ['route_target_both_auto_evpn']
|
BOOL_PARAMS = ['route_target_both_auto_evpn']
|
||||||
PARAM_TO_COMMAND_KEYMAP = {
|
PARAM_TO_COMMAND_KEYMAP = {
|
||||||
'vrf': 'vrf',
|
|
||||||
'safi': 'safi',
|
|
||||||
'afi': 'afi',
|
|
||||||
'route_target_both_auto_evpn': 'route-target both auto evpn'
|
'route_target_both_auto_evpn': 'route-target both auto evpn'
|
||||||
}
|
}
|
||||||
PARAM_TO_DEFAULT_KEYMAP = {}
|
PARAM_TO_DEFAULT_KEYMAP = {}
|
||||||
|
@ -179,11 +174,10 @@ def state_present(module, existing, proposed, candidate):
|
||||||
command = '{0} {1}'.format(key, value.lower())
|
command = '{0} {1}'.format(key, value.lower())
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
|
|
||||||
if commands:
|
parents = ['vrf context {0}'.format(module.params['vrf'])]
|
||||||
parents = ['vrf context {0}'.format(module.params['vrf'])]
|
parents.append('address-family {0} {1}'.format(module.params['afi'],
|
||||||
parents.append('address-family {0} {1}'.format(module.params['afi'],
|
module.params['safi']))
|
||||||
module.params['safi']))
|
candidate.add(commands, parents=parents)
|
||||||
candidate.add(commands, parents=parents)
|
|
||||||
|
|
||||||
|
|
||||||
def state_absent(module, existing, proposed, candidate):
|
def state_absent(module, existing, proposed, candidate):
|
||||||
|
@ -201,10 +195,7 @@ def main():
|
||||||
afi=dict(required=True, type='str', choices=['ipv4', 'ipv6']),
|
afi=dict(required=True, type='str', choices=['ipv4', 'ipv6']),
|
||||||
route_target_both_auto_evpn=dict(required=False, type='bool'),
|
route_target_both_auto_evpn=dict(required=False, type='bool'),
|
||||||
m_facts=dict(required=False, default=False, type='bool'),
|
m_facts=dict(required=False, default=False, type='bool'),
|
||||||
state=dict(choices=['present', 'absent'], default='present', required=False),
|
state=dict(choices=['present', 'absent'], default='present', required=False)
|
||||||
include_defaults=dict(default=False),
|
|
||||||
config=dict(),
|
|
||||||
save=dict(type='bool', default=False)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(nxos_argument_spec)
|
argument_spec.update(nxos_argument_spec)
|
||||||
|
@ -238,9 +229,10 @@ def main():
|
||||||
state_absent(module, existing, proposed, candidate)
|
state_absent(module, existing, proposed, candidate)
|
||||||
|
|
||||||
if candidate:
|
if candidate:
|
||||||
|
candidate = candidate.items_text()
|
||||||
load_config(module, candidate)
|
load_config(module, candidate)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
result['commands'] = candidate.items_text()
|
result['commands'] = candidate
|
||||||
|
|
||||||
else:
|
else:
|
||||||
result['commands'] = []
|
result['commands'] = []
|
||||||
|
|
|
@ -51,10 +51,7 @@ class TestNxosVrfafModule(TestNxosModule):
|
||||||
set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='present'))
|
set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='present'))
|
||||||
result = self.execute_module(changed=True)
|
result = self.execute_module(changed=True)
|
||||||
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
|
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
|
||||||
'address-family ipv4 unicast',
|
'address-family ipv4 unicast']))
|
||||||
'afi ipv4',
|
|
||||||
'vrf ntc',
|
|
||||||
'safi unicast']))
|
|
||||||
|
|
||||||
def test_nxos_vrf_af_absent(self):
|
def test_nxos_vrf_af_absent(self):
|
||||||
set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='absent'))
|
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)
|
result = self.execute_module(changed=True)
|
||||||
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
|
self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc',
|
||||||
'address-family ipv4 unicast',
|
'address-family ipv4 unicast',
|
||||||
'afi ipv4',
|
'route-target both auto evpn']))
|
||||||
'route-target both auto evpn',
|
|
||||||
'vrf ntc',
|
|
||||||
'safi unicast']))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue