Ejemplo n.º 1
0
class FileCatalogProxyClient:
  """ File catalog client for the File Catalog proxy service
  """

  def __init__( self, fcName, **kwargs ):
    """ Constructor of the LCGFileCatalogProxy client class
    """
    self.method = None
    self.fcName = fcName
    self.rpc = RPCClient( 'DataManagement/FileCatalogProxy', timeout=120 )
    self.valid = False
    self.valid = self.rpc.ping()['OK']

  def isOK( self ):
    """ Is the Catalog available?
    """
    return self.valid

  def getName( self ):
    """ Get the file catalog name
    """
    return self.fcName

  def __getattr__( self, name ):
    self.method = name
    return self.execute

  def execute( self, *parms, **kws ):
    """ Magic method dispatcher """
    return self.rpc.callProxyMethod( self.fcName, self.method, parms, kws )
Ejemplo n.º 2
0
 def putFile( self, path, sourceSize = 0 ):
   client = RPCClient( self.url )
   if sourceSize:
     gLogger.debug( "ProxyStorage.putFile: The client has provided the source file size implying a replication is requested." )
     return client.callProxyMethod( self.name, 'putFile', path, {'sourceSize':sourceSize} )
   gLogger.debug( "ProxyStorage.putFile: No source size was provided therefore a simple put will be performed." )
   res = self.__checkArgumentFormatDict( path )
   if not res['OK']:
     return res
   urls = res['Value']
   failed = {}
   successful = {}
   client = RPCClient( self.url )
   transferClient = TransferClient( self.url )
   for dest_url, src_file in urls.items():
     fileName = os.path.basename( dest_url )
     res = transferClient.sendFile( src_file, 'putFile/%s' % fileName )
     if not res['OK']:
       gLogger.error( "ProxyStorage.putFile: Failed to send file to proxy server.", res['Message'] )
       failed[dest_url] = res['Message']
     else:
       res = client.uploadFile( self.name, src_file )
       if not res['OK']:
         gLogger.error( "ProxyStorage.putFile: Failed to upload file to storage element from proxy server.", res['Message'] )
         failed[dest_url] = res['Message']
       else:
         res = self.__executeOperation( dest_url, 'getFileSize' )
         if not res['OK']:
           gLogger.error( "ProxyStorage.putFile: Failed to determine destination file size.", res['Message'] )
           failed[dest_url] = res['Message']
         else:
           successful[dest_url] = res['Value']
   resDict = {'Failed':failed, 'Successful':successful}
   return S_OK( resDict )
Ejemplo n.º 3
0
class FileCatalogProxyClient:
  """ File catalog client for the File Catalog proxy service
  """

  def __init__( self, fcName, **kwargs ):
    """ Constructor of the LCGFileCatalogProxy client class
    """
    self.method = None
    self.fcName = fcName
    self.rpc = RPCClient( 'DataManagement/FileCatalogProxy', timeout=120 )
    self.valid = False
    self.valid = self.rpc.ping()['OK']

  def isOK( self ):
    """ Is the Catalog available?
    """
    return self.valid

  def getName( self ):
    """ Get the file catalog name
    """
    return self.fcName

  def __getattr__( self, name ):
    self.method = name
    return self.execute

  def execute( self, *parms, **kws ):
    """ Magic method dispatcher """
    return self.rpc.callProxyMethod( self.fcName, self.method, parms, kws )
Ejemplo n.º 4
0
    def putFile(self, path, sourceSize=0):

        client = RPCClient(self.url)

        if sourceSize:
            gLogger.debug(
                "ProxyStorage.putFile: The client has provided the source file size implying a replication is requested."
            )
            return client.callProxyMethod(self.name, 'putFile', [path],
                                          {'sourceSize': sourceSize})

        gLogger.debug(
            "ProxyStorage.putFile: No source size was provided therefore a simple put will be performed."
        )
        res = checkArgumentFormat(path)
        if not res['OK']:
            return res
        urls = res['Value']
        failed = {}
        successful = {}
        # make sure transferClient uses the same ProxyStorage instance we uploaded the file to
        transferClient = TransferClient(client.serviceURL)
        for dest_url, src_file in urls.items():
            fileName = os.path.basename(dest_url)
            res = transferClient.sendFile(src_file, 'putFile/%s' % fileName)
            if not res['OK']:
                gLogger.error(
                    "ProxyStorage.putFile: Failed to send file to proxy server.",
                    res['Message'])
                failed[dest_url] = res['Message']
            else:
                res = client.uploadFile(self.name, dest_url)
                if not res['OK']:
                    gLogger.error(
                        "ProxyStorage.putFile: Failed to upload file to storage element from proxy server.",
                        res['Message'])
                    failed[dest_url] = res['Message']
                else:
                    res = self.__executeOperation(dest_url, 'getFileSize')
                    if not res['OK']:
                        gLogger.error(
                            "ProxyStorage.putFile: Failed to determine destination file size.",
                            res['Message'])
                        failed[dest_url] = res['Message']
                    else:
                        successful[dest_url] = res['Value']
        resDict = {'Failed': failed, 'Successful': successful}
        return S_OK(resDict)
Ejemplo n.º 5
0
 def removeDirectory(self, path, recursive=False):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'removeDirectory', path,
                                   {'recursive': recursive})
Ejemplo n.º 6
0
 def getDirectorySize(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getDirectorySize', path)
Ejemplo n.º 7
0
 def pinFile(self, path, lifetime=60 * 60 * 24):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'pinFile', path,
                                   {'lifetime': lifetime})
Ejemplo n.º 8
0
 def getTransportURL(self, path, protocols=False):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getTransportURL', path,
                                   {'protocols': protocols})
Ejemplo n.º 9
0
 def exists(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'exists', path)
Ejemplo n.º 10
0
 def removeDirectory( self, path, recursive = False ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeDirectory', [path], {'recursive':recursive} )
Ejemplo n.º 11
0
 def listDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'listDirectory', [path], {} )
Ejemplo n.º 12
0
 def getFileSize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileSize', [path], {} )
Ejemplo n.º 13
0
 def exists( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'exists', [path], {} )
Ejemplo n.º 14
0
 def listDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'listDirectory', path )
Ejemplo n.º 15
0
 def getDirectoryMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectoryMetadata', path )
Ejemplo n.º 16
0
 def prestageFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFile', path )
Ejemplo n.º 17
0
 def getFileMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileMetadata', [path], {} )
Ejemplo n.º 18
0
 def getDirectorySize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectorySize', [path], {} )
Ejemplo n.º 19
0
 def getTransportURL( self, path, protocols = False ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getTransportURL', [path], {'protocols':protocols} )
Ejemplo n.º 20
0
 def createDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'createDirectory', [path], {} )
Ejemplo n.º 21
0
 def removeFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeFile', [path], {} )
Ejemplo n.º 22
0
 def getPFNBase( self ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getPFNBase', [], {} )
Ejemplo n.º 23
0
 def prestageFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFile', [path], {} )
Ejemplo n.º 24
0
 def getFileMetadata(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getFileMetadata', path)
Ejemplo n.º 25
0
 def prestageFileStatus( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFileStatus', [path], {} )
Ejemplo n.º 26
0
 def prestageFileStatus(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'prestageFileStatus', path)
Ejemplo n.º 27
0
 def pinFile( self, path, lifetime = 60 * 60 * 24 ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'pinFile', [path], {'lifetime':lifetime} )
Ejemplo n.º 28
0
 def releaseFile(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'releaseFile', path)
Ejemplo n.º 29
0
 def getFileSize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileSize', path )
Ejemplo n.º 30
0
 def createDirectory(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'createDirectory', path)
Ejemplo n.º 31
0
 def getDirectoryMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectoryMetadata', [path], {} )
Ejemplo n.º 32
0
 def releaseFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'releaseFile', [path], {} )
Ejemplo n.º 33
0
 def removeFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeFile', path )