- 'hrn' : users_by_email[user['email']]['hrn'],
- }
- if 'first_name' in user:
- person['first_name'] = user['first_name']
- if 'last_name' in user:
- person['last_name'] = user['last_name']
- if 'person_id' in user:
- person['person_id'] = user['person_id']
- if user['keys']:
- # XXX Only one key is kept for IoTLAB
- person['pkey'] = user['keys'][0]
-
- # LDAP
- if users_by_email not in existing_users_by_email.keys():
- ret = self.driver.AddPerson(person)
- if 'uid' in ret:
- person['uid'] = ret['uid']
- added_persons.append(person)
- else:
- logger.debug(" IOTLABSLICES ret message %s" %(ret))
- else:
- person['uid'] = existing_users_by_email[user['email']]['uid']
-
- # Local DB
- self.driver.add_person_to_db(person)
-
-
- # Set the login in the slice_record XXX
- slice_record['login'] = existing_users[0]['uid']
-
- return added_persons
-
-#DEPRECATED| # users to be added, removed or updated
-#DEPRECATED| #One user in one iotlab slice : there should be no need
-#DEPRECATED| #to remove/ add any user from/to a slice.
-#DEPRECATED| #However a user from SFA which is not registered in Iotlab yet
-#DEPRECATED| #should be added to the LDAP.
-#DEPRECATED| added_user_emails = set(requested_user_emails).\
-#DEPRECATED| difference(set(existing_user_emails))
-#DEPRECATED|
-#DEPRECATED|
-#DEPRECATED| #self.verify_keys(existing_slice_users, updated_users_list, \
-#DEPRECATED| #peer, append)
-#DEPRECATED|
-#DEPRECATED| # XXX JORDAN the uid of the user is put in slice_record['login']
-#DEPRECATED| added_persons = []
-#DEPRECATED| # add new users
-#DEPRECATED| #requested_user_email is in existing_user_emails
-#DEPRECATED| if len(added_user_emails) == 0:
-#DEPRECATED| slice_record['login'] = existing_users[0]['uid']
-#DEPRECATED| #slice_record['login'] = users_dict[requested_user_emails[0]]['uid']
-#DEPRECATED| logger.debug(" IOTLABSLICES \tverify_person QUICK DIRTY %s"
-#DEPRECATED| % (slice_record))
-#DEPRECATED| # XXX JORDAN uid == 'register'
-#DEPRECATED| logger.debug("JORDAN USERS BY EMAIL: %r" % users_by_email)
-#DEPRECATED|
-#DEPRECATED| # XXX JORDAN i have no added_user_emails
-#DEPRECATED| logger.debug("JORDAN: added_user_emails: %r" % added_user_emails)
-#DEPRECATED| for added_user_email in added_user_emails:
-#DEPRECATED| added_user = users_dict[added_user_email]
-#DEPRECATED| logger.debug(" IOTLABSLICES \r\n \r\n \t verify_person \
-#DEPRECATED| added_user %s" % (added_user))
-#DEPRECATED| person = {}
-#DEPRECATED| person['peer_person_id'] = None
-#DEPRECATED| k_list = ['first_name', 'last_name', 'person_id']
-#DEPRECATED| for k in k_list:
-#DEPRECATED| if k in added_user:
-#DEPRECATED| person[k] = added_user[k]
-#DEPRECATED| # bug user without key
-#DEPRECATED| if added_user['keys']:
-#DEPRECATED| person['pkey'] = added_user['keys'][0]
-#DEPRECATED| person['mail'] = added_user['email']
-#DEPRECATED| person['email'] = added_user['email']
-#DEPRECATED| person['key_ids'] = added_user.get('key_ids', [])
-#DEPRECATED|
-#DEPRECATED| # JORDAN
-#DEPRECATED| # This is the only call to AddPerson. We need to be sure to provide
-#DEPRECATED| # the right hrn, by default it used to be done in the function like
-#DEPRECATED| # this:
-#DEPRECATED| # person['hrn'] = self.testbed_shell.root_auth + '.' + ret['uid']
-#DEPRECATED| person['hrn'] = users_by_email[added_user['email']]['hrn']
-#DEPRECATED|
-#DEPRECATED| # This only deals with the LDAP (now)
-#DEPRECATED| ret = self.driver.AddPerson(person)
-#DEPRECATED| # This will check if we have a record in the local DB and add it if necessary
-#DEPRECATED| self.__add_person_to_db(person)
-#DEPRECATED|
-#DEPRECATED| if 'uid' in ret:
-#DEPRECATED| # meaning bool is True and the AddPerson was successful
-#DEPRECATED| person['uid'] = ret['uid']
-#DEPRECATED| slice_record['login'] = person['uid']
-#DEPRECATED| else:
-#DEPRECATED| # error message in ret
-#DEPRECATED| logger.debug(" IOTLABSLICES ret message %s" %(ret))
-#DEPRECATED|
-#DEPRECATED| logger.debug(" IOTLABSLICES \r\n \r\n \t THE SECOND verify_person\
-#DEPRECATED| person %s" % (person))
-#DEPRECATED| #Update slice_Record with the id now known to LDAP
-#DEPRECATED|
-#DEPRECATED|
-#DEPRECATED| added_persons.append(person)
-#DEPRECATED| return added_persons
-
+ 'hrn' : user['hrn'],
+ }
+ if 'first_name' in user:
+ person['first_name'] = user['first_name']
+ if 'last_name' in user:
+ person['last_name'] = user['last_name']
+ if 'person_id' in user:
+ person['person_id'] = user['person_id']
+ if user['keys']:
+ # Only one key is kept for IoTLAB
+ person['pkey'] = user['keys'][0]
+ # SFA DB (if user already exist we do nothing)
+ self.driver.add_person_to_db(person)
+ # Iot-LAB LDAP (if user already exist we do nothing)
+ ret = self.driver.AddPerson(person)
+ # user uid information is only in LDAP
+ # Be carreful : global scope of dict slice_record in driver
+ slice_record['login'] = ret['uid']
+ return person
+
+