rucio-clients 35.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rucio-clients might be problematic. Click here for more details.
- rucio/__init__.py +17 -0
- rucio/alembicrevision.py +15 -0
- rucio/client/__init__.py +15 -0
- rucio/client/accountclient.py +433 -0
- rucio/client/accountlimitclient.py +183 -0
- rucio/client/baseclient.py +974 -0
- rucio/client/client.py +76 -0
- rucio/client/configclient.py +126 -0
- rucio/client/credentialclient.py +59 -0
- rucio/client/didclient.py +866 -0
- rucio/client/diracclient.py +56 -0
- rucio/client/downloadclient.py +1785 -0
- rucio/client/exportclient.py +44 -0
- rucio/client/fileclient.py +50 -0
- rucio/client/importclient.py +42 -0
- rucio/client/lifetimeclient.py +90 -0
- rucio/client/lockclient.py +109 -0
- rucio/client/metaconventionsclient.py +140 -0
- rucio/client/pingclient.py +44 -0
- rucio/client/replicaclient.py +454 -0
- rucio/client/requestclient.py +125 -0
- rucio/client/rseclient.py +746 -0
- rucio/client/ruleclient.py +294 -0
- rucio/client/scopeclient.py +90 -0
- rucio/client/subscriptionclient.py +173 -0
- rucio/client/touchclient.py +82 -0
- rucio/client/uploadclient.py +955 -0
- rucio/common/__init__.py +13 -0
- rucio/common/cache.py +74 -0
- rucio/common/config.py +801 -0
- rucio/common/constants.py +159 -0
- rucio/common/constraints.py +17 -0
- rucio/common/didtype.py +189 -0
- rucio/common/exception.py +1151 -0
- rucio/common/extra.py +36 -0
- rucio/common/logging.py +420 -0
- rucio/common/pcache.py +1408 -0
- rucio/common/plugins.py +153 -0
- rucio/common/policy.py +84 -0
- rucio/common/schema/__init__.py +150 -0
- rucio/common/schema/atlas.py +413 -0
- rucio/common/schema/belleii.py +408 -0
- rucio/common/schema/domatpc.py +401 -0
- rucio/common/schema/escape.py +426 -0
- rucio/common/schema/generic.py +433 -0
- rucio/common/schema/generic_multi_vo.py +412 -0
- rucio/common/schema/icecube.py +406 -0
- rucio/common/stomp_utils.py +159 -0
- rucio/common/stopwatch.py +55 -0
- rucio/common/test_rucio_server.py +148 -0
- rucio/common/types.py +403 -0
- rucio/common/utils.py +2238 -0
- rucio/rse/__init__.py +96 -0
- rucio/rse/protocols/__init__.py +13 -0
- rucio/rse/protocols/bittorrent.py +184 -0
- rucio/rse/protocols/cache.py +122 -0
- rucio/rse/protocols/dummy.py +111 -0
- rucio/rse/protocols/gfal.py +703 -0
- rucio/rse/protocols/globus.py +243 -0
- rucio/rse/protocols/gsiftp.py +92 -0
- rucio/rse/protocols/http_cache.py +82 -0
- rucio/rse/protocols/mock.py +123 -0
- rucio/rse/protocols/ngarc.py +209 -0
- rucio/rse/protocols/posix.py +250 -0
- rucio/rse/protocols/protocol.py +594 -0
- rucio/rse/protocols/rclone.py +364 -0
- rucio/rse/protocols/rfio.py +136 -0
- rucio/rse/protocols/srm.py +338 -0
- rucio/rse/protocols/ssh.py +413 -0
- rucio/rse/protocols/storm.py +206 -0
- rucio/rse/protocols/webdav.py +550 -0
- rucio/rse/protocols/xrootd.py +301 -0
- rucio/rse/rsemanager.py +764 -0
- rucio/vcsversion.py +11 -0
- rucio/version.py +38 -0
- rucio_clients-35.7.0.data/data/etc/rse-accounts.cfg.template +25 -0
- rucio_clients-35.7.0.data/data/etc/rucio.cfg.atlas.client.template +42 -0
- rucio_clients-35.7.0.data/data/etc/rucio.cfg.template +257 -0
- rucio_clients-35.7.0.data/data/requirements.client.txt +15 -0
- rucio_clients-35.7.0.data/data/rucio_client/merge_rucio_configs.py +144 -0
- rucio_clients-35.7.0.data/scripts/rucio +2542 -0
- rucio_clients-35.7.0.data/scripts/rucio-admin +2447 -0
- rucio_clients-35.7.0.dist-info/METADATA +50 -0
- rucio_clients-35.7.0.dist-info/RECORD +88 -0
- rucio_clients-35.7.0.dist-info/WHEEL +5 -0
- rucio_clients-35.7.0.dist-info/licenses/AUTHORS.rst +97 -0
- rucio_clients-35.7.0.dist-info/licenses/LICENSE +201 -0
- rucio_clients-35.7.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
# Copyright European Organization for Nuclear Research (CERN) since 2012
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from json import dumps, loads
|
|
16
|
+
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
|
|
17
|
+
from urllib.parse import quote
|
|
18
|
+
|
|
19
|
+
from requests.status_codes import codes
|
|
20
|
+
|
|
21
|
+
from rucio.client.baseclient import BaseClient, choice
|
|
22
|
+
from rucio.common.utils import build_url
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
from collections.abc import Iterable, Iterator
|
|
26
|
+
|
|
27
|
+
from rucio.common.constants import RSE_SUPPORTED_PROTOCOL_DOMAINS_LITERAL, RSE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL, SUPPORTED_PROTOCOLS_LITERAL
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class RSEClient(BaseClient):
|
|
31
|
+
"""RSE client class for working with rucio RSEs"""
|
|
32
|
+
|
|
33
|
+
RSE_BASEURL = 'rses'
|
|
34
|
+
|
|
35
|
+
def get_rse(self, rse: str) -> dict[str, Any]:
|
|
36
|
+
"""
|
|
37
|
+
Returns details about the referred RSE.
|
|
38
|
+
|
|
39
|
+
:param rse: Name of the referred RSE
|
|
40
|
+
|
|
41
|
+
:returns: A dict containing all attributes of the referred RSE
|
|
42
|
+
|
|
43
|
+
:raises RSENotFound: if the referred RSE was not found in the database
|
|
44
|
+
"""
|
|
45
|
+
path = '/'.join([self.RSE_BASEURL, rse])
|
|
46
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
47
|
+
|
|
48
|
+
r = self._send_request(url, type_='GET')
|
|
49
|
+
if r.status_code == codes.ok:
|
|
50
|
+
rse_dict = loads(r.text)
|
|
51
|
+
return rse_dict
|
|
52
|
+
else:
|
|
53
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
54
|
+
raise exc_cls(exc_msg)
|
|
55
|
+
|
|
56
|
+
def add_rse(self, rse: str, **kwargs) -> Literal[True]:
|
|
57
|
+
"""
|
|
58
|
+
Sends the request to create a new RSE.
|
|
59
|
+
|
|
60
|
+
:param rse: the name of the rse.
|
|
61
|
+
:param deterministic: Boolean to know if the pfn is generated deterministically.
|
|
62
|
+
:param volatile: Boolean for RSE cache.
|
|
63
|
+
:param city: City for the RSE.
|
|
64
|
+
:param region_code: The region code for the RSE.
|
|
65
|
+
:param country_name: The country.
|
|
66
|
+
:param continent: The continent.
|
|
67
|
+
:param time_zone: Timezone.
|
|
68
|
+
:param staging_area: Staging area.
|
|
69
|
+
:param ISP: Internet service provider.
|
|
70
|
+
:param rse_type: RSE type.
|
|
71
|
+
:param latitude: Latitude coordinate of RSE.
|
|
72
|
+
:param longitude: Longitude coordinate of RSE.
|
|
73
|
+
:param ASN: Access service network.
|
|
74
|
+
:param availability: Availability.
|
|
75
|
+
|
|
76
|
+
:return: True if location was created successfully else False.
|
|
77
|
+
:raises Duplicate: if rse already exists.
|
|
78
|
+
"""
|
|
79
|
+
path = 'rses/' + rse
|
|
80
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
81
|
+
r = self._send_request(url, type_='POST', data=dumps(kwargs))
|
|
82
|
+
if r.status_code == codes.created:
|
|
83
|
+
return True
|
|
84
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
85
|
+
raise exc_cls(exc_msg)
|
|
86
|
+
|
|
87
|
+
def update_rse(self, rse: str, parameters: dict[str, Any]) -> Literal[True]:
|
|
88
|
+
"""
|
|
89
|
+
Update RSE properties like availability or name.
|
|
90
|
+
|
|
91
|
+
:param rse: the name of the new rse.
|
|
92
|
+
:param parameters: A dictionary with property (name, read, write, delete as keys).
|
|
93
|
+
"""
|
|
94
|
+
path = 'rses/' + rse
|
|
95
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
96
|
+
r = self._send_request(url, type_='PUT', data=dumps(parameters))
|
|
97
|
+
if r.status_code == codes.created:
|
|
98
|
+
return True
|
|
99
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
100
|
+
raise exc_cls(exc_msg)
|
|
101
|
+
|
|
102
|
+
def delete_rse(self, rse: str) -> Literal[True]:
|
|
103
|
+
"""
|
|
104
|
+
Sends the request to delete a rse.
|
|
105
|
+
|
|
106
|
+
:param rse: the name of the rse.
|
|
107
|
+
:return: True if location was created successfully else False.
|
|
108
|
+
"""
|
|
109
|
+
path = 'rses/' + rse
|
|
110
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
111
|
+
r = self._send_request(url, type_='DEL')
|
|
112
|
+
if r.status_code == codes.ok:
|
|
113
|
+
return True
|
|
114
|
+
else:
|
|
115
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
116
|
+
raise exc_cls(exc_msg)
|
|
117
|
+
|
|
118
|
+
def list_rses(self, rse_expression: Optional[str] = None) -> "Iterator[dict[str, Any]]":
|
|
119
|
+
"""
|
|
120
|
+
Sends the request to list all rucio locations(RSEs).
|
|
121
|
+
|
|
122
|
+
:rse_expression: RSE Expression to use as filter.
|
|
123
|
+
:return: a list containing the names of all rucio locations.
|
|
124
|
+
"""
|
|
125
|
+
if rse_expression:
|
|
126
|
+
path = ['rses', "?expression=" + quote(rse_expression)]
|
|
127
|
+
path = '/'.join(path)
|
|
128
|
+
else:
|
|
129
|
+
path = 'rses/'
|
|
130
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
131
|
+
r = self._send_request(url, type_='GET')
|
|
132
|
+
if r.status_code == codes.ok:
|
|
133
|
+
return self._load_json_data(r)
|
|
134
|
+
else:
|
|
135
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
136
|
+
raise exc_cls(exc_msg)
|
|
137
|
+
|
|
138
|
+
def add_rse_attribute(
|
|
139
|
+
self,
|
|
140
|
+
rse: str,
|
|
141
|
+
key: str,
|
|
142
|
+
value: Any
|
|
143
|
+
) -> Literal[True]:
|
|
144
|
+
"""
|
|
145
|
+
Sends the request to add a RSE attribute.
|
|
146
|
+
|
|
147
|
+
:param rse: the name of the rse.
|
|
148
|
+
:param key: the attribute key.
|
|
149
|
+
:param value: the attribute value.
|
|
150
|
+
|
|
151
|
+
:return: True if RSE attribute was created successfully else False.
|
|
152
|
+
:raises Duplicate: if RSE attribute already exists.
|
|
153
|
+
"""
|
|
154
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'attr', key])
|
|
155
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
156
|
+
data = dumps({'value': value})
|
|
157
|
+
|
|
158
|
+
r = self._send_request(url, type_='POST', data=data)
|
|
159
|
+
if r.status_code == codes.created:
|
|
160
|
+
return True
|
|
161
|
+
else:
|
|
162
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
163
|
+
raise exc_cls(exc_msg)
|
|
164
|
+
|
|
165
|
+
def delete_rse_attribute(self, rse: str, key: str) -> Literal[True]:
|
|
166
|
+
"""
|
|
167
|
+
Sends the request to delete a RSE attribute.
|
|
168
|
+
|
|
169
|
+
:param rse: the RSE name.
|
|
170
|
+
:param key: the attribute key.
|
|
171
|
+
|
|
172
|
+
:return: True if RSE attribute was deleted successfully else False.
|
|
173
|
+
"""
|
|
174
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'attr', key])
|
|
175
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
176
|
+
|
|
177
|
+
r = self._send_request(url, type_='DEL')
|
|
178
|
+
if r.status_code == codes.ok:
|
|
179
|
+
return True
|
|
180
|
+
else:
|
|
181
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
182
|
+
raise exc_cls(exc_msg)
|
|
183
|
+
|
|
184
|
+
def list_rse_attributes(self, rse: str) -> dict[str, Any]:
|
|
185
|
+
"""
|
|
186
|
+
Sends the request to get RSE attributes.
|
|
187
|
+
|
|
188
|
+
:param rse: The RSE name.
|
|
189
|
+
|
|
190
|
+
:return: A ``dict`` with the RSE attribute name/value pairs.
|
|
191
|
+
"""
|
|
192
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'attr/'])
|
|
193
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
194
|
+
r = self._send_request(url, type_='GET')
|
|
195
|
+
if r.status_code == codes.ok:
|
|
196
|
+
attributes = loads(r.text)
|
|
197
|
+
return attributes
|
|
198
|
+
else:
|
|
199
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
200
|
+
raise exc_cls(exc_msg)
|
|
201
|
+
|
|
202
|
+
def add_protocol(self, rse: str, params: dict[str, Any]) -> Literal[True]:
|
|
203
|
+
"""
|
|
204
|
+
Sends the request to create a new protocol for the given RSE.
|
|
205
|
+
|
|
206
|
+
:param rse: the name of the rse.
|
|
207
|
+
:param scheme: identifier of this protocol
|
|
208
|
+
:param params: Attributes of the protocol. Supported are:
|
|
209
|
+
hostname: hostname for this protocol (default = localhost)
|
|
210
|
+
port: port for this protocol (default = 0)
|
|
211
|
+
prefix: string used as a prfeix for this protocol when generating the PFN (default = None)
|
|
212
|
+
impl: qualified name of the implementation class for this protocol (mandatory)
|
|
213
|
+
read: integer representing the priority of this procotol for read operations (default = -1)
|
|
214
|
+
write: integer representing the priority of this procotol for write operations (default = -1)
|
|
215
|
+
delete: integer representing the priority of this procotol for delete operations (default = -1)
|
|
216
|
+
extended_attributes: miscellaneous protocol specific information e.g. spacetoken for SRM (default = None)
|
|
217
|
+
|
|
218
|
+
:return: True if protocol was created successfully else False.
|
|
219
|
+
|
|
220
|
+
:raises Duplicate: if protocol with same hostname, port and protocol identifier
|
|
221
|
+
already exists for the given RSE.
|
|
222
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
223
|
+
:raises KeyNotFound: if params is missing manadtory attributes to create the
|
|
224
|
+
protocol.
|
|
225
|
+
:raises AccessDenied: if not authorized.
|
|
226
|
+
"""
|
|
227
|
+
scheme = params['scheme']
|
|
228
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'protocols', scheme])
|
|
229
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
230
|
+
r = self._send_request(url, type_='POST', data=dumps(params))
|
|
231
|
+
if r.status_code == codes.created:
|
|
232
|
+
return True
|
|
233
|
+
else:
|
|
234
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
235
|
+
raise exc_cls(exc_msg)
|
|
236
|
+
|
|
237
|
+
def get_protocols(
|
|
238
|
+
self,
|
|
239
|
+
rse: str,
|
|
240
|
+
protocol_domain: "RSE_SUPPORTED_PROTOCOL_DOMAINS_LITERAL" = 'ALL',
|
|
241
|
+
operation: Optional["RSE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL"] = None,
|
|
242
|
+
default: bool = False,
|
|
243
|
+
scheme: Optional['SUPPORTED_PROTOCOLS_LITERAL'] = None
|
|
244
|
+
) -> Any:
|
|
245
|
+
"""
|
|
246
|
+
Returns protocol information. Parameter combinations are:
|
|
247
|
+
(operation OR default) XOR protocol.
|
|
248
|
+
|
|
249
|
+
:param rse: the RSE name.
|
|
250
|
+
:param protocol_domain: The scope of the protocol. Supported are 'LAN', 'WAN', and 'ALL' (as default).
|
|
251
|
+
:param operation: The name of the requested operation (read, write, or delete).
|
|
252
|
+
If None, all operations are queried.
|
|
253
|
+
:param default: Indicates if only the default operations should be returned.
|
|
254
|
+
:param scheme: The identifier of the requested protocol.
|
|
255
|
+
|
|
256
|
+
:returns: A dict with details about each matching protocol.
|
|
257
|
+
|
|
258
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
259
|
+
:raises RSEProtocolNotSupported: if no matching protocol entry could be found.
|
|
260
|
+
:raises RSEOperationNotSupported: if no matching protocol entry for the requested
|
|
261
|
+
operation could be found.
|
|
262
|
+
"""
|
|
263
|
+
|
|
264
|
+
path = None
|
|
265
|
+
params = {}
|
|
266
|
+
if scheme:
|
|
267
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'protocols', scheme])
|
|
268
|
+
else:
|
|
269
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'protocols'])
|
|
270
|
+
if operation:
|
|
271
|
+
params['operation'] = operation
|
|
272
|
+
if default:
|
|
273
|
+
params['default'] = default
|
|
274
|
+
params['protocol_domain'] = protocol_domain
|
|
275
|
+
url = build_url(choice(self.list_hosts), path=path, params=params)
|
|
276
|
+
|
|
277
|
+
r = self._send_request(url, type_='GET')
|
|
278
|
+
if r.status_code == codes.ok:
|
|
279
|
+
protocols = loads(r.text)
|
|
280
|
+
return protocols
|
|
281
|
+
else:
|
|
282
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
283
|
+
raise exc_cls(exc_msg)
|
|
284
|
+
|
|
285
|
+
def lfns2pfns(
|
|
286
|
+
self,
|
|
287
|
+
rse: str,
|
|
288
|
+
lfns: 'Iterable[str]',
|
|
289
|
+
protocol_domain: 'RSE_SUPPORTED_PROTOCOL_DOMAINS_LITERAL' = 'ALL',
|
|
290
|
+
operation: Optional['RSE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL'] = None,
|
|
291
|
+
scheme: Optional['SUPPORTED_PROTOCOLS_LITERAL'] = None
|
|
292
|
+
) -> dict[str, str]:
|
|
293
|
+
"""
|
|
294
|
+
Returns PFNs that should be used at a RSE, corresponding to requested LFNs.
|
|
295
|
+
The PFNs are generated for the RSE *regardless* of whether a replica exists for the LFN.
|
|
296
|
+
|
|
297
|
+
:param rse: the RSE name
|
|
298
|
+
:param lfns: A list of LFN strings to translate to PFNs.
|
|
299
|
+
:param protocol_domain: The scope of the protocol. Supported are 'LAN', 'WAN', and 'ALL' (as default).
|
|
300
|
+
:param operation: The name of the requested operation (read, write, or delete).
|
|
301
|
+
If None, all operations are queried.
|
|
302
|
+
:param scheme: The identifier of the requested protocol (gsiftp, https, davs, etc).
|
|
303
|
+
|
|
304
|
+
:returns: A dictionary of LFN / PFN pairs.
|
|
305
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
306
|
+
:raises RSEProtocolNotSupported: if no matching protocol entry could be found.
|
|
307
|
+
:raises RSEOperationNotSupported: if no matching protocol entry for the requested
|
|
308
|
+
operation could be found.
|
|
309
|
+
"""
|
|
310
|
+
path = '/'.join([self.RSE_BASEURL, rse, 'lfns2pfns'])
|
|
311
|
+
params = []
|
|
312
|
+
if scheme:
|
|
313
|
+
params.append(('scheme', scheme))
|
|
314
|
+
if protocol_domain != 'ALL':
|
|
315
|
+
params.append(('domain', protocol_domain))
|
|
316
|
+
if operation:
|
|
317
|
+
params.append(('operation', operation))
|
|
318
|
+
for lfn in lfns:
|
|
319
|
+
params.append(('lfn', lfn))
|
|
320
|
+
|
|
321
|
+
url = build_url(choice(self.list_hosts), path=path, params=params, doseq=True)
|
|
322
|
+
|
|
323
|
+
r = self._send_request(url, type_='GET')
|
|
324
|
+
if r.status_code == codes.ok:
|
|
325
|
+
pfns = loads(r.text)
|
|
326
|
+
return pfns
|
|
327
|
+
else:
|
|
328
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
329
|
+
raise exc_cls(exc_msg)
|
|
330
|
+
|
|
331
|
+
def delete_protocols(
|
|
332
|
+
self,
|
|
333
|
+
rse: str,
|
|
334
|
+
scheme: 'SUPPORTED_PROTOCOLS_LITERAL',
|
|
335
|
+
hostname: Optional[str] = None,
|
|
336
|
+
port: Optional[int] = None
|
|
337
|
+
) -> Literal[True]:
|
|
338
|
+
"""
|
|
339
|
+
Deletes matching protocols from RSE. Protocols using the same identifier can be
|
|
340
|
+
distinguished by hostname and port.
|
|
341
|
+
|
|
342
|
+
:param rse: the RSE name.
|
|
343
|
+
:param scheme: identifier of the protocol.
|
|
344
|
+
:param hostname: hostname of the protocol.
|
|
345
|
+
:param port: port of the protocol.
|
|
346
|
+
|
|
347
|
+
:returns: True if success.
|
|
348
|
+
|
|
349
|
+
:raises RSEProtocolNotSupported: if no matching protocol entry could be found.
|
|
350
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
351
|
+
:raises AccessDenied: if not authorized.
|
|
352
|
+
"""
|
|
353
|
+
path = [self.RSE_BASEURL, rse, 'protocols', scheme]
|
|
354
|
+
if hostname:
|
|
355
|
+
path.append(hostname)
|
|
356
|
+
if port:
|
|
357
|
+
path.append(str(port))
|
|
358
|
+
|
|
359
|
+
path = '/'.join(path)
|
|
360
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
361
|
+
r = self._send_request(url, type_='DEL')
|
|
362
|
+
if r.status_code == codes.ok:
|
|
363
|
+
return True
|
|
364
|
+
else:
|
|
365
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
366
|
+
raise exc_cls(exc_msg)
|
|
367
|
+
|
|
368
|
+
def update_protocols(
|
|
369
|
+
self,
|
|
370
|
+
rse: str,
|
|
371
|
+
scheme: 'SUPPORTED_PROTOCOLS_LITERAL',
|
|
372
|
+
data: dict[str, Any],
|
|
373
|
+
hostname: Optional[str] = None,
|
|
374
|
+
port: Optional[int] = None):
|
|
375
|
+
"""
|
|
376
|
+
Updates matching protocols from RSE. Protocol using the same identifier can be
|
|
377
|
+
distinguished by hostname and port.
|
|
378
|
+
|
|
379
|
+
:param rse: the RSE name.
|
|
380
|
+
:param scheme: identifier of the protocol.
|
|
381
|
+
:param data: A dict providing the new values of the protocol attributes.
|
|
382
|
+
Keys must match column names in database.
|
|
383
|
+
:param hostname: hostname of the protocol.
|
|
384
|
+
:param port: port of the protocol.
|
|
385
|
+
|
|
386
|
+
:returns: True if success.
|
|
387
|
+
|
|
388
|
+
:raises RSEProtocolNotSupported: if no matching protocol entry could be found.
|
|
389
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
390
|
+
:raises KeyNotFound: if invalid data was provided for update.
|
|
391
|
+
:raises AccessDenied: if not authorized.
|
|
392
|
+
"""
|
|
393
|
+
path = [self.RSE_BASEURL, rse, 'protocols', scheme]
|
|
394
|
+
if hostname:
|
|
395
|
+
path.append(hostname)
|
|
396
|
+
if port:
|
|
397
|
+
path.append(str(port))
|
|
398
|
+
|
|
399
|
+
path = '/'.join(path)
|
|
400
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
401
|
+
r = self._send_request(url, type_='PUT', data=dumps(data))
|
|
402
|
+
if r.status_code == codes.ok:
|
|
403
|
+
return True
|
|
404
|
+
else:
|
|
405
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
406
|
+
raise exc_cls(exc_msg)
|
|
407
|
+
|
|
408
|
+
def swap_protocols(
|
|
409
|
+
self,
|
|
410
|
+
rse: str,
|
|
411
|
+
domain: 'RSE_SUPPORTED_PROTOCOL_DOMAINS_LITERAL',
|
|
412
|
+
operation: 'RSE_SUPPORTED_PROTOCOL_OPERATIONS_LITERAL',
|
|
413
|
+
scheme_a: 'SUPPORTED_PROTOCOLS_LITERAL',
|
|
414
|
+
scheme_b: 'SUPPORTED_PROTOCOLS_LITERAL'
|
|
415
|
+
) -> bool:
|
|
416
|
+
"""
|
|
417
|
+
Swaps the priorities of the provided operation.
|
|
418
|
+
|
|
419
|
+
:param rse: the RSE name.
|
|
420
|
+
:param domain: the domain in which priorities should be swapped i.e. wan or lan.
|
|
421
|
+
:param operation: the operation that should be swapped i.e. read, write, or delete.
|
|
422
|
+
:param scheme_a: the scheme of one of the two protocols to be swapped, e.g. srm.
|
|
423
|
+
:param scheme_b: the scheme of the other of the two protocols to be swapped, e.g. http.
|
|
424
|
+
|
|
425
|
+
:returns: True if success.
|
|
426
|
+
|
|
427
|
+
:raises RSEProtocolNotSupported: if no matching protocol entry could be found.
|
|
428
|
+
:raises RSENotFound: if the RSE doesn't exist.
|
|
429
|
+
:raises KeyNotFound: if invalid data was provided for update.
|
|
430
|
+
:raises AccessDenied: if not authorized.
|
|
431
|
+
"""
|
|
432
|
+
|
|
433
|
+
protocols = self.get_protocols(rse, domain, operation, False, scheme_a)['protocols']
|
|
434
|
+
protocol_a = next((p for p in protocols if p['scheme'] == scheme_a), None)
|
|
435
|
+
protocol_b = next((p for p in protocols if p['scheme'] == scheme_b), None)
|
|
436
|
+
|
|
437
|
+
if protocol_a is None or protocol_b is None:
|
|
438
|
+
return False
|
|
439
|
+
|
|
440
|
+
priority_a = protocol_a['domains'][domain][operation]
|
|
441
|
+
priority_b = protocol_b['domains'][domain][operation]
|
|
442
|
+
self.update_protocols(rse, protocol_a['scheme'], {'domains': {domain: {operation: priority_b}}}, protocol_a['hostname'], protocol_a['port'])
|
|
443
|
+
self.update_protocols(rse, protocol_b['scheme'], {'domains': {domain: {operation: priority_a}}}, protocol_b['hostname'], protocol_b['port'])
|
|
444
|
+
return True
|
|
445
|
+
|
|
446
|
+
def add_qos_policy(self, rse: str, qos_policy: str) -> Literal[True]:
|
|
447
|
+
"""
|
|
448
|
+
Add a QoS policy from an RSE.
|
|
449
|
+
|
|
450
|
+
:param rse_id: The id of the RSE.
|
|
451
|
+
:param qos_policy: The QoS policy to add.
|
|
452
|
+
:param session: The database session in use.
|
|
453
|
+
|
|
454
|
+
:raises Duplicate: If the QoS policy already exists.
|
|
455
|
+
:returns: True if successful, except otherwise.
|
|
456
|
+
"""
|
|
457
|
+
|
|
458
|
+
path = [self.RSE_BASEURL, rse, 'qos_policy', qos_policy]
|
|
459
|
+
path = '/'.join(path)
|
|
460
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
461
|
+
r = self._send_request(url, type_='POST')
|
|
462
|
+
if r.status_code == codes.created:
|
|
463
|
+
return True
|
|
464
|
+
else:
|
|
465
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
466
|
+
raise exc_cls(exc_msg)
|
|
467
|
+
|
|
468
|
+
def delete_qos_policy(self, rse: str, qos_policy: str) -> Literal[True]:
|
|
469
|
+
"""
|
|
470
|
+
Delete a QoS policy from an RSE.
|
|
471
|
+
|
|
472
|
+
:param rse_id: The id of the RSE.
|
|
473
|
+
:param qos_policy: The QoS policy to delete.
|
|
474
|
+
:param session: The database session in use.
|
|
475
|
+
|
|
476
|
+
:returns: True if successful, silent failure if QoS policy does not exist.
|
|
477
|
+
"""
|
|
478
|
+
|
|
479
|
+
path = [self.RSE_BASEURL, rse, 'qos_policy', qos_policy]
|
|
480
|
+
path = '/'.join(path)
|
|
481
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
482
|
+
r = self._send_request(url, type_='DEL')
|
|
483
|
+
if r.status_code == codes.ok:
|
|
484
|
+
return True
|
|
485
|
+
else:
|
|
486
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
487
|
+
raise exc_cls(exc_msg)
|
|
488
|
+
|
|
489
|
+
def list_qos_policies(self, rse: str) -> list[str]:
|
|
490
|
+
"""
|
|
491
|
+
List all QoS policies of an RSE.
|
|
492
|
+
|
|
493
|
+
:param rse_id: The id of the RSE.
|
|
494
|
+
:param session: The database session in use.
|
|
495
|
+
|
|
496
|
+
:returns: List containing all QoS policies.
|
|
497
|
+
"""
|
|
498
|
+
|
|
499
|
+
path = [self.RSE_BASEURL, rse, 'qos_policy']
|
|
500
|
+
path = '/'.join(path)
|
|
501
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
502
|
+
r = self._send_request(url, type_='GET')
|
|
503
|
+
if r.status_code == codes.ok:
|
|
504
|
+
return loads(r.text)
|
|
505
|
+
else:
|
|
506
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
507
|
+
raise exc_cls(exc_msg)
|
|
508
|
+
|
|
509
|
+
def set_rse_usage(
|
|
510
|
+
self,
|
|
511
|
+
rse: str,
|
|
512
|
+
source: str,
|
|
513
|
+
used: int,
|
|
514
|
+
free: int,
|
|
515
|
+
files: Optional[int] = None
|
|
516
|
+
) -> Literal[True]:
|
|
517
|
+
"""
|
|
518
|
+
Set RSE usage information.
|
|
519
|
+
|
|
520
|
+
:param rse: the RSE name.
|
|
521
|
+
:param source: the information source, e.g. srm.
|
|
522
|
+
:param used: the used space in bytes.
|
|
523
|
+
:param free: the free in bytes.
|
|
524
|
+
:param files: the number of files
|
|
525
|
+
|
|
526
|
+
:returns: True if successful
|
|
527
|
+
"""
|
|
528
|
+
path = [self.RSE_BASEURL, rse, 'usage']
|
|
529
|
+
path = '/'.join(path)
|
|
530
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
531
|
+
data = {'source': source, 'used': used, 'free': free, 'files': files}
|
|
532
|
+
r = self._send_request(url, type_='PUT', data=dumps(data))
|
|
533
|
+
if r.status_code == codes.ok:
|
|
534
|
+
return True
|
|
535
|
+
else:
|
|
536
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
537
|
+
raise exc_cls(exc_msg)
|
|
538
|
+
|
|
539
|
+
def get_rse_usage(
|
|
540
|
+
self,
|
|
541
|
+
rse: str,
|
|
542
|
+
filters: Optional[dict[str, Any]] = None
|
|
543
|
+
) -> "Iterator[dict[str, Any]]":
|
|
544
|
+
"""
|
|
545
|
+
Get RSE usage information.
|
|
546
|
+
|
|
547
|
+
:param rse: the RSE name.
|
|
548
|
+
:param filters: dictionary of attributes by which the results should be filtered
|
|
549
|
+
|
|
550
|
+
:returns: True if successful, otherwise false.
|
|
551
|
+
"""
|
|
552
|
+
path = [self.RSE_BASEURL, rse, 'usage']
|
|
553
|
+
path = '/'.join(path)
|
|
554
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
555
|
+
r = self._send_request(url, type_='GET', params=filters)
|
|
556
|
+
if r.status_code == codes.ok:
|
|
557
|
+
return self._load_json_data(r)
|
|
558
|
+
else:
|
|
559
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
560
|
+
raise exc_cls(exc_msg)
|
|
561
|
+
|
|
562
|
+
def list_rse_usage_history(
|
|
563
|
+
self,
|
|
564
|
+
rse: str,
|
|
565
|
+
filters: Optional[dict[str, Any]] = None
|
|
566
|
+
) -> "Iterator[dict[str, Any]]":
|
|
567
|
+
"""
|
|
568
|
+
List RSE usage history information.
|
|
569
|
+
|
|
570
|
+
:param rse: The RSE name.
|
|
571
|
+
:param filters: dictionary of attributes by which the results should be filtered.
|
|
572
|
+
|
|
573
|
+
:returns: list of dictionaries.
|
|
574
|
+
"""
|
|
575
|
+
path = [self.RSE_BASEURL, rse, 'usage', 'history']
|
|
576
|
+
path = '/'.join(path)
|
|
577
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
578
|
+
r = self._send_request(url, type_='GET', params=filters)
|
|
579
|
+
if r.status_code == codes.ok:
|
|
580
|
+
return self._load_json_data(r)
|
|
581
|
+
else:
|
|
582
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
583
|
+
status_code=r.status_code,
|
|
584
|
+
data=r.content)
|
|
585
|
+
raise exc_cls(exc_msg)
|
|
586
|
+
|
|
587
|
+
def set_rse_limits(
|
|
588
|
+
self,
|
|
589
|
+
rse: str,
|
|
590
|
+
name: str,
|
|
591
|
+
value: int
|
|
592
|
+
) -> Literal[True]:
|
|
593
|
+
"""
|
|
594
|
+
Set RSE limit information.
|
|
595
|
+
|
|
596
|
+
:param rse: The RSE name.
|
|
597
|
+
:param name: The name of the limit.
|
|
598
|
+
:param value: The feature value.
|
|
599
|
+
|
|
600
|
+
:returns: True if successful
|
|
601
|
+
"""
|
|
602
|
+
path = [self.RSE_BASEURL, rse, 'limits']
|
|
603
|
+
path = '/'.join(path)
|
|
604
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
605
|
+
r = self._send_request(url, type_='PUT', data=dumps({'name': name, 'value': value}))
|
|
606
|
+
if r.status_code == codes.ok:
|
|
607
|
+
return True
|
|
608
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
609
|
+
status_code=r.status_code,
|
|
610
|
+
data=r.content)
|
|
611
|
+
raise exc_cls(exc_msg)
|
|
612
|
+
|
|
613
|
+
def get_rse_limits(
|
|
614
|
+
self,
|
|
615
|
+
rse: str
|
|
616
|
+
) -> "Iterator[dict[str, Union[str, int]]]":
|
|
617
|
+
"""
|
|
618
|
+
Get RSE limits.
|
|
619
|
+
|
|
620
|
+
:param rse: The RSE name.
|
|
621
|
+
|
|
622
|
+
:returns: An iterator of RSE limits as dicts with 'name' and 'value' as keys.
|
|
623
|
+
"""
|
|
624
|
+
path = [self.RSE_BASEURL, rse, 'limits']
|
|
625
|
+
path = '/'.join(path)
|
|
626
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
627
|
+
r = self._send_request(url, type_='GET')
|
|
628
|
+
if r.status_code == codes.ok:
|
|
629
|
+
return next(self._load_json_data(r))
|
|
630
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
631
|
+
status_code=r.status_code,
|
|
632
|
+
data=r.content)
|
|
633
|
+
raise exc_cls(exc_msg)
|
|
634
|
+
|
|
635
|
+
def delete_rse_limits(self, rse: str, name: str) -> Literal[True]:
|
|
636
|
+
"""
|
|
637
|
+
Delete RSE limit information.
|
|
638
|
+
|
|
639
|
+
:param rse: The RSE name.
|
|
640
|
+
:param name: The name of the limit.
|
|
641
|
+
|
|
642
|
+
:returns: True if successful
|
|
643
|
+
"""
|
|
644
|
+
path = [self.RSE_BASEURL, rse, 'limits']
|
|
645
|
+
path = '/'.join(path)
|
|
646
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
647
|
+
r = self._send_request(url, type_='DEL', data=dumps({'name': name}))
|
|
648
|
+
if r.status_code == codes.ok:
|
|
649
|
+
return True
|
|
650
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
651
|
+
status_code=r.status_code,
|
|
652
|
+
data=r.content)
|
|
653
|
+
|
|
654
|
+
raise exc_cls(exc_msg)
|
|
655
|
+
|
|
656
|
+
def add_distance(
|
|
657
|
+
self,
|
|
658
|
+
source: str,
|
|
659
|
+
destination: str,
|
|
660
|
+
parameters: dict[str, int]
|
|
661
|
+
) -> Literal[True]:
|
|
662
|
+
"""
|
|
663
|
+
Add a src-dest distance.
|
|
664
|
+
|
|
665
|
+
:param source: The source.
|
|
666
|
+
:param destination: The destination.
|
|
667
|
+
:param parameters: A dictionary with property.
|
|
668
|
+
"""
|
|
669
|
+
path = [self.RSE_BASEURL, source, 'distances', destination]
|
|
670
|
+
path = '/'.join(path)
|
|
671
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
672
|
+
r = self._send_request(url, type_='POST', data=dumps(parameters))
|
|
673
|
+
if r.status_code == codes.created:
|
|
674
|
+
return True
|
|
675
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
676
|
+
status_code=r.status_code,
|
|
677
|
+
data=r.content)
|
|
678
|
+
raise exc_cls(exc_msg)
|
|
679
|
+
|
|
680
|
+
def update_distance(
|
|
681
|
+
self,
|
|
682
|
+
source: str,
|
|
683
|
+
destination: str,
|
|
684
|
+
parameters: dict[str, int]
|
|
685
|
+
) -> Literal[True]:
|
|
686
|
+
"""
|
|
687
|
+
Update distances with the given RSE ids.
|
|
688
|
+
|
|
689
|
+
:param source: The source.
|
|
690
|
+
:param destination: The destination.
|
|
691
|
+
:param parameters: A dictionary with property.
|
|
692
|
+
"""
|
|
693
|
+
path = [self.RSE_BASEURL, source, 'distances', destination]
|
|
694
|
+
path = '/'.join(path)
|
|
695
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
696
|
+
r = self._send_request(url, type_='PUT', data=dumps(parameters))
|
|
697
|
+
if r.status_code == codes.ok:
|
|
698
|
+
return True
|
|
699
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
700
|
+
status_code=r.status_code,
|
|
701
|
+
data=r.content)
|
|
702
|
+
raise exc_cls(exc_msg)
|
|
703
|
+
|
|
704
|
+
def get_distance(
|
|
705
|
+
self,
|
|
706
|
+
source: str,
|
|
707
|
+
destination: str
|
|
708
|
+
) -> list[dict[str, Union[str, int]]]:
|
|
709
|
+
"""
|
|
710
|
+
Get distances between rses.
|
|
711
|
+
|
|
712
|
+
:param source: The source RSE.
|
|
713
|
+
:param destination: The destination RSE.
|
|
714
|
+
|
|
715
|
+
:returns distance: List of dictionaries.
|
|
716
|
+
"""
|
|
717
|
+
path = [self.RSE_BASEURL, source, 'distances', destination]
|
|
718
|
+
path = '/'.join(path)
|
|
719
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
720
|
+
r = self._send_request(url, type_='GET')
|
|
721
|
+
if r.status_code == codes.ok:
|
|
722
|
+
return next(self._load_json_data(r))
|
|
723
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
|
|
724
|
+
raise exc_cls(exc_msg)
|
|
725
|
+
|
|
726
|
+
def delete_distance(
|
|
727
|
+
self,
|
|
728
|
+
source: str,
|
|
729
|
+
destination: str
|
|
730
|
+
) -> Literal[True]:
|
|
731
|
+
"""
|
|
732
|
+
Delete distances with the given RSE ids.
|
|
733
|
+
|
|
734
|
+
:param source: The source.
|
|
735
|
+
:param destination: The destination.
|
|
736
|
+
"""
|
|
737
|
+
path = [self.RSE_BASEURL, source, 'distances', destination]
|
|
738
|
+
path = '/'.join(path)
|
|
739
|
+
url = build_url(choice(self.list_hosts), path=path)
|
|
740
|
+
r = self._send_request(url, type_='DEL')
|
|
741
|
+
if r.status_code == codes.ok:
|
|
742
|
+
return True
|
|
743
|
+
exc_cls, exc_msg = self._get_exception(headers=r.headers,
|
|
744
|
+
status_code=r.status_code,
|
|
745
|
+
data=r.content)
|
|
746
|
+
raise exc_cls(exc_msg)
|