X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.py;h=3ef546ec9df6f69e312f0a760040ece297143334;hb=refs%2Ftags%2FMonitor-1.0-12;hp=783efbc744634df1b9b2a1286861f98fa8bd9546;hpb=5b7ebb918bb8c5c26c34219bf1d32e7c44505110;p=monitor.git diff --git a/plc.py b/plc.py index 783efbc..3ef546e 100644 --- a/plc.py +++ b/plc.py @@ -67,6 +67,50 @@ def getAPI(url): def getAuthAPI(): return PLC(auth.auth, auth.server) + +def getTechEmails(loginbase): + """ + For the given site, return all user email addresses that have the 'tech' role. + """ + api = getAuthAPI() + # get site details. + s = api.GetSites(loginbase)[0] + # get people at site + p = api.GetPersons(s['person_ids']) + # pull out those with the right role. + emails = [ person['email'] for person in filter(lambda x: 'tech' in x['roles'], p) ] + return emails + +def getPIEmails(loginbase): + """ + For the given site, return all user email addresses that have the 'tech' role. + """ + api = getAuthAPI() + # get site details. + s = api.GetSites(loginbase)[0] + # get people at site + p = api.GetPersons(s['person_ids']) + # pull out those with the right role. + emails = [ person['email'] for person in filter(lambda x: 'pi' in x['roles'], p) ] + return emails + +def getSliceUserEmails(loginbase): + """ + For the given site, return all user email addresses that have the 'tech' role. + """ + #api = getAuthAPI() + # get site details. + s = api.GetSites(loginbase)[0] + # get people at site + slices = api.GetSlices(s['slice_ids']) + people = [] + for slice in slices: + people += api.GetPersons(slice['person_ids']) + # pull out those with the right role. + emails = [ person['email'] for person in filter(lambda x: 'pi' in x['roles'], people) ] + unique_emails = [ x for x in set(emails) ] + return unique_emails + ''' Returns list of nodes in dbg as reported by PLC ''' @@ -138,6 +182,7 @@ def getSiteNodes(loginbase, fields=None): print "getSiteNodes: %s" % exc return nodelist + def getPersons(filter=None, fields=None): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) persons = []