From a5885442180d50c18b6779acffab062d512a2a6b Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Mon, 21 Apr 2014 01:28:48 -0700 Subject: [PATCH] report allocated slivers in addition to active slivers --- planetstack/core/plus/views.py | 5 +++-- planetstack/hpc_wizard/planetstack_analytics.py | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) 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 @@ def getCDNOperatorData(randomizeData = False): 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 @@ def getCDNOperatorData(randomizeData = False): "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 @@ class PlanetStackAnalytics(BigQueryAnalytics): 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 @@ class PlanetStackAnalytics(BigQueryAnalytics): # 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 -- 2.43.0