Merge branch 'iotlab_fixes' into geni-v3
authorLoic Baron <sandrine.avakian@inria.fr>
Wed, 30 Jul 2014 14:40:15 +0000 (16:40 +0200)
committerLoic Baron <sandrine.avakian@inria.fr>
Wed, 30 Jul 2014 14:40:15 +0000 (16:40 +0200)
Conflicts:
sfa/iotlab/OARrestapi.py
sfa/iotlab/iotlabaggregate.py
sfa/iotlab/iotlabdriver.py
sfa/iotlab/iotlabshell.py
sfa/iotlab/iotlabslices.py

1  2 
sfa/iotlab/LDAPapi.py

diff --combined sfa/iotlab/LDAPapi.py
@@@ -466,8 -466,6 +466,8 @@@ class LDAPapi
                  if record['first_name'] != record['last_name']:
                      req_ldapdict['cn'] = str(record['first_name'])+" "\
                          + str(record['last_name'])
 +            if 'uid' in record:
 +                req_ldapdict['uid'] = record['uid']
              if 'email' in record:
                  req_ldapdict['mail'] = record['email']
              if 'mail' in record:
  
          parent_hrn = None
          peer_authority = None
-         if 'hrn' in record:
+         # If the user is coming from External authority (e.g. OneLab)
+         # Then hrn is None, it should be filled in by the creation of Ldap User
+         # XXX LOIC !!! What if a user email is in 2 authorities? 
+         if 'hrn' in record and record['hrn'] is not None:
              hrn = record['hrn']
              parent_hrn = get_authority(hrn)
              if parent_hrn != self.authname:
              #then the login is different from the one found in its hrn
              if tmpname != hrn.split('.')[1]:
                  hrn = None
+             results = {
+                 'type': 'user',
+                 'pkey': ldapentry['sshPublicKey'],
+                 #'uid': ldapentry[1]['uid'][0],
+                 'uid': tmpname,
+                 'email': tmpemail,
+                 #'email': ldapentry[1]['mail'][0],
+                 'first_name': ldapentry['givenName'][0],
+                 'last_name': ldapentry['sn'][0],
+                 #'phone': 'none',
+                 'serial': 'none',
+                 'authority': parent_hrn,
+                 'peer_authority': peer_authority,
+                 'pointer': -1,
+                 'hrn': hrn,
+              }
          else:
-             hrn = None
-         results = {
-             'type': 'user',
-             'pkey': ldapentry['sshPublicKey'],
-             #'uid': ldapentry[1]['uid'][0],
-             'uid': tmpname,
-             'email': tmpemail,
-             #'email': ldapentry[1]['mail'][0],
-             'first_name': ldapentry['givenName'][0],
-             'last_name': ldapentry['sn'][0],
-             #'phone': 'none',
-             'serial': 'none',
-             'authority': parent_hrn,
-             'peer_authority': peer_authority,
-             'pointer': -1,
-             'hrn': hrn,
-                     }
+             #hrn = None
+             results = {
+                 'type': 'user',
+                 'pkey': ldapentry['sshPublicKey'],
+                 #'uid': ldapentry[1]['uid'][0],
+                 'uid': tmpname,
+                 'email': tmpemail,
+                 #'email': ldapentry[1]['mail'][0],
+                 'first_name': ldapentry['givenName'][0],
+                 'last_name': ldapentry['sn'][0],
+                 #'phone': 'none',
+                 'serial': 'none',
+                 'authority': parent_hrn,
+                 'peer_authority': peer_authority,
+                 'pointer': -1,
+             }
          return results
  
      def LdapFindUser(self, record=None, is_user_enabled=None,
              return None
          #Asked for a specific user
          if record is not None:
+             logger.debug("LOIC - record = %s" % record)
              results = self._process_ldap_info_for_one_user(record, result_data)
  
          else: