[MediaWiki-commits] [Gerrit] operations/puppet[production]: shinkengen: get role classes from puppet enc too

2016-10-20 Thread Andrew Bogott (Code Review)
Andrew Bogott has submitted this change and it was merged.

Change subject: shinkengen: get role classes from puppet enc too
..


shinkengen: get role classes from puppet enc too

Change-Id: I966f6422d218e5884c20712cb363703a501ba070
---
M modules/shinken/files/shinkengen
1 file changed, 13 insertions(+), 2 deletions(-)

Approvals:
  Andrew Bogott: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/shinken/files/shinkengen b/modules/shinken/files/shinkengen
index e9eee93..d3591e2 100755
--- a/modules/shinken/files/shinkengen
+++ b/modules/shinken/files/shinkengen
@@ -35,6 +35,7 @@
 import sys
 import yaml
 import ldap3
+import requests
 from collections import OrderedDict
 
 
@@ -101,10 +102,18 @@
 'region': hostinfo['l'][0],
 'puppetClasses': hostinfo.get('puppetClass', []),
 'project': project,
-'name': instancename
+'name': instancename,
+'fqdn': hostinfo['dc'][0]
 })
 
 return hosts
+
+def get_instance_roles(project, fqdn):
+url = 
'http://labcontrol1001.wikimedia.org:8100/v1/{project}/node/{fqdn}'.format(
+project,
+fqdn
+)
+return yaml.safe_load(requests.get(url).text)['roles']
 
 if __name__ == '__main__':
 argparser = argparse.ArgumentParser()
@@ -132,7 +141,9 @@
 # particular roles with checks.  role::labs::instance is
 # implicitly applied to all instances via
 # manifests/site.pp, so we need to add it here explicitly.
-co.properties['hostgroups'] = ','.join([project, 
'role::labs::instance'] + instance['puppetClasses'])
+hostgroups = [project, 'role::labs::instance'] + 
instance['puppetClasses']
+hostgroups += get_instance_roles(instance['project'], 
instance['fqdn'])
+co.properties['hostgroups'] = ','.join(hostgroups)
 # For each project added to monitoring we expect a contactgroup 
with the same
 # name added.
 # FIXME: Implement access mechanism more fine grained than 
per-project

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I966f6422d218e5884c20712cb363703a501ba070
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alex Monk 
Gerrit-Reviewer: Andrew Bogott 
Gerrit-Reviewer: Yuvipanda 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] operations/puppet[production]: shinkengen: get role classes from puppet enc too

2016-09-21 Thread Alex Monk (Code Review)
Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312109

Change subject: shinkengen: get role classes from puppet enc too
..

shinkengen: get role classes from puppet enc too

Change-Id: I966f6422d218e5884c20712cb363703a501ba070
---
M modules/shinken/files/shinkengen
1 file changed, 13 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/09/312109/1

diff --git a/modules/shinken/files/shinkengen b/modules/shinken/files/shinkengen
index e9eee93..d3591e2 100755
--- a/modules/shinken/files/shinkengen
+++ b/modules/shinken/files/shinkengen
@@ -35,6 +35,7 @@
 import sys
 import yaml
 import ldap3
+import requests
 from collections import OrderedDict
 
 
@@ -101,10 +102,18 @@
 'region': hostinfo['l'][0],
 'puppetClasses': hostinfo.get('puppetClass', []),
 'project': project,
-'name': instancename
+'name': instancename,
+'fqdn': hostinfo['dc'][0]
 })
 
 return hosts
+
+def get_instance_roles(project, fqdn):
+url = 
'http://labcontrol1001.wikimedia.org:8100/v1/{project}/node/{fqdn}'.format(
+project,
+fqdn
+)
+return yaml.safe_load(requests.get(url).text)['roles']
 
 if __name__ == '__main__':
 argparser = argparse.ArgumentParser()
@@ -132,7 +141,9 @@
 # particular roles with checks.  role::labs::instance is
 # implicitly applied to all instances via
 # manifests/site.pp, so we need to add it here explicitly.
-co.properties['hostgroups'] = ','.join([project, 
'role::labs::instance'] + instance['puppetClasses'])
+hostgroups = [project, 'role::labs::instance'] + 
instance['puppetClasses']
+hostgroups += get_instance_roles(instance['project'], 
instance['fqdn'])
+co.properties['hostgroups'] = ','.join(hostgroups)
 # For each project added to monitoring we expect a contactgroup 
with the same
 # name added.
 # FIXME: Implement access mechanism more fine grained than 
per-project

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I966f6422d218e5884c20712cb363703a501ba070
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alex Monk 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits