Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: appengine/gce-backend/config.py

Issue 2705153007: Count configured minimum and maximum numbers of instances (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/gce-backend/metrics.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/gce-backend/config.py
diff --git a/appengine/gce-backend/config.py b/appengine/gce-backend/config.py
index a64883ac26024e752cac0cf4ca361c4a9bee60aa..cde35e0b21682eedf9f2961206a8c8fa24132628 100644
--- a/appengine/gce-backend/config.py
+++ b/appengine/gce-backend/config.py
@@ -65,6 +65,22 @@ class Configuration(datastore_utils.config.GlobalConfig):
return template_cfg, manager_cfg
+def count_instances():
+ """Counts the numbers of instances configured by each instance template.
+
+ Returns:
+ A dict mapping instance template name to a list of (min, max).
+ """
+ # Aggregate the numbers of instances configured in each instance group manager
+ # created for each instance template.
+ totals = collections.defaultdict(lambda: [0, 0])
+ _, manager_cfg = Configuration.load()
+ for manager in manager_cfg.managers:
+ totals[manager.template_base_name][0] += manager.minimum_size
+ totals[manager.template_base_name][1] += manager.maximum_size
+ return totals
+
+
def update_template_configs():
"""Updates the local template configuration from the config service.
« no previous file with comments | « no previous file | appengine/gce-backend/metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698