Protocol
This module defines the base class for implementing a transfer protocol, along with some of the default methods for LFN2PFN translations.
RSEProtocol(protocol_attr, rse_settings, logger=logging.log)
¶
This class is virtual and acts as a base to inherit new protocols from. It further provides some common functionality which applies for the majority of the protocols.
Initializes the object with information about the referred RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
protocol_attr
|
Properties of the requested protocol. |
required | |
rse_settting
|
The RSE settings. |
required | |
logger
|
Optional decorated logger that can be passed from the calling daemons or servers. |
log
|
lfns2pfns(lfns)
¶
Returns a fully qualified PFN for the file referred by path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
The path to the file. |
required |
Returns:
Type | Description |
---|---|
Fully qualified PFN. |
__lfns2pfns_client(lfns)
¶
Provides the path of a replica for non-deterministic sites. Will be assigned to get path by the init method if necessary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope
|
list of DIDs |
required |
Returns:
Type | Description |
---|---|
dict with scope:name as keys and PFN as value (in case of errors the Rucio exception si assigned to the key) |
_get_path(scope, name)
¶
Transforms the logical file name into a PFN. Suitable for sites implementing the RUCIO naming convention. This implementation is only invoked if the RSE is deterministic.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scope
|
scope |
required | |
name
|
filename |
required |
Returns:
Type | Description |
---|---|
RSE specific URI of the physical file |
_get_path_nondeterministic_server(scope, name)
¶
Provides the path of a replica for non-deterministic sites. Will be assigned to get path by the init method if necessary.
parse_pfns(pfns)
¶
Splits the given PFN into the parts known by the protocol. It is also checked if the provided protocol supports the given PFNs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pfns
|
a list of a fully qualified PFNs |
required |
Returns:
Type | Description |
---|---|
dic with PFN as key and a dict with path and name as value |
Raises:
Type | Description |
---|---|
RSEFileNameNotSupported
|
if the provided PFN doesn't match with the protocol settings |
exists(path)
abstractmethod
¶
Checks if the requested file is known by the referred RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Physical file name |
required |
Returns:
Type | Description |
---|---|
True if the file exists, False if it doesn't |
Raises:
Type | Description |
---|---|
SourceNotFound
|
if the source file was not found on the referred storage. |
connect()
abstractmethod
¶
Establishes the actual connection to the referred RSE.
Raises:
Type | Description |
---|---|
RSEAccessDenied
|
if no connection could be established. |
close()
abstractmethod
¶
Closes the connection to RSE.
get(path, dest, transfer_timeout=None)
abstractmethod
¶
Provides access to files stored inside connected the RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Physical file name of requested file |
required | |
dest
|
Name and path of the files when stored at the client |
required | |
transfer_timeout
|
Transfer timeout (in seconds) |
None
|
Raises:
Type | Description |
---|---|
DestinationNotAccessible
|
if the destination storage was not accessible. |
ServiceUnavailable
|
if some generic error occurred in the library. |
SourceNotFound
|
if the source file was not found on the referred storage. |
put(source, target, source_dir, transfer_timeout=None)
abstractmethod
¶
Allows to store files inside the referred RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
path to the source file on the client file system |
required | |
target
|
path to the destination file on the storage |
required | |
source_dir
|
Path where the to be transferred files are stored in the local file system |
required | |
transfer_timeout
|
Transfer timeout (in seconds) |
None
|
Raises:
Type | Description |
---|---|
DestinationNotAccessible
|
if the destination storage was not accessible. |
ServiceUnavailable
|
if some generic error occurred in the library. |
SourceNotFound
|
if the source file was not found on the referred storage. |
delete(path)
abstractmethod
¶
Deletes a file from the connected RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
path to the to be deleted file |
required |
Raises:
Type | Description |
---|---|
ServiceUnavailable
|
if some generic error occurred in the library. |
SourceNotFound
|
if the source file was not found on the referred storage. |
rename(path, new_path)
abstractmethod
¶
Allows to rename a file stored inside the connected RSE.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
path to the current file on the storage |
required | |
new_path
|
path to the new file on the storage |
required |
Raises:
Type | Description |
---|---|
DestinationNotAccessible
|
if the destination storage was not accessible. |
ServiceUnavailable
|
if some generic error occurred in the library. |
SourceNotFound
|
if the source file was not found on the referred storage. |
get_space_usage()
¶
Get RSE space usage information.
Returns:
Type | Description |
---|---|
a list with dict containing 'totalsize' and 'unusedsize' |
Raises:
Type | Description |
---|---|
ServiceUnavailable
|
if some generic error occurred in the library. |
stat(path)
¶
Returns the stats of a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
path to file |
required |
Returns:
Type | Description |
---|---|
a dict with two keys, filesize and adler32 of the file provided in path. |
Raises:
Type | Description |
---|---|
ServiceUnavailable
|
if some generic error occurred in the library. |
SourceNotFound
|
if the source file was not found on the referred storage. |