summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2018-05-30 15:31:16 +0530
committerGitHub <noreply@github.com>2018-05-30 15:31:16 +0530
commit786ec14e5412ba7276e76b71cf42ed5d591c74e9 (patch)
tree5ceb7ae8c446ad0a1e27ac8d3beeeddc032500a0
parent8ece8679d84f4caf247ae5bf23c112d0dd752ad8 (diff)
downloadansible-786ec14e5412ba7276e76b71cf42ed5d591c74e9.tar.gz
fix nxos dci failures (#40871)
* 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>
-rw-r--r--lib/ansible/modules/network/nxos/nxos_interface.py13
-rw-r--r--lib/ansible/modules/network/nxos/nxos_linkagg.py18
2 files changed, 8 insertions, 23 deletions
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()