Add check for requests module

Fix adds check for requests Python module and suggests user to install,
if no requests module installation found.

Fixes: #27643

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2017-08-03 12:31:41 +05:30 committed by Toshio Kuratomi
parent 31b4ae2e6a
commit 748fa5db35
3 changed files with 25 additions and 3 deletions

View file

@ -103,9 +103,14 @@ EXAMPLES = '''
'''
import json
import requests
import urllib
try:
import requests
HAS_REQUESTS = True
except ImportError as e:
HAS_REQUESTS = False
from ansible.module_utils.basic import AnsibleModule
@ -127,6 +132,9 @@ def main():
supports_check_mode = True
)
if not HAS_REQUESTS:
module.fail_json(msg="requests library is required for this module. To install, use `pip install requests`")
if module.params['destination_type'] == "queue":
dest_type="q"
else: