Ottomata has submitted this change and it was merged.

Change subject: mod. use get_project_host_map method to generate map for 
project to host key.
......................................................................


mod. use get_project_host_map method to generate map for project to host key.

Change-Id: Ifd2d33d2b1014856571ad4ea43294d1f5f7b9381
---
M templates/misc/e3-metrics.settings.py.erb
1 file changed, 17 insertions(+), 6 deletions(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved



diff --git a/templates/misc/e3-metrics.settings.py.erb 
b/templates/misc/e3-metrics.settings.py.erb
index cc8f07f..f200284 100644
--- a/templates/misc/e3-metrics.settings.py.erb
+++ b/templates/misc/e3-metrics.settings.py.erb
@@ -50,10 +50,21 @@
 <% end # mysql_connections..each -%>
 }
 
-PROJECT_DB_MAP = {
-    'enwiki': 's1',
-    'dewiki': 's5',
-    'itwiki': 's2',
-    'commonswiki': 's4',
-}
+def get_project_host_map(usecache=True):
+    cache_name = 'project_host_map.json'
+    if not exists(cache_name) or not usecache:
+       cluster_url_fmt = 'http://noc.wikimedia.org/conf/s%d.dblist'
+        host_fmt = 's%d'
+        project_host_map = {}
+        for i in range(1,8):
+            host = host_fmt % i
+            url = cluster_url_fmt % i
+            projects = urlopen(url).read().splitlines()
+            for project in projects:
+                project_host_map[project] = host
+        json.dump(project_host_map, open(cache_name, 'w'))
+    else:
+        project_host_map = json.load(open(cache_name))
+    return project_host_map
 
+PROJECT_DB_MAP = get_project_host_map()

-- 
To view, visit https://gerrit.wikimedia.org/r/56576
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifd2d33d2b1014856571ad4ea43294d1f5f7b9381
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rfaulk <[email protected]>
Gerrit-Reviewer: Jeremyb <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to