コード例 #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 )
コード例 #2
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 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 )
コード例 #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 )
コード例 #4
0
ファイル: ProxyStorage.py プロジェクト: mesmith75/DIRAC
    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)
コード例 #5
0
 def removeDirectory(self, path, recursive=False):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'removeDirectory', path,
                                   {'recursive': recursive})
コード例 #6
0
 def getDirectorySize(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getDirectorySize', path)
コード例 #7
0
 def pinFile(self, path, lifetime=60 * 60 * 24):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'pinFile', path,
                                   {'lifetime': lifetime})
コード例 #8
0
 def getTransportURL(self, path, protocols=False):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getTransportURL', path,
                                   {'protocols': protocols})
コード例 #9
0
 def exists(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'exists', path)
コード例 #10
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def removeDirectory( self, path, recursive = False ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeDirectory', [path], {'recursive':recursive} )
コード例 #11
0
 def listDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'listDirectory', [path], {} )
コード例 #12
0
 def getFileSize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileSize', [path], {} )
コード例 #13
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def exists( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'exists', [path], {} )
コード例 #14
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 def listDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'listDirectory', path )
コード例 #15
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 def getDirectoryMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectoryMetadata', path )
コード例 #16
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 def prestageFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFile', path )
コード例 #17
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def getFileMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileMetadata', [path], {} )
コード例 #18
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def getDirectorySize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectorySize', [path], {} )
コード例 #19
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def getTransportURL( self, path, protocols = False ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getTransportURL', [path], {'protocols':protocols} )
コード例 #20
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def createDirectory( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'createDirectory', [path], {} )
コード例 #21
0
 def removeFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeFile', [path], {} )
コード例 #22
0
 def getPFNBase( self ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getPFNBase', [], {} )
コード例 #23
0
 def prestageFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFile', [path], {} )
コード例 #24
0
 def getFileMetadata(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'getFileMetadata', path)
コード例 #25
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def prestageFileStatus( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'prestageFileStatus', [path], {} )
コード例 #26
0
 def prestageFileStatus(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'prestageFileStatus', path)
コード例 #27
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def pinFile( self, path, lifetime = 60 * 60 * 24 ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'pinFile', [path], {'lifetime':lifetime} )
コード例 #28
0
 def releaseFile(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'releaseFile', path)
コード例 #29
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 def getFileSize( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getFileSize', path )
コード例 #30
0
 def createDirectory(self, path):
     client = RPCClient(self.url)
     return client.callProxyMethod(self.name, 'createDirectory', path)
コード例 #31
0
 def getDirectoryMetadata( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'getDirectoryMetadata', [path], {} )
コード例 #32
0
ファイル: ProxyStorage.py プロジェクト: cgrefe/DIRAC
 def releaseFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'releaseFile', [path], {} )
コード例 #33
0
ファイル: ProxyStorage.py プロジェクト: bmb/DIRAC
 def removeFile( self, path ):
   client = RPCClient( self.url )
   return client.callProxyMethod( self.name, 'removeFile', path )