report allocated slivers in addition to active slivers
diff --git a/planetstack/core/plus/views.py b/planetstack/core/plus/views.py
index d4cc56b..38a7a96 100644
--- a/planetstack/core/plus/views.py
+++ b/planetstack/core/plus/views.py
@@ -212,7 +212,7 @@
rows = bq.postprocess_results(rows, filter={"slice": "HyperCache"}, maxi=["cpu"], count=["hostname"], computed=["bytes_sent/elapsed"], groupBy=["Time","site"], maxDeltaTime=80)
- bq.merge_datamodel_sites(rows)
+ bq.merge_datamodel_sites(rows, slice="HyperCache")
new_rows = {}
for row in rows:
@@ -220,7 +220,8 @@
"long": float(row.get("long", 0)),
"health": 0,
"numNodes": int(row.get("numNodes",0)),
- "numHPCSlivers": int(row.get("count_hostname", 0)),
+ "activeHPCSlivers": int(row.get("count_hostname", 0)),
+ "numHPCSlivers": int(row.get("allocated_slivers", 0)),
"siteUrl": str(row.get("url", "")),
"hot": float(row.get("hotness", 0.0)),
"bandwidth": row.get("sum_computed_bytes_sent_div_elapsed",0),
diff --git a/planetstack/hpc_wizard/planetstack_analytics.py b/planetstack/hpc_wizard/planetstack_analytics.py
index 7e0d1b6..5287e2f 100644
--- a/planetstack/hpc_wizard/planetstack_analytics.py
+++ b/planetstack/hpc_wizard/planetstack_analytics.py
@@ -196,10 +196,17 @@
return ("text/html", new_result)
- def merge_datamodel_sites(self, rows):
+ def merge_datamodel_sites(self, rows, slice=None):
""" For a query that included "site" in its groupby, merge in the
opencloud site information.
"""
+
+ if slice:
+ try:
+ slice = Slice.objects.get(name=slice)
+ except:
+ slice = None
+
for row in rows:
sitename = row["site"]
try:
@@ -208,10 +215,17 @@
# we didn't find it in the data model
continue
+ allocated_slivers = 0
+ if model_site and slice:
+ for sliver in slice.slivers.all():
+ if sliver.node.site == model_site:
+ allocated_slivers = allocated_slivers + 1
+
row["lat"] = float(model_site.location.latitude)
row["long"] = float(model_site.location.longitude)
row["url"] = model_site.site_url
row["numNodes"] = model_site.nodes.count()
+ row["allocated_slivers"] = allocated_slivers
max_cpu = row.get("max_avg_cpu", row.get("max_cpu",0))
cpu=float(max_cpu)/100.0