Пример #1
0
  def setUp(self):
    self.lfc = LcgFileCatalogClient(host='lfc-lhcb.cern.ch',infosys='lcg-bdii.cern.ch:2170')
    ######################################################
    #
    #  Clean the test directory before starting
    #
    dir = '/lhcb/test/unit-test'
    res = self.lfc.listDirectory(dir)
    self.assert_(res['OK'])
    self.assert_(res['Value'].has_key('Successful'))
    self.assert_(res['Value'].has_key('Failed'))
    self.assert_(res['Value']['Successful'].has_key(dir))
    lfnsToDelete = res['Value']['Successful'][dir]
    res = self.lfc.getReplicas(lfnsToDelete)
    self.assert_(res['OK'])
    self.assert_(res['Value'].has_key('Successful'))
    self.assert_(res['Value'].has_key('Failed'))
    replicas = res['Value']['Successful']
    replicaTupleList = []
    for lfn in replicas.keys():
      for se in replicas[lfn].keys():
        replicaTuple = (lfn,replicas[lfn][se],se)
        replicaTupleList.append(replicaTuple)

    res = self.lfc.removeReplica(replicaTupleList)
    self.assert_(res['OK'])
    self.assert_(res['Value'].has_key('Successful'))
    self.assert_(res['Value'].has_key('Failed'))
    self.assertFalse(res['Value']['Failed'])
    res = self.lfc.removeFile(lfnsToDelete)
    self.assert_(res['OK'])
    self.assert_(res['Value'].has_key('Successful'))
    self.assert_(res['Value'].has_key('Failed'))
    self.assertFalse(res['Value']['Failed'])
  def __init__( self, infosys = None, master_host = None, mirrors = [] ):
    """ Default constructor
    """
    if not infosys:
      configPath = '/Resources/FileCatalogs/LcgFileCatalogCombined/LcgGfalInfosys'
      infosys = gConfig.getValue( configPath )

    self.valid = False
    if not master_host:
      configPath = '/Resources/FileCatalogs/LcgFileCatalogCombined/MasterHost'
      master_host = gConfig.getValue( configPath )
    if master_host:
      # Create the master LFC client first
      self.lfc = LcgFileCatalogClient( infosys, master_host )
      if self.lfc.isOK():
        self.valid = True

      if not mirrors:
        siteName = DIRAC.siteName()
        res = getLocationOrderedCatalogs( siteName = siteName )
        if not res['OK']:
          mirrors = []
        else:
          mirrors = res['Value']
      # Create the mirror LFC instances
      self.mirrors = []
      for mirror in mirrors:
        lfc = LcgFileCatalogClient( infosys, mirror )
        self.mirrors.append( lfc )
      self.nmirrors = len( self.mirrors )

      # Keep the environment for the master instance
      self.master_host = self.lfc.host
      os.environ['LFC_HOST'] = self.master_host
      os.environ['LCG_GFAL_INFOSYS'] = infosys
      self.name = 'LFC'
      self.timeout = 3000
Пример #3
0
    fcType = res['Value']

if not fcType:
    res = gConfig.getSections("/Resources/FileCatalogs", listOrdered=True)
    if res['OK']:
        fcType = res['Value'][0]

for switch in Script.getUnprocessedSwitches():
    if switch[0].lower() == "f" or switch[0].lower() == "file-catalog":
        fcType = switch[1]

from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI

if fcType == "LcgFileCatalog" or fcType == "LFC":
    from DIRAC.Resources.Catalog.LcgFileCatalogClient import LcgFileCatalogClient
    cli = FileCatalogClientCLI(LcgFileCatalogClient())
    try:
        host = os.environ['LFC_HOST']
    except Exception, x:
        print "LFC_HOST environment variable not defined"
        sys.exit(1)
    print "Starting LFC FileCatalog client"
    cli.cmdloop()
elif fcType == "LcgFileCatalogProxy" or fcType == "LFCproxy":
    from DIRAC.Resources.Catalog.LcgFileCatalogProxyClient import LcgFileCatalogProxyClient
    cli = FileCatalogClientCLI(LcgFileCatalogProxyClient())
    print "Starting LFC Proxy FileCatalog client"
    cli.cmdloop()
elif fcType == "LcgFileCatalogCombined" or fcType == "LFCCombined":
    from DIRAC.Resources.Catalog.LcgFileCatalogCombinedClient import LcgFileCatalogCombinedClient
    cli = FileCatalogClientCLI(LcgFileCatalogCombinedClient())