From 03fadf3b435b05975b5d3aec028ee92511fd5a13 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Tue, 11 Aug 2020 14:17:25 +0300 Subject: [PATCH] Fix non existing attribuites in SDK exception SDK exception may not have extra_data, details or response attributes. Print None in this case. Change-Id: Ic4073c28a4e4afb8ca5d2b72c4ea8582da244af1 --- plugins/module_utils/openstack.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/module_utils/openstack.py b/plugins/module_utils/openstack.py index 0b618485..3172c873 100644 --- a/plugins/module_utils/openstack.py +++ b/plugins/module_utils/openstack.py @@ -392,9 +392,10 @@ class OpenStackModule: params = { 'msg': str(e), 'extra_data': { - 'data': e.extra_data, - 'details': e.details, - 'response': e.response.text + 'data': getattr(e, 'extra_data', 'None'), + 'details': getattr(e, 'details', 'None'), + 'response': getattr(getattr(e, 'response', ''), + 'text', 'None') } } self.ansible.fail_json(**params)