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,get_leaf
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()
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()
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
#(site_hrn, 'authority') not in existing_records:
#print "SITE HRN UNKNOWN" , site, site_hrn
#site_hrn = SenslabImporter.import_site(interface_hrn, site)
-
- print "\r\n \r\n ===========IMPORT NODE_RECORDS ==========\r\n site %s \r\n \t nodes_dict %s" %(site,nodes_dict)
+
# import node records
#for node_id in site['node_ids']:
#for[node['node_id'] for node in nodes_dict]:
#print '\r\n \t **NODE_ID %s node %s '%( node_id, node)
#continue
for node in nodes_dict:
- print '\r\n \t NODE_ID %s node %s '%( node_id, node)
- 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
for person in ldap_person_list:
- print >>sys.stderr, "\r\n\r\n^^^^^^^^^^^^^PERSON hrn %s person %s site hrn %s" %(hrn,person)
if person['hrn'] not in existing_hrns or \
(person['hrn'], 'user') not in existing_records :
import_person( person)
login_base = get_leaf(get_authority(record_hrn))
nodename = Xrn.unescape(get_leaf(record_hrn))
print "type: node : nodename %s" %(nodename)
- for node in nodes_dict.values():
+ for node in nodes_dict:
if node['hostname'] == nodename :
found = True
break