-###########################################################################
-# Copyright (C) 2011 by root
-# <root@FlabFedora2>
-#
-# Copyright: See COPYING file that comes with this distribution
-#
-###########################################################################
+
import sys
import datetime
import time
from sfa.senslab.slabdriver import SlabDriver
from sfa.senslab.slabpostgres import SlabDB
from sfa.util.config import Config
+from sfa.util.plxrn import PlXrn
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
hrn = hrn[:64]
node_record = table.find({'type': 'node', 'hrn': hrn})
- pkey = Keypair(create=True)
+ pkey = Keypair(create=True)
+
urn = hrn_to_urn(hrn, 'node')
node_gid = AuthHierarchy.create_gid(urn, create_uuid(), pkey)
node_record = SfaRecord(hrn=hrn, gid=node_gid, type="node", pointer=node['node_id'])
node_record['date_created'] = int(time.mktime(extime.timetuple()))
existing_records = table.find({'hrn': hrn, 'type': 'node', 'pointer': node['node_id']})
if not existing_records:
- print>>sys.stderr, " \r\n \t slab-import : node record %s inserted" %(node_record['hrn'])
+ print>>sys.stderr, " \r\n \t slab-import : node record %s inserted" %(node_record )
table.insert(node_record)
else:
existing_record = existing_records[0]
if not existing_records:
print>>sys.stderr, " \r\n \t slab-import : slice record %s inserted" %(slice_record['hrn'])
table.insert(slice_record)
- #table.insert_slice(person)
- db.insert_slice(person)
+ db.insert_slab_slice(person)
else:
print>>sys.stderr, " \r\n \t slab-import : slice record %s updated" %(slice_record['hrn'])
existing_record = existing_records[0]
slice_record['record_id'] = existing_record['record_id']
table.update(slice_record)
- db.update_slice(slice_record)
+ db.update_senslab_slice(slice_record)
def delete_record( hrn, type):
# delete the record
print>>sys.stderr, " \r\n \t slab-import : record %s deleted" %(record['hrn'])
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 hostname_to_hrn(root_auth,login_base,hostname):
+ return PlXrn(auth=root_auth,hostname=login_base+'_'+hostname).get_hrn()
+
def main():
sys.exit(0)
root_auth = config.SFA_REGISTRY_ROOT_AUTH
interface_hrn = config.SFA_INTERFACE_HRN
- print interface_hrn, root_auth
+
#Get all records in the sfa table
# create dict of all existing sfa records
# import node records
for node in nodes_dict:
- hrn = hostname_to_hrn( root_auth, node['hostname'])
+ # Sandrine
+ # A changer pour l utilisation du nouveau OAR de prod, le site etant contenu dans le hostname
+ hrn = hostname_to_hrn( root_auth,node['site_login_base'], node['hostname'])
if hrn not in existing_hrns or \
(hrn, 'node') not in existing_records:
import_node(hrn, node)