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:
parent
31b4ae2e6a
commit
748fa5db35
3 changed files with 25 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -105,7 +105,11 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import json
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError as e:
|
||||
HAS_REQUESTS = False
|
||||
import urllib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -137,6 +141,9 @@ def main():
|
|||
urllib.quote(module.params['name'],'')
|
||||
)
|
||||
|
||||
if not HAS_REQUESTS:
|
||||
module.fail_json(msg="requests library is required for this module. To install, use `pip install requests`")
|
||||
|
||||
# Check if exchange already exists
|
||||
r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))
|
||||
|
||||
|
|
|
@ -120,7 +120,11 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import json
|
||||
import requests
|
||||
try:
|
||||
import requests
|
||||
HAS_REQUESTS = True
|
||||
except ImportError as e:
|
||||
HAS_REQUESTS = False
|
||||
import urllib
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -155,6 +159,9 @@ def main():
|
|||
module.params['name']
|
||||
)
|
||||
|
||||
if not HAS_REQUESTS:
|
||||
module.fail_json(msg="requests library is required for this module. To install, use `pip install requests`")
|
||||
|
||||
# Check if queue already exists
|
||||
r = requests.get( url, auth=(module.params['login_user'],module.params['login_password']))
|
||||
|
||||
|
|
Loading…
Reference in a new issue