From c066a60b7c48c9a31b51834d49bccfd0b00dd2e5 Mon Sep 17 00:00:00 2001 From: Rene Moser Date: Thu, 26 Mar 2015 15:32:58 +0100 Subject: [PATCH] cloudstack: fail_json() if library cs is not found --- lib/ansible/module_utils/cloudstack.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_utils/cloudstack.py b/lib/ansible/module_utils/cloudstack.py index cb482ae993..ab72f2c789 100644 --- a/lib/ansible/module_utils/cloudstack.py +++ b/lib/ansible/module_utils/cloudstack.py @@ -17,19 +17,20 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -import sys try: from cs import CloudStack, CloudStackException, read_config + has_lib_cs = True except ImportError: - print("failed=True " + \ - "msg='python library cs required: pip install cs'") - sys.exit(1) + has_lib_cs = False class AnsibleCloudStack: def __init__(self, module): + if not has_lib_cs: + module.fail_json(msg="python library cs required: pip install cs") + self.module = module self._connect()