X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fclient_helper.py;h=809831942035d720f36d4e11bc69f983dde0c4ea;hb=4a9e6751f9f396f463932133b9d62fc925a99ef6;hp=2117b146508d9041453abd22645270230b8b9bc2;hpb=cf802a4f0250de22a6f38f1ee97a89e86bfc1128;p=sfa.git diff --git a/sfa/client/client_helper.py b/sfa/client/client_helper.py index 2117b146..80983194 100644 --- a/sfa/client/client_helper.py +++ b/sfa/client/client_helper.py @@ -5,7 +5,7 @@ # 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) +# also, the 'users' field 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' @@ -14,21 +14,24 @@ # 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 = [] + users = [] for record in records: - if record['type'] != 'user': + if record['type'] != 'user': continue user = {'urn': record['reg-urn'], 'keys': record['reg-keys'], - } + 'email': record['email']} users.append(user) - return users + return users + -def sfa_users_arg (records, slice_record): +def sfa_users_arg(records, slice_record): users = [] for record in records: - if record['type'] != 'user': + if record['type'] != 'user': continue user = {'urn': record['reg-urn'], 'keys': record['reg-keys'], @@ -36,22 +39,23 @@ def sfa_users_arg (records, 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))) + pl_fields = ['email', 'person_id', + 'first_name', 'last_name', 'key_ids'] # try to fill all these in - for field in extra_fields: - if record.has_key(field): user[field]=record[field] + for field in pl_fields: + if field in record: + user[field] = record[field] users.append(user) return users + def sfa_to_pg_users_arg(users): new_users = [] fields = ['urn', 'keys'] for user in users: - new_user = dict([item for item in user.items() \ - if item[0] in fields]) + new_user = dict([item for item in list(user.items()) + if item[0] in fields]) new_users.append(new_user) - return new_users + return new_users