ProxyStorage

This is the Proxy storage element client

class DIRAC.Resources.Storage.ProxyStorage.ProxyStorage(storageName, parameters)

Bases: StorageBase

DYNAMIC_OPTIONS = {}
PROTOCOL_PARAMETERS = ['Protocol', 'Host', 'Path', 'Port', 'SpaceToken', 'WSUrl']
__init__(storageName, parameters)
changeDirectory(directory)

Change the directory to the supplied directory

constructURLFromLFN(lfn, withWSUrl=False)

Construct URL from the given LFN according to the VO convention for the primary protocol of the storage plagin

Parameters:
  • lfn (str) – file LFN

  • withWSUrl (boolean) – flag to include the web service part into the resulting URL

Return result:

result[‘Value’] - resulting URL

createDirectory(path)

Make a new directory on the physical storage

exists(path)

Check if the given path exists

getCurrentDirectory()

Get the current directory

getCurrentURL(fileName)

Obtain the current file URL from the current working directory and the filename

Parameters:
  • self – self reference

  • fileName (str) – path on storage

getDirectory(path)

Get locally a directory from the physical storage together with all its files and subdirectories.

getDirectoryMetadata(path)

Get the metadata for the directory

getDirectorySize(path)

Get the size of the directory on the storage

getEndpoint()
This will get endpoint of the storage. It basically is the same as getURLBase()

but without the basePath

Returns:

‘proto://hostname<:port>’

getFile(path, localPath=False)

Get a local copy of the file specified by its path

getFileMetadata(path)

Get metadata associated to the file

getFileSize(path)

Get the physical size of the given file

getName()

The name with which the storage was instantiated

getOccupancy(**kwargs)

Get the StorageElement occupancy info in MB.

This generic implementation download a json file supposed to contain the necessary info.

Parameters:

occupancyLFN – (mandatory named argument) LFN of the json file.

Returns:

S_OK/S_ERROR dictionary. The S_OK value should contain a dictionary with Total and Free space in MB

getParameters()

Get the parameters with which the storage was instantiated

getTransportURL(pathDict, protocols)

Get a transport URL for a given URL. For a simple storage plugin it is just returning input URL if the plugin protocol is one of the requested protocols

Parameters:
  • pathDict (dict) – URL obtained from File Catalog or constructed according to convention

  • protocols (python:list) – a list of acceptable transport protocols in priority order

getURLBase(withWSUrl=False)

This will get the URL base. This is then appended with the LFN in DIRAC convention.

Parameters:
  • self – self reference

  • withWSUrl (bool) – flag to include Web Service part of the url

Returns:

URL

getWLCGTokenPath(lfn: str, wlcgTokenBasePath: str) str

Returns the path expected to be in a WLCG token It basically consists of basepath - tokenBasePath  + LFN The tokenBasePath is a configuration on the storage side.

isDirectory(path)

Check if the given path exists and it is a directory

isFile(path)

Check if the given path exists and it is a file

isNativeURL(url)

Check if URL :url: is valid for :self.protocol:

Parameters:
  • self – self reference

  • url (str) – URL

isURL(path)

Guess if the path looks like a URL

Parameters:
  • self – self reference

  • path (string) – input file LFN or URL

Returns boolean:

True if URL, False otherwise

listDirectory(path)

List the supplied path

prestageFile(path)

Issue prestage request for file

prestageFileStatus(path)

Obtain the status of the prestage request

putDirectory(path)

Put a local directory to the physical storage together with all its files and subdirectories.

putFile(path, sourceSize=0)

Put a copy of the local file to the current directory on the physical storage

releaseFile(path)

Release the file on the destination storage element

removeDirectory(path, recursive=False)

Remove a directory on the physical storage together with all its files and subdirectories.

removeFile(path)

Remove physically the file specified by its path

resetCurrentDirectory()

Reset the working directory to the base dir

setParameters(parameterDict)

Set standard parameters, method can be overriden in subclasses to process specific parameters

setStorageElement(se)
updateURL(url, withWSUrl=False)

Update the URL according to the current SE parameters