mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Validate SSL certs accessed through urllib*
* Adds another module utility file which generalizes the access of urls via the urllib* libraries. * Adds a new spec generator for common arguments. * Makes the user-agent string configurable. Fixes #6211
This commit is contained in:
@@ -138,24 +138,13 @@ def main():
|
||||
while True:
|
||||
if time.time() > timeout:
|
||||
module.fail_json(msg='Timeout, could not fetch Riak stats.')
|
||||
try:
|
||||
if sys.version_info<(2,6,0):
|
||||
stats_raw = urllib2.urlopen(
|
||||
'http://%s/stats' % (http_conn), None).read()
|
||||
else:
|
||||
stats_raw = urllib2.urlopen(
|
||||
'http://%s/stats' % (http_conn), None, 5).read()
|
||||
(response, info) = fetch_url(module, 'http://%s/stats' % (http_conn), force=True, timeout=5)
|
||||
if info['status'] == 200:
|
||||
stats_raw = response.read()
|
||||
break
|
||||
except urllib2.HTTPError, e:
|
||||
time.sleep(5)
|
||||
except urllib2.URLError, e:
|
||||
time.sleep(5)
|
||||
except socket.timeout:
|
||||
time.sleep(5)
|
||||
except Exception, e:
|
||||
module.fail_json(msg='Could not fetch Riak stats: %s' % e)
|
||||
time.sleep(5)
|
||||
|
||||
# here we attempt to load those stats,
|
||||
# here we attempt to load those stats,
|
||||
try:
|
||||
stats = json.loads(stats_raw)
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user