self.refresh()
def refresh(self):
- resp, content = self.http.request("http://localhost:8080/controller/nb/v2/analytics/default/hoststats/" + self.src + "/" + self.dst, "GET")
+ resp, content = self.http.request("http://localhost:8080/affinity/nb/v2/analytics/default/hoststats/" + self.src + "/" + self.dst, "GET")
if (resp.status == 404):
return
if (resp.status == 503):
def __init__(self):
self.http = httplib2.Http(".cache")
self.http.add_credentials("admin", "admin")
+ self.url_prefix = "http://localhost:8080/controller/nb/v2/subnetservice/default/"
# Checks whether subnet exists. Checks against the actual subnet
# string (e.g., "10.0.0.255/1"), not the subnet name. Will not
# catch things like overlapping subnets.
def exists(self, subnet):
- resp, content = self.http.request("http://localhost:8080/controller/nb/v2/subnet/default/subnet/all", "GET")
+ resp, content = self.http.request(self.url_prefix + "subnets", "GET")
+ if (resp.status != 200):
+ print "Fatal error - can't check for subnet existence"
+ sys.exit(-1)
data = json.loads(content)
- for key in data:
- if (data[key]["subnet"] == subnet):
+
+ # TODO:
+ for key in data["subnetConfig"]:
+ print key["subnet"]
+ if (key["subnet"] == subnet):
return True
return False
return
subnet_config = dict(name=subnet_name, subnet=subnet)
json_data = json.dumps(subnet_config)
- resp, content = self.http.request("http://localhost:8080/controller/nb/v2/subnet/default/subnet/" + subnet_name, "POST", json_data, {'Content-Type': 'application/json'})
+ resp, content = self.http.request(self.url_prefix + "subnet/" + subnet_name, "POST", json_data, {'Content-Type': 'application/json'})
if (resp.status == 201):
print "subnet", subnet, "added"
else: