3 # Thierry - 2012 sept 21
5 # it seems terribly wrong that the client should decide to use PG- or PL- related code
6 # esp. in a context where we're trying to have more and more kinds of testbeds involved
8 # also, the 'users' field that CreateSliver is expecting (the key point here is to get this right)
9 # is specified to have at least a urn and a list of keys, both of these being supported natively
11 # So long story short, it seems to me that we should have a common code that fills in 'urn' and 'keys'
12 # and then code that tentatively tries to add as much extra info that we can get on these users
14 # the fact e.g. that PlanetLab insists on getting a first_name and last_name is not
15 # exactly consistent with the GENI spec. of CreateSliver
17 def pg_users_arg(records):
19 for record in records:
20 if record['type'] != 'user':
22 user = {'urn': record['reg-urn'],
23 'keys': record['reg-keys'],
24 'email': record['email']}
28 def sfa_users_arg (records, slice_record):
30 for record in records:
31 if record['type'] != 'user':
33 user = {'urn': record['reg-urn'],
34 'keys': record['reg-keys'],
35 'slice_record': slice_record,
37 # fill as much stuff as possible from planetlab or similar
38 # note that reg-email is not yet available
39 pl_fields = ['email', 'person_id', 'first_name', 'last_name', 'key_ids']
40 nitos_fields = [ 'email', 'user_id' ]
41 extra_fields = list ( set(pl_fields).union(set(nitos_fields)))
42 # try to fill all these in
43 for field in extra_fields:
44 if record.has_key(field): user[field]=record[field]
49 def sfa_to_pg_users_arg(users):
52 fields = ['urn', 'keys']
54 new_user = dict([item for item in user.items() \
55 if item[0] in fields])
56 new_users.append(new_user)