X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fclient_helper.py;h=48160a4903ec4df53adf12c6e31ffc96de7a3d6f;hb=1cc8e9613cab8b5b22478de369f259e591c54e6d;hp=b33911fe762c6ce36da76f38746000244e4e74a8;hpb=b8596ce95578bf77158db2a5dacbaab36bdf6b16;p=sfa.git diff --git a/sfa/client/client_helper.py b/sfa/client/client_helper.py index b33911fe..48160a49 100644 --- a/sfa/client/client_helper.py +++ b/sfa/client/client_helper.py @@ -1,36 +1,50 @@ -import sys +### +# +# Thierry - 2012 sept 21 +# +# it seems terribly wrong that the client should decide to use PG- or PL- related code +# esp. in a context where we're trying to have more and more kinds of testbeds involved +# +# also, the 'users' filed that CreateSliver is expecting (the key point here is to get this right) +# is specified to have at least a urn and a list of keys, both of these being supported natively +# in the sfa db +# So long story short, it seems to me that we should have a common code that fills in 'urn' and 'keys' +# and then code that tentatively tries to add as much extra info that we can get on these users +# +# the fact e.g. that PlanetLab insists on getting a first_name and last_name is not +# exactly consistent with the GENI spec. of CreateSliver +# def pg_users_arg(records): users = [] for record in records: if record['type'] != 'user': continue user = {'urn': record['geni_urn'], - 'keys': record['keys']} + 'keys': record['keys'], + 'email': record['email']} users.append(user) return users -def sfa_users_arg(records, slice_record): +def sfa_users_arg (records, slice_record): users = [] - print>>sys.stderr, " \r\n \r\n \t CLIENT_HELPER.PY sfa_users_arg slice_record %s \r\n records %s"%(slice_record,records) for record in records: if record['type'] != 'user': continue - user = {#'urn': record['geni_urn'], - #'keys': record['keys'], - #'email': record['email'], # needed for MyPLC - 'person_id': record['record_id'], - 'hrn': record['hrn'], - 'type': record['type'], - 'authority' : record['authority'], - 'gid' : record['gid'], - #'first_name': record['first_name'], # needed for MyPLC - #'last_name': record['last_name'], # needed for MyPLC - 'slice_record': slice_record, # needed for legacy refresh peer - #'key_ids': record['key_ids'] # needed for legacy refresh peer - } - users.append(user) - print>>sys.stderr, " \r\n \r\n \t CLIENT_HELPER.PY sfa_users_arg user %s",user - return users + user = {'urn': record['reg-urn'], + 'keys': record['reg-keys'], + 'slice_record': slice_record, + } + # fill as much stuff as possible from planetlab or similar + # note that reg-email is not yet available + pl_fields = ['email', 'person_id', 'first_name', 'last_name', 'key_ids'] + nitos_fields = [ 'email', 'user_id' ] + extra_fields = list ( set(pl_fields).union(set(nitos_fields))) + # try to fill all these in + for field in extra_fields: + if record.has_key(field): user[field]=record[field] + users.append(user) + + return users def sfa_to_pg_users_arg(users):