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:
James Cammarata
2014-03-10 16:06:52 -05:00
parent c920f78cc3
commit 5bc6eafba5
23 changed files with 598 additions and 402 deletions

View File

@@ -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: