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
|
||||
'''
|
||||
|
||||
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
|
||||
|
||||
|
||||
def execute_show_command(command, module, command_type='cli_show'):
|
||||
if module.params['transport'] == 'cli':
|
||||
if "section" not in command:
|
||||
|
@ -158,7 +159,10 @@ def execute_show_command(command, module, command_type='cli_show'):
|
|||
cmds = [command]
|
||||
body = run_commands(module, cmds)
|
||||
elif module.params['transport'] == 'nxapi':
|
||||
if command_type == 'cli_show_ascii':
|
||||
cmds = [command]
|
||||
else:
|
||||
cmds = [command + ' | json']
|
||||
body = run_commands(module, cmds)
|
||||
return body
|
||||
|
||||
|
@ -177,10 +181,9 @@ def get_vrf_list(module):
|
|||
command = 'show vrf all'
|
||||
vrf_table = None
|
||||
|
||||
body = execute_show_command(command, module)
|
||||
|
||||
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):
|
||||
return []
|
||||
|
||||
|
@ -219,7 +222,7 @@ def get_vpc(module):
|
|||
if domain != 'not configured':
|
||||
delay_restore = None
|
||||
pkl_src = None
|
||||
role_priority = None
|
||||
role_priority = '32667'
|
||||
system_priority = None
|
||||
pkl_dest = None
|
||||
pkl_vrf = None
|
||||
|
@ -249,7 +252,6 @@ def get_vpc(module):
|
|||
if 'peer-gateway' in each:
|
||||
peer_gw = True
|
||||
|
||||
|
||||
command = 'show vpc peer-keepalive'
|
||||
body = execute_show_command(command, module)[0]
|
||||
|
||||
|
@ -307,10 +309,16 @@ def get_commands_to_config_vpc(module, vpc, domain, existing):
|
|||
else:
|
||||
vpc['auto_recovery'] = ''
|
||||
|
||||
if 'peer_gw' in vpc:
|
||||
if vpc.get('peer_gw') is False:
|
||||
vpc['peer_gw'] = 'no'
|
||||
else:
|
||||
vpc['peer_gw'] = ''
|
||||
else:
|
||||
if existing.get('peer_gw') is False:
|
||||
vpc['peer_gw'] = 'no'
|
||||
else:
|
||||
vpc['peer_gw'] = ''
|
||||
|
||||
CONFIG_ARGS = {
|
||||
'role_priority': 'role priority {role_priority}',
|
||||
|
@ -442,4 +450,3 @@ def main():
|
|||
|
||||
if __name__ == '__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_interface.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_vrf.py
|
||||
lib/ansible/modules/network/nxos/nxos_vrf_interface.py
|
||||
|
|
Loading…
Reference in a new issue