mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fix nxos_interface multiple issues (#27106)
* fix execute_show_command * fix pep8 issues * fix AttributeError #26562 * legacy-file remove * modify execute_show_command output * fix admin_state up doc * fix admin_state for all interfaces doc Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
9b9a8749da
commit
7351ee9a76
2 changed files with 22 additions and 23 deletions
|
@ -123,16 +123,14 @@ EXAMPLES = '''
|
|||
- svi
|
||||
- nve
|
||||
|
||||
- name: Admin up all ethernet interfaces
|
||||
- name: Admin up all loopback interfaces
|
||||
nxos_interface:
|
||||
interface: ethernet
|
||||
host: 68.170.147.165
|
||||
interface: loopback 0-1023
|
||||
admin_state: up
|
||||
|
||||
- name: Admin down ALL interfaces (physical and logical)
|
||||
- name: Admin down all loopback interfaces
|
||||
nxos_interface:
|
||||
interface: all
|
||||
host: 68.170.147.165
|
||||
interface: looback 0-1023
|
||||
admin_state: down
|
||||
'''
|
||||
|
||||
|
@ -149,8 +147,6 @@ from ansible.module_utils.nxos import nxos_argument_spec, check_args
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
|
||||
|
||||
def is_default_interface(interface, module):
|
||||
"""Checks to see if interface exists and if it is a default config
|
||||
Args:
|
||||
|
@ -386,14 +382,15 @@ def get_interfaces_dict(module):
|
|||
'portchannel': [],
|
||||
'nve': [],
|
||||
'unknown': []
|
||||
}
|
||||
}
|
||||
|
||||
interface_list = body.get('TABLE_interface')['ROW_interface']
|
||||
for index in interface_list:
|
||||
intf = index['interface']
|
||||
intf_type = get_interface_type(intf)
|
||||
if body:
|
||||
interface_list = body['TABLE_interface']['ROW_interface']
|
||||
for index in interface_list:
|
||||
intf = index['interface']
|
||||
intf_type = get_interface_type(intf)
|
||||
|
||||
interfaces[intf_type].append(intf)
|
||||
interfaces[intf_type].append(intf)
|
||||
|
||||
return interfaces
|
||||
|
||||
|
@ -547,9 +544,15 @@ def smart_existing(module, intf_type, normalized_interface):
|
|||
|
||||
|
||||
def execute_show_command(command, module):
|
||||
if module.params['transport'] == 'cli':
|
||||
command += ' | json'
|
||||
cmds = [command]
|
||||
if 'show run' not in command:
|
||||
output = 'json'
|
||||
else:
|
||||
output = 'text'
|
||||
cmds = [{
|
||||
'command': command,
|
||||
'output': output,
|
||||
}]
|
||||
|
||||
body = run_commands(module, cmds)
|
||||
return body
|
||||
|
||||
|
@ -584,10 +587,7 @@ def main():
|
|||
interface_type=dict(required=False, choices=['loopback', 'portchannel', 'svi', 'nve']),
|
||||
ip_forward=dict(required=False, choices=['enable', 'disable']),
|
||||
fabric_forwarding_anycast_gateway=dict(required=False, type='bool'),
|
||||
state=dict(choices=['absent', 'present', 'default'], default='present', required=False),
|
||||
include_defaults=dict(default=True),
|
||||
config=dict(),
|
||||
save=dict(type='bool', default=False)
|
||||
state=dict(choices=['absent', 'present', 'default'], default='present', required=False)
|
||||
)
|
||||
|
||||
argument_spec.update(nxos_argument_spec)
|
||||
|
@ -687,7 +687,7 @@ def main():
|
|||
load_config(module, cmds)
|
||||
results['changed'] = True
|
||||
if module.params['interface']:
|
||||
if delta.get('mode'): # or delta.get('admin_state'):
|
||||
if delta.get('mode'):
|
||||
# if the mode changes from L2 to L3, the admin state
|
||||
# seems to change after the API call, so adding a second API
|
||||
# call to ensure it's in the desired state.
|
||||
|
|
|
@ -348,7 +348,6 @@ lib/ansible/modules/network/nxos/nxos_igmp.py
|
|||
lib/ansible/modules/network/nxos/nxos_igmp_interface.py
|
||||
lib/ansible/modules/network/nxos/nxos_igmp_snooping.py
|
||||
lib/ansible/modules/network/nxos/nxos_install_os.py
|
||||
lib/ansible/modules/network/nxos/nxos_interface.py
|
||||
lib/ansible/modules/network/nxos/nxos_ntp.py
|
||||
lib/ansible/modules/network/nxos/nxos_ntp_auth.py
|
||||
lib/ansible/modules/network/nxos/nxos_ntp_options.py
|
||||
|
|
Loading…
Reference in a new issue