From a12a05c2199422d671f756f3bcb4f632efd08aff Mon Sep 17 00:00:00 2001 From: rahushen Date: Tue, 3 Oct 2017 07:54:14 -0400 Subject: [PATCH] Fixes #30769 - nxos_vtp_version errors out on N1 images. (#30770) * Fixes #30769 * add the same fix for 2 more vtp modules --- 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 046cc8d5fc..e6e1352e16 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 73f0396738..e21ed47c4c 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 e4782eb7b5..33eeef07e9 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 ""