Content-type: text/html
There follows a series of examples of how to use selected functions and how to retrieve the information returned by them: Examples are to copy a file to SE and register it in replica catalog or lfc, finding the GUID for given surl or lfn, copy and register file from one SE to another, Unregister and register a file in LFC residing on an SE.
#!/usr/bin/python """ # Copy a file to Storage element and register in the the LFC. """ import sys import lcg_util src='file:/etc/hosts' dest='grid2.irb.hr' guid="212fa800-9d65-11da-a746-0800200c9b13" lfn='/grid/dteam/fnaz/testfile' vo='dteam' relativepath='fnaz/testfile' nstreams=1 config='' insecure=0 verbose=1 actual_guid="" for i in range(0,37): actual_guid=actual_guid + " " output= lcg_util.lcg_cr(src,dest,guid,lfn,vo,relativepath,nstreams,'',insecure,verbose,actual_guid) print "teststatus: ",output print "actual_guid: ",actual_guid
#!/usr/bin/python """ # Copy a file from one Storage Element to another Storage Element and registers it in the LRC or the LFC. # Unregister in the LRC or the LFC a file residing on an SE. # Register in the LRC or the LFC, a file residing on an SE """ import sys import lcg_util vo='dteam' src_file='lfn:/grid/dteam/fnaz/testfile' dest_file='grid009.to.infn.it' relativepath="fnaz/testfile" nstreams=1 insecure=0 verbose=1 config='' surl='sfn://grid009.to.infn.it/flatfiles/SE00/dteam/fnaz/testfile' guid='guid:212fa800-9d65-11da-a746-0800200c9b21' lfn="" actual_guid="" for i in range(0,37): actual_guid=actual_guid+" " #copy and register file output= lcg_util.lcg_rep(src_file,dest_file,vo,relativepath,nstreams,config,insecure,verbose) print "status_rep: ",output if output==0: #Unregister the file output= lcg_util.lcg_uf(surl,guid,vo,config,insecure) print " status_uf: ",output #Register the file output= lcg_util.lcg_rf(surl,guid,lfn,vo,config,insecure,verbose,actual_guid) print "status_rf: ",output else: print "Copy and register fail."
#!/usr/bin/python """ Get the GUID for a given LFN """ import lcg_util vo='dteam' file='lfn:/grid/dteam/fnaz/testfile' insecure=0 config='' guid="" for i in range(0,37): guid=guid + " " output= lcg_util.lcg_lg(file,vo,config,insecure,guid) if output!=0: print "status: ",output else: print "guid:",guid