From: Nicolas Turro Date: Tue, 15 Nov 2011 11:26:35 +0000 (+0100) Subject: Missing imports added, hostname to hrn conversion. NT X-Git-Tag: sfa-2.1-24~3^2~297^2 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=da4a0cfcc9bb73eebd807e9514a80eb4ef6c4c57 Missing imports added, hostname to hrn conversion. NT --- diff --git a/sfa/senslab/slab-import.py b/sfa/senslab/slab-import.py index 351ecd51..44a2e8c2 100644 --- a/sfa/senslab/slab-import.py +++ b/sfa/senslab/slab-import.py @@ -10,9 +10,13 @@ from sfa.senslab.OARrestapi import OARapi from sfa.senslab.LDAPapi import LDAPapi from sfa.senslab.slabdriver import SlabDriver from sfa.util.config import Config -from sfa.util.xrn import hrn_to_urn, get_authority +from sfa.util.xrn import hrn_to_urn, get_authority,Xrn from sfa.util.table import SfaTable +from sfa.util.record import SfaRecord from sfa.trust.hierarchy import Hierarchy +from sfa.trust.certificate import Keypair +from sfa.trust.gid import create_uuid + AuthHierarchy = Hierarchy() table = SfaTable() @@ -87,7 +91,13 @@ def delete_record( hrn, type): for record in record_list: table.remove(record) - +def hostname_to_hrn(root_auth,hostname): + # keep only the first part of the DNS name + #hrn='.'.join( [auth,hostname.split(".")[0] ] ) + # escape the '.' in the hostname + hrn='.'.join( [root_auth,Xrn.escape(hostname)] ) + return hrn_to_urn(hrn,'node') + def main(): config = Config() @@ -128,7 +138,7 @@ def main(): Driver = SlabDriver(config) nodes_dict = Driver.GetNodes() - print "\r\n NODES8DICT ",nodes_dict + #print "\r\n NODES8DICT ",nodes_dict ldap_person_list = Driver.GetPersons() print "\r\n PERSONS_LIST ",ldap_person_list @@ -160,10 +170,10 @@ def main(): #print '\r\n \t **NODE_ID %s node %s '%( node_id, node) #continue for node in nodes_dict: - hrn = hostname_to_hrn(interface_hrn, root_auth, node['hostname']) + hrn = hostname_to_hrn( root_auth, node['hostname']) if hrn not in existing_hrns or \ (hrn, 'node') not in existing_records: - print "\t\t NODE HRN NOT in existing records!" ,hrn + print "\t\t NODE HRN NOT in existing record, importing it" ,hrn import_node(hrn, node) # import persons