Fixing small mistake in GetLeases.
[sfa.git] / sfa / iotlab / iotlabslices.py
index f44575c..7722bf0 100644 (file)
@@ -108,7 +108,7 @@ class IotlabSlices:
         logger.debug("IOTLABSLICES verify_slice_leases sfa_slice %s "
                      % (sfa_slice))
         #First get the list of current leases from OAR
-        leases = self.driver.iotlab_api.GetLeases({'name': sfa_slice['hrn']})
+        leases = self.driver.iotlab_api.GetLeases({'slice_hrn': sfa_slice['hrn']})
         logger.debug("IOTLABSLICES verify_slice_leases requested_jobs_dict %s \
                         leases %s " % (requested_jobs_dict, leases))
 
@@ -130,6 +130,9 @@ class IotlabSlices:
 
         #First remove job whose duration is too short
         for job in requested_jobs_dict.values():
+            job['duration'] = \
+                str(int(job['duration']) \
+                * self.driver.iotlab_api.GetLeaseGranularity())
             if job['duration'] < self.driver.iotlab_api.GetLeaseGranularity():
                 del requested_jobs_dict[job['start_time']]
 
@@ -350,7 +353,7 @@ class IotlabSlices:
 
         Checking that a user exist is based on the user's email. If the user is
         still not found in the LDAP, it means that the user comes from another
-        federated. In this case an account has to be created in LDAP
+        federated testbed. In this case an account has to be created in LDAP
         so as to enable the user to use the testbed, since we trust the testbed
         he comes from. This is done by calling AddPerson.
 
@@ -484,7 +487,7 @@ class IotlabSlices:
 
         for added_user_email in added_user_emails:
             added_user = users_dict[added_user_email]
-            logger.debug(" SLABSLICE \r\n \r\n  \t THE SECOND verify_person \
+            logger.debug(" IOTLABSLICES \r\n \r\n  \t  verify_person \
                          added_user %s" % (added_user))
             person = {}
             person['peer_person_id'] = None
@@ -499,13 +502,18 @@ class IotlabSlices:
             person['key_ids'] = added_user.get('key_ids', [])
 
             ret = self.driver.iotlab_api.AddPerson(person)
-            if type(ret) == int:
-                person['uid'] = ret
+            if 'uid' in ret:
+                # meaning bool is True and the AddPerson was successful
+                person['uid'] = ret['uid']
+                slice_record['login'] = person['uid']
+            else:
+                # error message in ret
+                logger.debug(" IOTLABSLICES ret message %s" %(ret))
 
             logger.debug(" SLABSLICE \r\n \r\n  \t THE SECOND verify_person\
                            person %s" % (person))
             #Update slice_Record with the id now known to LDAP
-            slice_record['login'] = person['uid']
+
 
             added_persons.append(person)
         return added_persons