sfi is more flexible when putting together the 'users' arg for CreateSliver
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 21 Sep 2012 16:48:14 +0000 (18:48 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 21 Sep 2012 16:48:14 +0000 (18:48 +0200)
sfa/client/client_helper.py

index d25873f..2117b14 100644 (file)
@@ -1,11 +1,27 @@
-
+###
+#
+# 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['urn'],
-                'keys': record['keys']}
+        user = {'urn': record['reg-urn'],
+                'keys': record['reg-keys'],
+                }
         users.append(user)
     return users    
 
@@ -14,26 +30,18 @@ def sfa_users_arg (records, slice_record):
     for record in records:
         if record['type'] != 'user': 
             continue
-        try:
-            user = {'urn': record['urn'], #
-# all right, so this is sooo totally wrong
-#                    'keys': record['keys'],
-#                    'email': record['email'], # needed for MyPLC
-#                    'person_id': record['person_id'], # needed for MyPLC
-#                    '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
-                    }
-        except:
-            # handle NITOS user args
-            user = {'urn': record['urn'], 
-                    'keys': record['keys'],
-                    'email': record['email'], 
-                    'user_id': record['user_id'], 
-                    'slice_record': slice_record,
-                    }
-            
+        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