X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FRetrieveSlicePersonKeys.py;h=0d55eb7145917db2e82a47816d75dadb63e36a90;hb=6e915d8a9ac5474c20482751ab6d24e6ce13aec9;hp=e851fe2b9617f23ec5e5c5b0cae56e74e4a20935;hpb=647e5fff4e77d6139637a483b3d74cee597060de;p=plcapi.git diff --git a/PLC/Methods/RetrieveSlicePersonKeys.py b/PLC/Methods/RetrieveSlicePersonKeys.py index e851fe2..0d55eb7 100644 --- a/PLC/Methods/RetrieveSlicePersonKeys.py +++ b/PLC/Methods/RetrieveSlicePersonKeys.py @@ -1,10 +1,8 @@ -from types import StringTypes - from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Filter import Filter from PLC.Auth import Auth -from PLC.Slices import Slice, Slices +from PLC.Slices import Slice, Slices from PLC.Persons import Person, Persons from PLC.Keys import Key, Keys from functools import reduce @@ -14,7 +12,7 @@ class RetrieveSlicePersonKeys(Method): This method exposes the public ssh keys for people in a slice It expects a slice name or id, and returns a dictionary on emails. This method is designed to help third-party software authenticate - users (e.g. the OMF Experiment Controller). + users (e.g. the OMF Experiment Controller). For this reason it is accessible with anonymous authentication. """ @@ -41,7 +39,7 @@ class RetrieveSlicePersonKeys(Method): # the people in the slice slice=Slices (self.api, slice_id_or_name, ['person_ids'])[0] slice_person_ids = slice['person_ids'] - + # if caller has not specified person_id, use slice_person_ids if 'person_id' not in person_filter: person_filter['person_id']=slice_person_ids @@ -51,17 +49,17 @@ class RetrieveSlicePersonKeys(Method): if not isinstance (caller_provided,list): caller_provided = [ caller_provided, ] person_filter['person_id'] = list ( set(caller_provided).intersection(slice_person_ids) ) - + def merge (l1,l2): return l1+l2 persons = Persons (self.api, person_filter, ['email','key_ids'] ) key_id_to_email_hash = \ - dict ( reduce ( merge , [ [ (kid,p['email']) for kid in p['key_ids']] for p in persons ] ) ) - + dict ( reduce ( merge , [ [ (kid,p['email']) for kid in p['key_ids']] for p in persons ] ) ) + all_key_ids = reduce (merge, [ p['key_ids'] for p in persons ] ) all_keys = Keys (self.api, all_key_ids) - + result={} for key in all_keys: key_id=key['key_id']