Change-Id: Iddd0dfb7ec44a89c00f3f481a5576459b113077e
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
+def rest_get(restURL, username, password):
rest_buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.TIMEOUT, 2)
rest_buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.TIMEOUT, 2)
c.setopt(c.URL, str(restURL))
c.setopt(c.HTTPGET, 0)
c.setopt(c.WRITEFUNCTION, rest_buffer.write)
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())
c.perform()
c.close()
return json.loads(rest_buffer.getvalue())
url += 'Category=Shards,name=' + names[i]
url += '-shard-' + shardName + '-config,type=DistributedConfigDatastore'
try:
url += 'Category=Shards,name=' + names[i]
url += '-shard-' + shardName + '-config,type=DistributedConfigDatastore'
try:
+ resp = rest_get(url, username, password)
if resp['status'] != 200:
controller_state[controller["ip"]] = 'HTTP ' + str(resp['status'])
if 'value' in resp:
if resp['status'] != 200:
controller_state[controller["ip"]] = 'HTTP ' + str(resp['status'])
if 'value' in resp:
try:
controllers = data["cluster"]["controllers"]
shards_to_exclude = data["cluster"]["shards_to_exclude"]
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'
except:
print str(sys.exc_info())
print 'Error reading the file cluster.json'
for controller in controllers:
url = "http://" + controller["ip"] + ":" + controller["port"] + "/jolokia/read/org.opendaylight.controller:"
url += "Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore"
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)
+ data = rest_get(url, username, password)
- 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)
print 'Are all controllers up?'
print str(sys.exc_info()[1])
exit(1)