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
19 def pg_users_arg(records):
21 for record in records:
22 if record['type'] != 'user':
24 user = {'urn': record['reg-urn'],
25 'keys': record['reg-keys'],
26 'email': record['email']}
31 def sfa_users_arg(records, slice_record):
33 for record in records:
34 if record['type'] != 'user':
36 user = {'urn': record['reg-urn'],
37 'keys': record['reg-keys'],
38 'slice_record': slice_record,
40 # fill as much stuff as possible from planetlab or similar
41 # note that reg-email is not yet available
42 pl_fields = ['email', 'person_id',
43 'first_name', 'last_name', 'key_ids']
44 nitos_fields = ['email', 'user_id']
45 extra_fields = list(set(pl_fields).union(set(nitos_fields)))
46 # try to fill all these in
47 for field in extra_fields:
49 user[field] = record[field]
55 def sfa_to_pg_users_arg(users):
58 fields = ['urn', 'keys']
60 new_user = dict([item for item in user.items()
61 if item[0] in fields])
62 new_users.append(new_user)