From 6999b1168f0c1a4cd074726fffdfae830e512af0 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Wed, 4 Oct 2017 12:09:25 +0530 Subject: [PATCH] Fixes #30769 - nxos_vtp_version errors out on N1 images. (#30770) (#31285) * Fixes #30769 * add the same fix for 2 more vtp modules (cherry picked from commit a12a05c2199422d671f756f3bcb4f632efd08aff) --- lib/ansible/modules/network/nxos/nxos_vtp_domain.py | 11 +++++++---- lib/ansible/modules/network/nxos/nxos_vtp_password.py | 11 +++++++---- lib/ansible/modules/network/nxos/nxos_vtp_version.py | 11 +++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py index 046cc8d5fcf..e6e1352e166 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py @@ -149,10 +149,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return "" diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_password.py b/lib/ansible/modules/network/nxos/nxos_vtp_password.py index 73f03967387..e21ed47c4c0 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_password.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_password.py @@ -180,10 +180,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return "" diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_version.py b/lib/ansible/modules/network/nxos/nxos_vtp_version.py index e4782eb7b51..33eeef07e94 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_version.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_version.py @@ -147,10 +147,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return ""