[CHANGE REQUEST] Update country-code script on bapp01

Toshio Kuratomi toshio at tiki-lounge.com
Tue Feb 28 17:01:19 UTC 2012


On bapp01 we have a script that checks whether the country code that people have
in FAS is known to GeoIP.  This script runs once a week.  The script sends out
email if the country code is not known to GeoIP (this happens if we update GeoIP
and a previous country code is removed).

I'd like to update this script in puppet so that it doesn't notify inactive
accounts as we're currently sending out nagmail to accounts which are no longer
used (but may point to valid email addresses):

diff --git a/modules/fas/files/fas-invalid-cc.py
b/modules/fas/files/fas-invalid-cc.py
index 2e7d309..186049a 100755
--- a/modules/fas/files/fas-invalid-cc.py
+++ b/modules/fas/files/fas-invalid-cc.py
@@ -86,14 +86,14 @@ def getusers():
   country_codes = GeoIP.country_codes
 
   data = []
-  data = fas.people_by_key(key='id', fields=['human_name', 'username',
'country_code', 'email'])
+  data = fas.people_by_key(key='id', fields=['human_name', 'username',
'country_code', 'email', 'status'])
   
   if not email: 
 
     print '\nSummary of accounts without valid Country Codes.'
     print '\n------------------------------------------------'
 
-  for user_info in data.values():
+  for user_info in [d for d in data.itervalues() if d['status'] == 'active']:
     if user_info['country_code'] and user_info['country_code'] not in
country_codes:
       if email:



Could I get two +1s?

-Toshio



More information about the infrastructure mailing list