* fix structured output for nxos_linkagg
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
* fix TypeError for nxos_interface
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 786ec14e54
)
This commit is contained in:
parent
58f018e367
commit
592c6877b5
2 changed files with 8 additions and 23 deletions
|
@ -267,7 +267,7 @@ def get_vlan_interface_attributes(name, intf_type, module):
|
|||
command = 'show run interface {0} all'.format(name)
|
||||
try:
|
||||
body = execute_show_command(command, module)[0]
|
||||
except IndexError:
|
||||
except (IndexError, TypeError):
|
||||
return None
|
||||
if body:
|
||||
command_list = body.split('\n')
|
||||
|
@ -504,7 +504,7 @@ def map_config_to_obj(want, module):
|
|||
if body:
|
||||
try:
|
||||
interface_table = body['TABLE_interface']['ROW_interface']
|
||||
except KeyError:
|
||||
except (KeyError, TypeError):
|
||||
return list()
|
||||
|
||||
if interface_table:
|
||||
|
@ -599,11 +599,12 @@ def check_declarative_intent_params(module, want):
|
|||
return
|
||||
|
||||
cmd = [{'command': 'show interface {0}'.format(w['name']), 'output': 'text'}]
|
||||
output = run_commands(module, cmd, check_rc=False)
|
||||
if output:
|
||||
out = output[0]
|
||||
else:
|
||||
|
||||
try:
|
||||
out = run_commands(module, cmd, check_rc=False)[0]
|
||||
except (AttributeError, IndexError, TypeError):
|
||||
out = ''
|
||||
|
||||
if want_tx_rate:
|
||||
match = re.search(r'output rate (\d+)', out, re.M)
|
||||
have_tx_rate = None
|
||||
|
|
|
@ -133,22 +133,6 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
|
||||
|
||||
def execute_show_command(command, module):
|
||||
device_info = get_capabilities(module)
|
||||
network_api = device_info.get('network_api', 'nxapi')
|
||||
|
||||
if network_api == 'cliconf':
|
||||
if 'show port-channel summary' in command:
|
||||
command += ' | json'
|
||||
cmds = [command]
|
||||
body = run_commands(module, cmds)
|
||||
elif network_api == 'nxapi':
|
||||
cmds = [command]
|
||||
body = run_commands(module, cmds)
|
||||
|
||||
return body
|
||||
|
||||
|
||||
def search_obj_in_list(group, lst):
|
||||
for o in lst:
|
||||
if o['group'] == group:
|
||||
|
@ -337,7 +321,7 @@ def parse_channel_options(module, output, channel):
|
|||
|
||||
def map_config_to_obj(module):
|
||||
objs = list()
|
||||
output = execute_show_command('show port-channel summary', module)[0]
|
||||
output = run_commands(module, ['show port-channel summary | json'])[0]
|
||||
if not output:
|
||||
return list()
|
||||
|
||||
|
|
Loading…
Reference in a new issue