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))
#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']]
if slices_list:
for sl in slices_list:
- logger.debug("SLABSLICE \t verify_slice slicename %s \
+ logger.debug("IOTLABSLICES \t verify_slice slicename %s \
slices_list %s sl %s \r slice_record %s"
% (slicename, slices_list, sl, slice_record))
sfa_slice = sl
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.
for info in users:
if 'slice_record' in info:
slice_rec = info['slice_record']
- user = slice_rec['user']
+ if 'user' in slice_rec :
+ user = slice_rec['user']
- if 'email' in user:
- users_by_email[user['email']] = user
- users_dict[user['email']] = user
+ if 'email' in user:
+ users_by_email[user['email']] = user
+ users_dict[user['email']] = user
- logger.debug("SLABSLICE.PY \t verify_person \
+ logger.debug("IOTLABSLICES.PY \t verify_person \
users_dict %s \r\n user_by_email %s \r\n \
\tusers_by_id %s "
% (users_dict, users_by_email, users_by_id))
#Needed because what if the user has been deleted in LDAP but
#is still in SFA?
existing_users = self.driver.iotlab_api.GetPersons(filter_user)
- logger.debug(" \r\n SLABSLICE.PY \tverify_person filter_user \
+ logger.debug(" \r\n IOTLABSLICES.PY \tverify_person filter_user \
%s existing_users %s "
% (filter_user, existing_users))
#User is in iotlab LDAP
ldap_reslt = self.driver.iotlab_api.ldap.LdapSearch(req)
if ldap_reslt:
- logger.debug(" SLABSLICE.PY \tverify_person users \
+ logger.debug(" IOTLABSLICES.PY \tverify_person users \
USER already in Iotlab \t ldap_reslt %s \
" % (ldap_reslt))
existing_users.append(ldap_reslt[1])
else:
#User not existing in LDAP
- logger.debug("SLABSLICE.PY \tverify_person users \
+ logger.debug("IOTLABSLICES.PY \tverify_person users \
not in ldap ...NEW ACCOUNT NEEDED %s \r\n \t \
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("SLABSLICE.PY \tverify_person \
+ 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['PI'][0] in requested_user_hrns:
- logger.debug(" SLABSLICE \tverify_person ['PI']\
+ logger.debug(" IOTLABSLICES \tverify_person ['PI']\
slice_record %s" % (slice_record))
except KeyError:
#requested_user_email is in existing_user_emails
if len(added_user_emails) == 0:
slice_record['login'] = users_dict[requested_user_emails[0]]['uid']
- logger.debug(" SLABSLICE \tverify_person QUICK DIRTY %s"
+ logger.debug(" IOTLABSLICES \tverify_person QUICK DIRTY %s"
% (slice_record))
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
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\
+ logger.debug(" IOTLABSLICES \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