From 609ab41a698d69166cf51dc001996db6665c9745 Mon Sep 17 00:00:00 2001 From: Nicolas Turro Date: Wed, 26 Oct 2011 16:39:22 +0200 Subject: [PATCH 1/1] Read the name of the senslab authority from the SFA_REGISTRY_ROOT_AUTH. NT. --- sfa/senslab/table_slab.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sfa/senslab/table_slab.py b/sfa/senslab/table_slab.py index 502f520c..a09b6654 100644 --- a/sfa/senslab/table_slab.py +++ b/sfa/senslab/table_slab.py @@ -14,12 +14,16 @@ from sfa.trust.auth import * from sfa.senslab.OARrestapi import * class SfaTable(list): - + authname="" def __init__(self, record_filter = None): self.oar = OARapi() self.ldapserv=ldap.open("192.168.0.251") self.senslabauth=Hierarchy() - authinfo=self.senslabauth.get_auth_info("senslab") + config=Config() + self.authname=config.SFA_REGISTRY_ROOT_AUTH + print >>sys.stderr,"AUTHNAME : ",self.authname + authinfo=self.senslabauth.get_auth_info(self.authname) + self.auth=Auth() gid=authinfo.get_gid_object() @@ -67,12 +71,12 @@ class SfaTable(list): if 'authority' in record_filter: # ask for authority - if record_filter['authority']=='senslab': - # which is senslab + if record_filter['authority']==self.authname: + # which is SFA_REGISTRY_ROOT_AUTH # request all records which are under our authority, ie all ldap entries ldapfilter="cn=*" else: - #which is NOT senslab + #which is NOT SFA_REGISTRY_ROOT_AUTH return [] else : if not 'hrn' in record_filter: @@ -89,7 +93,7 @@ class SfaTable(list): ldapfilter="(|" for hrn in hrns: splited_hrn=hrn.split(".") - if splited_hrn[0] != "senslab" : + if splited_hrn[0] != "SFA_REGISTRY_ROOT_AUTH" : print >>sys.stderr,"i know nothing about",hrn else : login=splited_hrn[1] @@ -102,14 +106,14 @@ class SfaTable(list): rindex=self.ldapserv.search("ou=people,dc=senslab,dc=info",ldap.SCOPE_SUBTREE,ldapfilter, ['mail','givenName', 'sn', 'uid','sshPublicKey']) ldapresponse=self.ldapserv.result(rindex,1) for ldapentry in ldapresponse[1]: - hrn="senslab."+ldapentry[1]['uid'][0] + hrn=self.authname+"."+ldapentry[1]['uid'][0] uuid=create_uuid() RSA_KEY_STRING=ldapentry[1]['sshPublicKey'][0] pkey=convert_public_key(RSA_KEY_STRING) - gid=self.senslabauth.create_gid("urn:publicid:IDN+senslab+user+"+ldapentry[1]['uid'][0], uuid, pkey, CA=False) + gid=self.senslabauth.create_gid("urn:publicid:IDN+"+self.authname+"+user+"+ldapentry[1]['uid'][0], uuid, pkey, CA=False) parent_hrn = get_authority(hrn) parent_auth_info = self.senslabauth.get_auth_info(parent_hrn) @@ -122,7 +126,7 @@ class SfaTable(list): # 'phone': 'none', 'gid': gid.save_to_string(), 'serial': 'none', - 'authority': 'senslab', + 'authority': self.authname, 'peer_authority': '', 'pointer' : '', 'hrn': hrn, @@ -137,7 +141,7 @@ class SfaTable(list): if 'authority' in record_filter: # ask for authority - if record_filter['authority']=='senslab': + if record_filter['authority']== self.authname : # which is senslab print>> sys.stderr , "ET MERDE !!!!" node_ids="" @@ -158,7 +162,7 @@ class SfaTable(list): for hrn in hrns: head,sep,tail=hrn.partition(".") - if head != "senslab" : + if head != self.authname : print >>sys.stderr,"i know nothing about",hrn else : node_ids.append(tail) @@ -166,7 +170,7 @@ class SfaTable(list): node_list = self.oar.GetNodes( node_ids) for node in node_list: - hrn="senslab."+node['hostname'] + hrn=self.authname+"."+node['hostname'] results.append( { 'type': 'node', # 'email': ldapentry[1]['mail'][0], @@ -175,7 +179,7 @@ class SfaTable(list): # 'phone': 'none', # 'gid': gid.save_to_string(), # 'serial': 'none', - 'authority': 'senslab', + 'authority': self.authname, 'peer_authority': '', 'pointer' : '', 'hrn': hrn, @@ -200,7 +204,7 @@ class SfaTable(list): print >>sys.stderr,"find : don't know how to handle slices yet" return [] if record_filter['type'] == 'authority': - if 'hrn' in record_filter and record_filter['hrn']=='senslab': + if 'hrn' in record_filter and record_filter['hrn']==self.authname: return [] else: print >>sys.stderr,"find which authority ?" -- 2.45.2