X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tools%2Fclustering%2Fcluster-monitor%2Fmonitor.py;h=d708ea7252f054b288dfd357c0d4f3fbacb0738e;hb=d87161ca380651f74b05606741d948200f708705;hp=c9fb3ee5d7dd59198f4ff27637d5fd0c826c76e9;hpb=241920acc7e834f9db75e3f068f17df35ce594e6;p=integration%2Ftest.git diff --git a/tools/clustering/cluster-monitor/monitor.py b/tools/clustering/cluster-monitor/monitor.py index c9fb3ee5d7..d708ea7252 100644 --- a/tools/clustering/cluster-monitor/monitor.py +++ b/tools/clustering/cluster-monitor/monitor.py @@ -37,7 +37,7 @@ import pycurl import string -def rest_get(restURL): +def rest_get(restURL, username, password): rest_buffer = BytesIO() c = pycurl.Curl() c.setopt(c.TIMEOUT, 2) @@ -46,6 +46,7 @@ def rest_get(restURL): c.setopt(c.URL, str(restURL)) c.setopt(c.HTTPGET, 0) c.setopt(c.WRITEFUNCTION, rest_buffer.write) + c.setopt(pycurl.USERPWD, "%s:%s" % (str(username), str(password))) c.perform() c.close() return json.loads(rest_buffer.getvalue()) @@ -61,7 +62,7 @@ def getClusterRolesWithCurl(shardName, *args): url += 'Category=Shards,name=' + names[i] url += '-shard-' + shardName + '-config,type=DistributedConfigDatastore' try: - resp = rest_get(url) + resp = rest_get(url, username, password) if resp['status'] != 200: controller_state[controller["ip"]] = 'HTTP ' + str(resp['status']) if 'value' in resp: @@ -103,6 +104,8 @@ except: try: controllers = data["cluster"]["controllers"] shards_to_exclude = data["cluster"]["shards_to_exclude"] + username = data["cluster"]["user"] + password = data["cluster"]["pass"] except: print str(sys.exc_info()) print 'Error reading the file cluster.json' @@ -114,10 +117,11 @@ Shards = set() for controller in controllers: url = "http://" + controller["ip"] + ":" + controller["port"] + "/jolokia/read/org.opendaylight.controller:" url += "Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore" + rest_get(url, username, password) try: - data = rest_get(url) + data = rest_get(url, username, password) except: - print 'Unable to retrieve shard names from ' + controller + print 'Unable to retrieve shard names from ' + str(controller) print 'Are all controllers up?' print str(sys.exc_info()[1]) exit(1)