SRM2Storage

mod:SRM2Storage

synopsis:SRM v2 interface to StorageElement
class DIRAC.Resources.Storage.SRM2Storage.SRM2Storage(**kwargs)

Bases: DIRAC.Resources.Storage.StorageBase.StorageBase

class SRM2Storage

SRM v2 interface to StorageElement using lcg_util and gfal

DYNAMIC_OPTIONS = {}
PROTOCOL_PARAMETERS = ['Protocol', 'Host', 'Path', 'Port', 'SpaceToken', 'WSUrl']
__init__(**kwargs)

c’tor

Parameters:
  • self – self reference
  • storageName (str) – SE name
  • parameters (dict) – dictionary of protocol 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)

mkdir -p path on storage

Parameters:
  • self – self reference
  • path (str) –
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, localPath=False)

Get a local copy in the current directory of a physical file specified by its path

getDirectoryMetadata(path)

get the metadata for the directory :path:

Parameters:
  • self – self reference
  • path (str) – SE path
getDirectorySize(path)

Get the size of the directory on the storage

getFile(path, localPath=False)

make a local copy of a storage :path:

Parameters:
  • self – self reference
  • path (str) – path on storage
  • localPath (mixed) – if not specified, os.getcwd()
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(path, protocols=False)

obtain the tURLs for the supplied path and protocols

Parameters:
  • self – self reference
  • path (str) – path on storage
  • protocols (mixed) – protocols to use
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

isDirectory(path)

isdir on storage path

Parameters:
  • self – self reference
  • path (str) – SE path
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
isOK()
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, internalCall=False)

List the contents of the directory on the storage

Parameters:interalCall – if this method is called from within that class, we should return index on SURL, not LFNs Do not set it to True for a normal call, unless you really know what you are doing !!
pinFile(path, lifetime=86400)

Pin a file with a given lifetime

Parameters:
  • self – self reference
  • path (str) – PFN path
  • lifetime (int) – pin lifetime in seconds (default 24h)
prestageFile(path, lifetime=86400)

Issue prestage request for file

Parameters:
  • self – self reference
  • path (str) – PFN path
  • lifetime (int) – prestage lifetime in seconds (default 24h)
prestageFileStatus(path)

Monitor prestage request for files

putDirectory(path)

cp -R local SE puts a local directory to the physical storage together with all its files and subdirectories

Parameters:
  • self – self reference
  • path (str) – local fs path
putFile(path, sourceSize=0)

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

releaseFile(path)

Release a pinned file

Parameters:
  • self – self reference
  • path (str) – PFN path
removeDirectory(path, recursive=False)

Remove a directory

removeFile(path)

rm path on storage

Parameters:
  • self – self reference
  • path (str) – file 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