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
|
- svi
|
||||||
- nve
|
- nve
|
||||||
|
|
||||||
- name: Admin up all ethernet interfaces
|
- name: Admin up all loopback interfaces
|
||||||
nxos_interface:
|
nxos_interface:
|
||||||
interface: ethernet
|
interface: loopback 0-1023
|
||||||
host: 68.170.147.165
|
|
||||||
admin_state: up
|
admin_state: up
|
||||||
|
|
||||||
- name: Admin down ALL interfaces (physical and logical)
|
- name: Admin down all loopback interfaces
|
||||||
nxos_interface:
|
nxos_interface:
|
||||||
interface: all
|
interface: looback 0-1023
|
||||||
host: 68.170.147.165
|
|
||||||
admin_state: down
|
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
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_default_interface(interface, module):
|
def is_default_interface(interface, module):
|
||||||
"""Checks to see if interface exists and if it is a default config
|
"""Checks to see if interface exists and if it is a default config
|
||||||
Args:
|
Args:
|
||||||
|
@ -386,14 +382,15 @@ def get_interfaces_dict(module):
|
||||||
'portchannel': [],
|
'portchannel': [],
|
||||||
'nve': [],
|
'nve': [],
|
||||||
'unknown': []
|
'unknown': []
|
||||||
}
|
}
|
||||||
|
|
||||||
interface_list = body.get('TABLE_interface')['ROW_interface']
|
if body:
|
||||||
for index in interface_list:
|
interface_list = body['TABLE_interface']['ROW_interface']
|
||||||
intf = index['interface']
|
for index in interface_list:
|
||||||
intf_type = get_interface_type(intf)
|
intf = index['interface']
|
||||||
|
intf_type = get_interface_type(intf)
|
||||||
|
|
||||||
interfaces[intf_type].append(intf)
|
interfaces[intf_type].append(intf)
|
||||||
|
|
||||||
return interfaces
|
return interfaces
|
||||||
|
|
||||||
|
@ -547,9 +544,15 @@ def smart_existing(module, intf_type, normalized_interface):
|
||||||
|
|
||||||
|
|
||||||
def execute_show_command(command, module):
|
def execute_show_command(command, module):
|
||||||
if module.params['transport'] == 'cli':
|
if 'show run' not in command:
|
||||||
command += ' | json'
|
output = 'json'
|
||||||
cmds = [command]
|
else:
|
||||||
|
output = 'text'
|
||||||
|
cmds = [{
|
||||||
|
'command': command,
|
||||||
|
'output': output,
|
||||||
|
}]
|
||||||
|
|
||||||
body = run_commands(module, cmds)
|
body = run_commands(module, cmds)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
@ -584,10 +587,7 @@ def main():
|
||||||
interface_type=dict(required=False, choices=['loopback', 'portchannel', 'svi', 'nve']),
|
interface_type=dict(required=False, choices=['loopback', 'portchannel', 'svi', 'nve']),
|
||||||
ip_forward=dict(required=False, choices=['enable', 'disable']),
|
ip_forward=dict(required=False, choices=['enable', 'disable']),
|
||||||
fabric_forwarding_anycast_gateway=dict(required=False, type='bool'),
|
fabric_forwarding_anycast_gateway=dict(required=False, type='bool'),
|
||||||
state=dict(choices=['absent', 'present', 'default'], default='present', required=False),
|
state=dict(choices=['absent', 'present', 'default'], default='present', required=False)
|
||||||
include_defaults=dict(default=True),
|
|
||||||
config=dict(),
|
|
||||||
save=dict(type='bool', default=False)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec.update(nxos_argument_spec)
|
argument_spec.update(nxos_argument_spec)
|
||||||
|
@ -687,7 +687,7 @@ def main():
|
||||||
load_config(module, cmds)
|
load_config(module, cmds)
|
||||||
results['changed'] = True
|
results['changed'] = True
|
||||||
if module.params['interface']:
|
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
|
# if the mode changes from L2 to L3, the admin state
|
||||||
# seems to change after the API call, so adding a second API
|
# seems to change after the API call, so adding a second API
|
||||||
# call to ensure it's in the desired state.
|
# 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_interface.py
|
||||||
lib/ansible/modules/network/nxos/nxos_igmp_snooping.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_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.py
|
||||||
lib/ansible/modules/network/nxos/nxos_ntp_auth.py
|
lib/ansible/modules/network/nxos/nxos_ntp_auth.py
|
||||||
lib/ansible/modules/network/nxos/nxos_ntp_options.py
|
lib/ansible/modules/network/nxos/nxos_ntp_options.py
|
||||||
|
|
Loading…
Reference in a new issue