Skip to content

Replicaclient

ReplicaClient(rucio_host=None, auth_host=None, account=None, ca_cert=None, auth_type=None, creds=None, timeout=600, user_agent='rucio-clients', vo=None, logger=LOG)

Replica client class for working with replicas

Constructor of the BaseClient.

Parameters:

Name Type Description Default
rucio_host Optional[str]

The address of the rucio server, if None it is read from the config file.

None
rucio_port

The port of the rucio server, if None it is read from the config file.

required
auth_host Optional[str]

The address of the rucio authentication server, if None it is read from the config file.

None
auth_port

The port of the rucio authentication server, if None it is read from the config file.

required
account Optional[str]

The account to authenticate to rucio.

None
use_ssl

Enable or disable ssl for commucation. Default is enabled.

required
ca_cert Optional[str]

The path to the rucio server certificate.

None
auth_type Optional[str]

The type of authentication (e.g.: 'userpass', 'kerberos' ...)

None
creds Optional[dict[str, Any]]

Dictionary with credentials needed for authentication.

None
user_agent Optional[str]

Indicates the client.

'rucio-clients'
vo Optional[str]

The VO to authenticate into.

None
logger Logger

Logger object to use. If None, use the default LOG created by the module

LOG

quarantine_replicas(replicas, rse=None, rse_id=None)

Add quaratined replicas for RSE.

Parameters:

Name Type Description Default
replicas

List of replica infos: {'scope': (optional), 'name': (optional), 'path': (required)}.

required
rse

RSE name.

None
rse_id

RSE id. Either RSE name or RSE id must be specified, but not both

None

declare_bad_file_replicas(replicas, reason, force=False)

Declare a list of bad replicas.

Parameters:

Name Type Description Default
replicas

Either a list of PFNs (string) or a list of dicts {'scope': , 'name': , 'rse_id': or 'rse': }

required
reason

The reason of the loss.

required
force

boolean, tell the serrver to ignore existing replica status in the bad_replicas table. Default: False

False

Returns:

Type Description

Dictionary {"rse_name": ["did: error",...]} - list of strings for DIDs failed to declare, by RSE

declare_bad_did_replicas(rse, dids, reason)

Declare a list of bad replicas.

Parameters:

Name Type Description Default
rse

The RSE where the bad replicas reside

required
dids

The DIDs of the bad replicas

required
reason

The reason of the loss.

required

declare_suspicious_file_replicas(pfns, reason)

Declare a list of bad replicas.

Parameters:

Name Type Description Default
pfns

The list of PFNs.

required
reason

The reason of the loss.

required

get_did_from_pfns(pfns, rse=None)

Get the DIDs associated to a PFN on one given RSE

Parameters:

Name Type Description Default
pfns

The list of PFNs.

required
rse

The RSE name.

None

Returns:

Type Description

A list of dictionaries {pfn: {'scope': scope, 'name': name}}

list_replicas(dids, schemes=None, ignore_availability=True, all_states=False, metalink=False, rse_expression=None, client_location=None, sort=None, domain=None, signature_lifetime=None, nrandom=None, resolve_archives=True, resolve_parents=False, updated_after=None)

List file replicas for a list of data identifiers (DIDs).

Parameters:

Name Type Description Default
dids

The list of data identifiers (DIDs) like : [{'scope': , 'name': }, {'scope': , 'name': }, ...]

required
schemes

A list of schemes to filter the replicas. (e.g. file, http, ...)

None
ignore_availability

Also include replicas from blocked RSEs into the list

True
metalink

False (default) retrieves as JSON, True retrieves as metalink4+xml.

False
rse_expression

The RSE expression to restrict replicas on a set of RSEs.

None
client_location

Client location dictionary for PFN modification {'ip', 'fqdn', 'site', 'latitude', 'longitude'}

None
sort

Sort the replicas: geoip - based on src/dst IP topographical distance closeness - based on src/dst closeness dynamic - Rucio Dynamic Smart Sort (tm)

None
domain

Define the domain. None is fallback to 'wan', otherwise 'wan, 'lan', or 'all'

None
signature_lifetime

If supported, in seconds, restrict the lifetime of the signed PFN.

None
nrandom

pick N random replicas. If the initial number of replicas is smaller than N, returns all replicas.

None
resolve_archives

When set to True, find archives which contain the replicas.

True
resolve_parents

When set to True, find all parent datasets which contain the replicas.

False
updated_after

epoch timestamp or datetime object (UTC time), only return replicas updated after this time

None

Returns:

Type Description

A list of dictionaries with replica information.

list_suspicious_replicas(rse_expression=None, younger_than=None, nattempts=None)

List file replicas tagged as suspicious.

Parameters:

Name Type Description Default
rse_expression

The RSE expression to restrict replicas on a set of RSEs.

None
younger_than

Datetime object to select the replicas which were declared since younger_than date. Default value = 10 days ago.

None
nattempts

The minimum number of replica appearances in the bad_replica DB table from younger_than date. Default value = 0.

None
state

State of the replica, either 'BAD' or 'SUSPICIOUS'. No value returns replicas with either state.

required

add_replica(rse, scope, name, bytes_, adler32, pfn=None, md5=None, meta=None)

Add file replicas to a RSE.

Parameters:

Name Type Description Default
rse str

the RSE name.

required
scope str

The scope of the file.

required
name str

The name of the file.

required
bytes_ int

The size in bytes.

required
adler32 str

adler32 checksum.

required
pfn Optional[str]

PFN of the file for non deterministic RSE.

None
md5 Optional[str]

md5 checksum.

None
meta Optional[dict[str, Any]]

Metadata attributes.

None

Returns:

Type Description
bool

True if files were created successfully.

add_replicas(rse, files, ignore_availability=True)

Bulk add file replicas to a RSE.

Parameters:

Name Type Description Default
rse

the RSE name.

required
files

The list of files. This is a list of DIDs like : [{'scope': , 'name': }, {'scope': , 'name': }, ...]

required
ignore_availability

Ignore the RSE blocklsit.

True

Returns:

Type Description

True if files were created successfully.

delete_replicas(rse, files, ignore_availability=True)

Bulk delete file replicas from a RSE.

Parameters:

Name Type Description Default
rse

the RSE name.

required
files

The list of files. This is a list of DIDs like : [{'scope': , 'name': }, {'scope': , 'name': }, ...]

required
ignore_availability

Ignore the RSE blocklist.

True

Returns:

Type Description

True if files have been deleted successfully.

update_replicas_states(rse, files)

Bulk update the file replicas states from a RSE.

Parameters:

Name Type Description Default
rse

the RSE name.

required
files

The list of files. This is a list of DIDs like : [{'scope': , 'name': , 'state': }, {'scope': , 'name': , 'state': }, ...], where a state value can be either of: 'A' (AVAILABLE) 'U' (UNAVAILABLE) 'C' (COPYING) 'B' (BEING_DELETED) 'D' (BAD) 'T' (TEMPORARY_UNAVAILABLE)

required

Returns:

Type Description

True if replica states have been updated successfully, otherwise an exception is raised.

list_dataset_replicas(scope, name, deep=False)

List dataset replicas for a did (scope:name).

Parameters:

Name Type Description Default
scope

The scope of the dataset.

required
name

The name of the dataset.

required
deep

Lookup at the file level.

False

Returns:

Type Description

A list of dict dataset replicas.

list_dataset_replicas_bulk(dids)

List dataset replicas for a did (scope:name).

Parameters:

Name Type Description Default
dids

The list of DIDs of the datasets.

required

Returns:

Type Description

A list of dict dataset replicas.

list_dataset_replicas_vp(scope, name, deep=False)

List dataset replicas for a DID (scope:name) using the Virtual Placement service.

NOTICE: This is an RnD function and might change or go away at any time.

Parameters:

Name Type Description Default
scope

The scope of the dataset.

required
name

The name of the dataset.

required
deep

Lookup at the file level.

False

Returns:

Type Description

If VP exists a list of dicts of sites

list_datasets_per_rse(rse, filters=None, limit=None)

List datasets at a RSE.

Parameters:

Name Type Description Default
rse

the rse name.

required
filters

dictionary of attributes by which the results should be filtered.

None
limit

limit number.

None

Returns:

Type Description

A list of dict dataset replicas.

add_bad_pfns(pfns, reason, state, expires_at)

Declare a list of bad replicas.

Parameters:

Name Type Description Default
pfns

The list of PFNs.

required
reason

The reason of the loss.

required
state

The state of the replica. Either BAD, SUSPICIOUS, TEMPORARY_UNAVAILABLE

required
expires_at

Specify a timeout for the TEMPORARY_UNAVAILABLE replicas. None for BAD files.

required

Returns:

Type Description

True if PFNs were created successfully.

set_tombstone(replicas)

Set a tombstone on a list of replicas.

Parameters:

Name Type Description Default
replicas

list of replicas.

required