summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Martin <jmartin@basho.com>2013-09-05 16:40:36 -0400
committerJames Martin <jmartin@basho.com>2013-09-06 13:42:27 -0400
commit8c1ed028d34ad6f341e374b992a1f9f8839f18fd (patch)
tree54e506113c8f76866dd50073094fe2d5dc66f6c2
parent441062f061c026134db1d72a52ed77e6ab89dded (diff)
downloadansible-8c1ed028d34ad6f341e374b992a1f9f8839f18fd.tar.gz
Fixes for python 2.4 support, better collection of riak version.
-rw-r--r--library/database/riak25
1 files changed, 13 insertions, 12 deletions
diff --git a/library/database/riak b/library/database/riak
index 38d07ba36a..68a58e6a11 100644
--- a/library/database/riak
+++ b/library/database/riak
@@ -87,9 +87,14 @@ EXAMPLES = '''
'''
import urllib2
-import json
import time
import socket
+import sys
+try:
+ import json
+except ImportError:
+ import simplejson as json
+
def ring_check(module, riak_admin_bin):
cmd = '%s ringready 2> /dev/null' % riak_admin_bin
@@ -129,21 +134,17 @@ def main():
riak_bin = module.get_bin_path('riak')
riak_admin_bin = module.get_bin_path('riak-admin')
- cmd = "%s version 2> /dev/null |grep ^riak|cut -f2 -d' '|tr -d '('" % riak_bin
- rc, out, err = module.run_command(cmd)
- if rc == 0:
- version = out.strip()
- else:
- module.fail_json(msg='Could not determine Riak version')
-
-# here we attempt to get stats from the http stats interface for 120 seconds.
timeout = time.time() + 120
while True:
if time.time() > timeout:
module.fail_json(msg='Timeout, could not fetch Riak stats.')
try:
- stats_raw = urllib2.urlopen(
- 'http://%s/stats' % (http_conn), None, 5).read()
+ 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()
break
except urllib2.HTTPError, e:
time.sleep(5)
@@ -163,7 +164,7 @@ def main():
node_name = stats['nodename']
nodes = stats['ring_members']
ring_size = stats['ring_creation_size']
-
+ version = stats['riak_core_version']
result = dict(node_name=node_name,
nodes=nodes,