huge cleanup for removing mutables used as default
[sfa.git] / sfa / iotlab / iotlabslices.py
index c441d65..966a26b 100644 (file)
@@ -221,7 +221,9 @@ class IotlabSlices:
         #Deleted leases are the ones with lease id not declared in the Rspec
         if deleted_leases:
             self.driver.testbed_shell.DeleteLeases(deleted_leases,
-                                                sfa_slice['user']['uid'])
+                                                sfa_slice['login'])
+            #self.driver.testbed_shell.DeleteLeases(deleted_leases,
+            #                                    sfa_slice['user']['uid'])
             logger.debug("IOTLABSLICES \
                           verify_slice_leases slice %s deleted_leases %s"
                          % (sfa_slice, deleted_leases))
@@ -334,8 +336,8 @@ class IotlabSlices:
                          'authority': slice_record['authority'],
                          'gid': slice_record['gid'],
                          'slice_id': slice_record['record_id'],
-                         'reg-researchers': slice_record['reg-researchers'],
-                         'peer_authority': str(sfa_peer)
+                         #'reg-researchers': slice_record['reg-researchers'],
+                         #'peer_authority': str(sfa_peer)
                          }
 
             if ldap_user:
@@ -354,7 +356,7 @@ class IotlabSlices:
         return sfa_slice
 
 
-    def verify_persons(self, slice_hrn, slice_record, users, options={}):
+    def verify_persons(self, slice_hrn, slice_record, users, options=None):
         """Ensures the users in users list exist and are enabled in LDAP. Adds
         person if needed (AddPerson).
 
@@ -380,7 +382,7 @@ class IotlabSlices:
 
 
         """
-
+        if options is None: options={}
         logger.debug("IOTLABSLICES \tverify_persons \tslice_hrn  %s  \
                     \t slice_record %s\r\n users %s \t  "
                      % (slice_hrn, slice_record, users))
@@ -456,20 +458,20 @@ class IotlabSlices:
                                 ldap_reslt %s " % (users, ldap_reslt))
 
         requested_user_emails = users_by_email.keys()
-        requested_user_hrns = \
-            [users_by_email[user]['hrn'] for user in users_by_email]
-        logger.debug("IOTLABSLICES.PY \tverify_person  \
-                       users_by_email  %s " % (users_by_email))
+        requested_user_hrns = \
+            [users_by_email[user]['hrn'] for user in users_by_email]
+        logger.debug("IOTLABSLICES.PY \tverify_person  \
+                       users_by_email  %s " % (users_by_email))
 
-        #Check that the user of the slice in the slice record
-        #matches one of the existing users
-        try:
-            if slice_record['reg-researchers'][0] in requested_user_hrns:
-                logger.debug(" IOTLABSLICES  \tverify_person ['PI']\
-                                slice_record %s" % (slice_record))
+        # #Check that the user of the slice in the slice record
+        # #matches one of the existing users
+        try:
+            if slice_record['reg-researchers'][0] in requested_user_hrns:
+                logger.debug(" IOTLABSLICES  \tverify_person ['PI']\
+                                slice_record %s" % (slice_record))
 
-        except KeyError:
-            pass
+        except KeyError:
+            pass
 
         # users to be added, removed or updated
         #One user in one iotlab slice : there should be no need
@@ -501,13 +503,14 @@ class IotlabSlices:
             for k in k_list:
                 if k in added_user:
                     person[k] = added_user[k]
-
-            person['pkey'] = added_user['keys'][0]
+            # bug user without key
+            if added_user['keys']:
+                person['pkey'] = added_user['keys'][0]
             person['mail'] = added_user['email']
             person['email'] = added_user['email']
             person['key_ids'] = added_user.get('key_ids', [])
 
-            ret = self.driver.testbed_shell.AddPerson(person)
+            ret = self.driver.AddPerson(person)
             if 'uid' in ret:
                 # meaning bool is True and the AddPerson was successful
                 person['uid'] = ret['uid']
@@ -525,10 +528,11 @@ class IotlabSlices:
         return added_persons
 
 
-    def verify_keys(self, persons, users, peer, options={}):
+    def verify_keys(self, persons, users, peer, options=None):
         """
         .. warning:: unused
         """
+        if options is None: options={}
         # existing keys
         key_ids = []
         for person in persons: