Merge Master in geni-v3 conflict resolution
[sfa.git] / sfa / senslab / slabslices.py
index 748b93c..5f5e52f 100644 (file)
@@ -20,18 +20,23 @@ class SlabSlices:
         
         # get this slice's authority (site)
         slice_authority = get_authority(hrn)
-        site_authority = slice_authority
+        #Senslab stuff
+        #This slice belongs to the current site
+        if slice_authority ==  self.driver.slab_api.root_auth:
+            site_authority = slice_authority
+            return None
+       
+        site_authority = get_authority(slice_authority).lower()
         # get this site's authority (sfa root authority or sub authority)
-        #site_authority = get_authority(slice_authority).lower()
+
         logger.debug("SLABSLICES \ get_peer slice_authority  %s \
                     site_authority %s hrn %s" %(slice_authority, \
                                         site_authority, hrn))
-        #This slice belongs to the current site
-        if site_authority == self.driver.slab_api.root_auth :
-            return None
+        
+            
         # check if we are already peered with this site_authority, if so
         #peers = self.driver.slab_api.GetPeers({})  
-        peers = self.driver.slab_api.GetPeers(peer_filter = slice_authority)
+        peers = self.driver.slab_api.GetPeers(peer_filter = site_authority)
         for peer_record in peers:
           
             if site_authority == peer_record.hrn:
@@ -347,14 +352,8 @@ class SlabSlices:
                         slice_record %s peer %s sfa_peer %s ldap_user %s"\
                         %(slice_record, peer,sfa_peer ,ldap_user ))
             #User already registered in ldap, meaning user should be in SFA db
-            #and hrn = sfa_auth+ uid           
-            if ldap_user : 
-                hrn = self.driver.slab_api.root_auth +'.'+ ldap_user['uid']
-                
-                user = self.driver.get_user_record(hrn)
-                
-                logger.debug(" SLABSLICES \tverify_slice hrn %s USER %s" %(hrn, user))
-                sfa_slice = {'slice_hrn': slicename,
+            #and hrn = sfa_auth+ uid   
+            sfa_slice = {'hrn': slicename,
                      #'url': slice_record.get('url', slice_hrn), 
                      #'description': slice_record.get('description', slice_hrn)
                      'node_list' : [],
@@ -364,15 +363,35 @@ class SlabSlices:
                      'slice_id' : slice_record['record_id'],
                      'reg-researchers':slice_record['reg-researchers'],
                      #'record_id_slice': slice_record['record_id'],
-                     'peer_authority':str(peer.hrn)
+                     'peer_authority':str(sfa_peer)
+                    
+                     }        
+            if ldap_user : 
+                hrn = self.driver.slab_api.root_auth +'.'+ ldap_user['uid']
+                
+                user = self.driver.get_user_record(hrn)
+                
+                logger.debug(" SLABSLICES \tverify_slice hrn %s USER %s" %(hrn, user))
+                #sfa_slice = {'slice_hrn': slicename,
+                     ##'url': slice_record.get('url', slice_hrn), 
+                     ##'description': slice_record.get('description', slice_hrn)
+                     #'node_list' : [],
+                     #'authority' : slice_record['authority'],
+                     #'gid':slice_record['gid'],
+                     ##'record_id_user' : user.record_id,
+                     #'slice_id' : slice_record['record_id'],
+                     #'reg-researchers':slice_record['reg-researchers'],
+                     ##'record_id_slice': slice_record['record_id'],
+                     #'peer_authority':str(peer.hrn)
                     
-                     }
+                     #}
+                     # add the slice  
+                if sfa_slice :
+                    self.driver.slab_api.AddSlice(sfa_slice, user)  
                      
                 if peer:
                     sfa_slice['slice_id'] = slice_record['record_id']
-            # add the slice  
-            if sfa_slice:
-                self.driver.slab_api.AddSlice(sfa_slice, user)                         
+                                   
             #slice['slice_id'] = self.driver.slab_api.AddSlice(slice)
             logger.debug("SLABSLICES \tverify_slice ADDSLICE OK") 
             #slice['node_ids']=[]