diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index e98da4b679..a199474e0a 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -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 diff --git a/lib/ansible/modules/network/nxos/nxos_linkagg.py b/lib/ansible/modules/network/nxos/nxos_linkagg.py index 2f962a0531..bf1df1d2a8 100644 --- a/lib/ansible/modules/network/nxos/nxos_linkagg.py +++ b/lib/ansible/modules/network/nxos/nxos_linkagg.py @@ -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()