def __init__(self, stat_type, **kwargs):
self.stat_type = stat_type
def __init__(self, stat_type, **kwargs):
self.stat_type = stat_type
self.subnet = kwargs['subnet']
self.url_prefix = "http://localhost:8080/affinity/nb/v2/analytics/default/prefixstats/"
else:
self.subnet = kwargs['subnet']
self.url_prefix = "http://localhost:8080/affinity/nb/v2/analytics/default/prefixstats/"
else:
- elif (self.stat_type == "affinityLink"):
- return "AffinityLink %s" % self.al
- elif (self.stat_type == "prefix"):
- return "Prefix %s" % self.subnet
+ elif (self.stat_type == Stats.TYPE_AL):
+ return "affinity link %s" % self.al
+ elif (self.stat_type == Stats.TYPE_PREFIX):
+ return "prefix %s" % self.subnet
resp, content = self.http.request(self.url_prefix + self.subnet, "GET")
try:
self.stats = json.loads(content)
resp, content = self.http.request(self.url_prefix + self.subnet, "GET")
try:
self.stats = json.loads(content)
# Return hosts that transferred data into this entity. Right now only supports prefixes.
def get_incoming_hosts(self):
# Return hosts that transferred data into this entity. Right now only supports prefixes.
def get_incoming_hosts(self):
resp, content = self.http.request(self.url_prefix + "incoming/" + self.subnet, "GET")
data = json.loads(content)
if (data != {}):
# IPs sometimes (always?) get returned as strings like /1.2.3.4; strip off the leading /
ips = [h.replace("/", "") for h in data['hosts']]
return ips
resp, content = self.http.request(self.url_prefix + "incoming/" + self.subnet, "GET")
data = json.loads(content)
if (data != {}):
# IPs sometimes (always?) get returned as strings like /1.2.3.4; strip off the leading /
ips = [h.replace("/", "") for h in data['hosts']]
return ips