mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix nxos_vpc idempotence issues (#25219)
* Fix nxos_vpc idempotence issues * Remove legacy-file pep8 now passing
This commit is contained in:
parent
80c1765653
commit
b76acc8ce8
2 changed files with 21 additions and 15 deletions
|
@ -147,10 +147,11 @@ changed:
|
||||||
sample: true
|
sample: true
|
||||||
'''
|
'''
|
||||||
|
|
||||||
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.nxos import nxos_argument_spec, check_args
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
def execute_show_command(command, module, command_type='cli_show'):
|
def execute_show_command(command, module, command_type='cli_show'):
|
||||||
if module.params['transport'] == 'cli':
|
if module.params['transport'] == 'cli':
|
||||||
if "section" not in command:
|
if "section" not in command:
|
||||||
|
@ -158,7 +159,10 @@ def execute_show_command(command, module, command_type='cli_show'):
|
||||||
cmds = [command]
|
cmds = [command]
|
||||||
body = run_commands(module, cmds)
|
body = run_commands(module, cmds)
|
||||||
elif module.params['transport'] == 'nxapi':
|
elif module.params['transport'] == 'nxapi':
|
||||||
|
if command_type == 'cli_show_ascii':
|
||||||
cmds = [command]
|
cmds = [command]
|
||||||
|
else:
|
||||||
|
cmds = [command + ' | json']
|
||||||
body = run_commands(module, cmds)
|
body = run_commands(module, cmds)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
@ -177,10 +181,9 @@ def get_vrf_list(module):
|
||||||
command = 'show vrf all'
|
command = 'show vrf all'
|
||||||
vrf_table = None
|
vrf_table = None
|
||||||
|
|
||||||
body = execute_show_command(command, module)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vrf_table = body[0]['TABLE_vrf']['ROW_vrf']
|
body = execute_show_command(command, module)[0]
|
||||||
|
vrf_table = body['TABLE_vrf']['ROW_vrf']
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -219,7 +222,7 @@ def get_vpc(module):
|
||||||
if domain != 'not configured':
|
if domain != 'not configured':
|
||||||
delay_restore = None
|
delay_restore = None
|
||||||
pkl_src = None
|
pkl_src = None
|
||||||
role_priority = None
|
role_priority = '32667'
|
||||||
system_priority = None
|
system_priority = None
|
||||||
pkl_dest = None
|
pkl_dest = None
|
||||||
pkl_vrf = None
|
pkl_vrf = None
|
||||||
|
@ -249,7 +252,6 @@ def get_vpc(module):
|
||||||
if 'peer-gateway' in each:
|
if 'peer-gateway' in each:
|
||||||
peer_gw = True
|
peer_gw = True
|
||||||
|
|
||||||
|
|
||||||
command = 'show vpc peer-keepalive'
|
command = 'show vpc peer-keepalive'
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
|
|
||||||
|
@ -307,10 +309,16 @@ def get_commands_to_config_vpc(module, vpc, domain, existing):
|
||||||
else:
|
else:
|
||||||
vpc['auto_recovery'] = ''
|
vpc['auto_recovery'] = ''
|
||||||
|
|
||||||
|
if 'peer_gw' in vpc:
|
||||||
if vpc.get('peer_gw') is False:
|
if vpc.get('peer_gw') is False:
|
||||||
vpc['peer_gw'] = 'no'
|
vpc['peer_gw'] = 'no'
|
||||||
else:
|
else:
|
||||||
vpc['peer_gw'] = ''
|
vpc['peer_gw'] = ''
|
||||||
|
else:
|
||||||
|
if existing.get('peer_gw') is False:
|
||||||
|
vpc['peer_gw'] = 'no'
|
||||||
|
else:
|
||||||
|
vpc['peer_gw'] = ''
|
||||||
|
|
||||||
CONFIG_ARGS = {
|
CONFIG_ARGS = {
|
||||||
'role_priority': 'role priority {role_priority}',
|
'role_priority': 'role priority {role_priority}',
|
||||||
|
@ -442,4 +450,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,6 @@ lib/ansible/modules/network/nxos/nxos_system.py
|
||||||
lib/ansible/modules/network/nxos/nxos_udld.py
|
lib/ansible/modules/network/nxos/nxos_udld.py
|
||||||
lib/ansible/modules/network/nxos/nxos_udld_interface.py
|
lib/ansible/modules/network/nxos/nxos_udld_interface.py
|
||||||
lib/ansible/modules/network/nxos/nxos_user.py
|
lib/ansible/modules/network/nxos/nxos_user.py
|
||||||
lib/ansible/modules/network/nxos/nxos_vpc.py
|
|
||||||
lib/ansible/modules/network/nxos/nxos_vpc_interface.py
|
lib/ansible/modules/network/nxos/nxos_vpc_interface.py
|
||||||
lib/ansible/modules/network/nxos/nxos_vrf.py
|
lib/ansible/modules/network/nxos/nxos_vrf.py
|
||||||
lib/ansible/modules/network/nxos/nxos_vrf_interface.py
|
lib/ansible/modules/network/nxos/nxos_vrf_interface.py
|
||||||
|
|
Loading…
Reference in a new issue