rucio-clients 35.7.0__py3-none-any.whl → 37.0.0rc2__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.

Files changed (86) hide show
  1. rucio/alembicrevision.py +1 -1
  2. rucio/cli/__init__.py +14 -0
  3. rucio/cli/account.py +216 -0
  4. rucio/cli/bin_legacy/__init__.py +13 -0
  5. rucio_clients-35.7.0.data/scripts/rucio → rucio/cli/bin_legacy/rucio.py +769 -486
  6. rucio_clients-35.7.0.data/scripts/rucio-admin → rucio/cli/bin_legacy/rucio_admin.py +476 -423
  7. rucio/cli/command.py +272 -0
  8. rucio/cli/config.py +72 -0
  9. rucio/cli/did.py +191 -0
  10. rucio/cli/download.py +128 -0
  11. rucio/cli/lifetime_exception.py +33 -0
  12. rucio/cli/replica.py +162 -0
  13. rucio/cli/rse.py +293 -0
  14. rucio/cli/rule.py +158 -0
  15. rucio/cli/scope.py +40 -0
  16. rucio/cli/subscription.py +73 -0
  17. rucio/cli/upload.py +60 -0
  18. rucio/cli/utils.py +226 -0
  19. rucio/client/accountclient.py +0 -1
  20. rucio/client/baseclient.py +33 -24
  21. rucio/client/client.py +45 -1
  22. rucio/client/didclient.py +5 -3
  23. rucio/client/downloadclient.py +6 -8
  24. rucio/client/replicaclient.py +0 -2
  25. rucio/client/richclient.py +317 -0
  26. rucio/client/rseclient.py +4 -4
  27. rucio/client/uploadclient.py +26 -12
  28. rucio/common/bittorrent.py +234 -0
  29. rucio/common/cache.py +66 -29
  30. rucio/common/checksum.py +168 -0
  31. rucio/common/client.py +122 -0
  32. rucio/common/config.py +22 -35
  33. rucio/common/constants.py +61 -3
  34. rucio/common/didtype.py +72 -24
  35. rucio/common/exception.py +65 -8
  36. rucio/common/extra.py +5 -10
  37. rucio/common/logging.py +13 -13
  38. rucio/common/pcache.py +8 -7
  39. rucio/common/plugins.py +59 -27
  40. rucio/common/policy.py +12 -3
  41. rucio/common/schema/__init__.py +84 -34
  42. rucio/common/schema/generic.py +0 -17
  43. rucio/common/schema/generic_multi_vo.py +0 -17
  44. rucio/common/stomp_utils.py +383 -119
  45. rucio/common/test_rucio_server.py +12 -6
  46. rucio/common/types.py +132 -52
  47. rucio/common/utils.py +93 -643
  48. rucio/rse/__init__.py +3 -3
  49. rucio/rse/protocols/bittorrent.py +11 -1
  50. rucio/rse/protocols/cache.py +0 -11
  51. rucio/rse/protocols/dummy.py +0 -11
  52. rucio/rse/protocols/gfal.py +14 -9
  53. rucio/rse/protocols/globus.py +1 -1
  54. rucio/rse/protocols/http_cache.py +1 -1
  55. rucio/rse/protocols/posix.py +2 -2
  56. rucio/rse/protocols/protocol.py +84 -317
  57. rucio/rse/protocols/rclone.py +2 -1
  58. rucio/rse/protocols/rfio.py +10 -1
  59. rucio/rse/protocols/ssh.py +2 -1
  60. rucio/rse/protocols/storm.py +2 -13
  61. rucio/rse/protocols/webdav.py +74 -30
  62. rucio/rse/protocols/xrootd.py +2 -1
  63. rucio/rse/rsemanager.py +170 -53
  64. rucio/rse/translation.py +260 -0
  65. rucio/vcsversion.py +4 -4
  66. rucio/version.py +7 -0
  67. {rucio_clients-35.7.0.data → rucio_clients-37.0.0rc2.data}/data/etc/rucio.cfg.atlas.client.template +3 -2
  68. {rucio_clients-35.7.0.data → rucio_clients-37.0.0rc2.data}/data/etc/rucio.cfg.template +3 -19
  69. {rucio_clients-35.7.0.data → rucio_clients-37.0.0rc2.data}/data/requirements.client.txt +11 -7
  70. rucio_clients-37.0.0rc2.data/scripts/rucio +133 -0
  71. rucio_clients-37.0.0rc2.data/scripts/rucio-admin +97 -0
  72. {rucio_clients-35.7.0.dist-info → rucio_clients-37.0.0rc2.dist-info}/METADATA +18 -14
  73. rucio_clients-37.0.0rc2.dist-info/RECORD +104 -0
  74. {rucio_clients-35.7.0.dist-info → rucio_clients-37.0.0rc2.dist-info}/licenses/AUTHORS.rst +3 -0
  75. rucio/common/schema/atlas.py +0 -413
  76. rucio/common/schema/belleii.py +0 -408
  77. rucio/common/schema/domatpc.py +0 -401
  78. rucio/common/schema/escape.py +0 -426
  79. rucio/common/schema/icecube.py +0 -406
  80. rucio/rse/protocols/gsiftp.py +0 -92
  81. rucio_clients-35.7.0.dist-info/RECORD +0 -88
  82. {rucio_clients-35.7.0.data → rucio_clients-37.0.0rc2.data}/data/etc/rse-accounts.cfg.template +0 -0
  83. {rucio_clients-35.7.0.data → rucio_clients-37.0.0rc2.data}/data/rucio_client/merge_rucio_configs.py +0 -0
  84. {rucio_clients-35.7.0.dist-info → rucio_clients-37.0.0rc2.dist-info}/WHEEL +0 -0
  85. {rucio_clients-35.7.0.dist-info → rucio_clients-37.0.0rc2.dist-info}/licenses/LICENSE +0 -0
  86. {rucio_clients-35.7.0.dist-info → rucio_clients-37.0.0rc2.dist-info}/top_level.txt +0 -0
@@ -15,145 +15,409 @@
15
15
  """
16
16
  Common utility functions for stomp connections
17
17
  """
18
-
18
+ import json
19
19
  import logging
20
+ import random
20
21
  import socket
22
+ from collections import namedtuple
23
+ from copy import deepcopy
24
+ from functools import partial
21
25
  from time import monotonic
22
- from typing import TYPE_CHECKING
26
+ from typing import TYPE_CHECKING, Any
27
+
28
+ from stomp import Connection12
29
+ from stomp.exception import ConnectFailedException, NotConnectedException
30
+ from stomp.listener import HeartbeatListener
23
31
 
24
- from stomp import Connection
32
+ from rucio.common.config import config_get, config_get_bool, config_get_float, config_get_int, config_get_list
33
+ from rucio.common.logging import formatted_logger
34
+ from rucio.core.monitor import MetricManager
25
35
 
26
36
  if TYPE_CHECKING:
27
- from collections.abc import Callable, Sequence
28
- from typing import Any
37
+ from collections.abc import Iterable, Iterator
38
+
39
+ from stomp.connect import Frame
40
+
41
+ from rucio.common.types import LoggerFunction
42
+
43
+
44
+ METRICS = MetricManager(module=__name__)
45
+
46
+
47
+ class Connection(Connection12):
48
+ """
49
+ Connection class.
50
+
51
+ Wraps Stomp Connection but knows the brokers without accessing
52
+ hidden variables from the Transport.
53
+ """
54
+ def __init__(self, host_and_ports: list[tuple[str, int]], **kwargs):
55
+ """
56
+ Initialise.
57
+
58
+ Args:
59
+ host_and_ports: brokers list
60
+
61
+ Kwargs:
62
+ Arguments to pass to the Constructor12 base class.
63
+ """
64
+ super().__init__(host_and_ports=host_and_ports, **kwargs)
65
+ self._brokers = host_and_ports
66
+
67
+ @property
68
+ def brokers(self) -> list[tuple[str, int]]:
69
+ """
70
+ List brokers.
71
+
72
+ Returns:
73
+ All assigned brokers in (host, port) format.
74
+ """
75
+ return self._brokers
76
+
29
77
 
30
- LoggerFunction = Callable[..., Any]
78
+ class ListenerBase(HeartbeatListener):
79
+ """Listener Base."""
31
80
 
81
+ _logger = formatted_logger(logging.log, 'ListenerBase %s')
32
82
 
33
- def resolve_ips(fqdns: "Sequence[str]", logger: "LoggerFunction" = logging.log):
34
- logger(logging.DEBUG, 'resolving dns aliases: %s' % fqdns)
35
- resolved = []
36
- for fqdn in fqdns:
37
- addrinfos = socket.getaddrinfo(fqdn, 0, socket.AF_INET, 0, socket.IPPROTO_TCP)
38
- resolved.extend(ai[4][0] for ai in addrinfos)
39
- logger(logging.DEBUG, 'dns aliases resolved to %s', resolved)
40
- return resolved
83
+ def __init__(self,
84
+ conn: Connection,
85
+ logger: "None | LoggerFunction" = None,
86
+ **kwargs):
87
+ """
88
+ Initialise.
89
+
90
+ Args:
91
+ conn: The connection object that is using this listener
92
+ logger: Logger to use. Defaults to logging.getLogger(__name__).getChild(__qualname__).
93
+
94
+ Kwargs:
95
+ Arguments to pass to the stomp.ConnectionListener base class.
96
+ """
97
+ super().__init__(transport=conn.transport, **kwargs)
98
+ self._conn = conn
99
+ if logger is not None:
100
+ self._logger = logger
101
+
102
+ @METRICS.count_it
103
+ def on_heartbeat_timeout(self):
104
+ self._conn.disconnect()
105
+
106
+ @METRICS.count_it
107
+ def on_error(self, frame: "Frame"):
108
+ """
109
+ on_error
110
+ """
111
+ self._logger(logging.ERROR, 'Message receive error: [%s] %s', self._conn.brokers[0][0], frame.body)
112
+
113
+
114
+ StompConfig = namedtuple("StompConfig", ('brokers', 'use_ssl', 'port', 'vhost',
115
+ 'destination', 'key_file', 'cert_file',
116
+ 'username', 'password', 'nonssl_port',
117
+ 'reconnect_attempts_max', 'timeout', 'heartbeats'))
41
118
 
42
119
 
43
120
  class StompConnectionManager:
121
+ """Stomp Connection Manager."""
122
+
123
+ _logger = formatted_logger(logging.log, 'StompConnectionManager %s')
124
+
125
+ def __init__(self,
126
+ config_section: str,
127
+ logger: "None | LoggerFunction" = None):
128
+ """
129
+ Initialise.
130
+
131
+ Args:
132
+ config_section: The name of the config section for this manager to parse for configuration.
133
+ logger: logger to use. Defaults to logging.getLogger(__name__).getChild(__qualname__).
134
+ """
135
+ if logger is not None:
136
+ self._logger = logger
137
+ self._config = self._parse_config(config_section)
138
+ self._listener_factory = None
139
+ self._conns = []
140
+ for broker in self._config.brokers:
141
+ conn = Connection(host_and_ports=[broker],
142
+ vhost=self._config.vhost,
143
+ reconnect_attempts_max=self._config.reconnect_attempts_max,
144
+ timeout=self._config.timeout,
145
+ heartbeats=self._config.heartbeats)
146
+ if self._config.use_ssl:
147
+ conn.set_ssl(cert_file=self._config.cert_file, key_file=self._config.key_file)
148
+ self._conns.append(conn)
149
+
150
+ @property
151
+ def config(self) -> StompConfig:
152
+ """
153
+ Get the config.
154
+
155
+ Returns:
156
+ config object.
157
+ """
158
+ return deepcopy(self._config)
159
+
160
+ def set_listener_factory(self, name: str, listener_cls: type, **kwargs) -> None:
161
+ """
162
+ Setup listener factory
163
+
164
+ This method will setup a factory to create a name and listener for the arguments to
165
+ connection.set_listener based on pre-defined argument values.
44
166
 
45
- def __init__(self):
46
- self._brokers = None
47
- self._port = None
48
- self._use_ssl = None
49
- self._vhost = None
50
- self._reconnect_attempts = None
51
- self._ssl_key_file = None
52
- self._timeout = None
53
- self._heartbeats = None
167
+ Args:
168
+ name: Listener name
169
+ listener_cls: Listener class.
170
+ """
171
+ def create_listener(name, listener_factory, conn):
172
+ return name, listener_factory(conn=conn)
173
+ self._listener_factory = partial(create_listener,
174
+ name=name,
175
+ listener_factory=partial(listener_cls, logger=self._logger, **kwargs))
54
176
 
55
- self._connections = {}
177
+ def _parse_config(self, config_section: str) -> StompConfig:
178
+ """
179
+ Parse config section.
56
180
 
57
- def is_stalled(self, connection: Connection, *, logger: "LoggerFunction" = logging.log):
58
- if not connection.is_connected():
59
- return True
181
+ Args:
182
+ config_section: The name of the config section for this manager to parse for configuration.
60
183
 
61
- if self._heartbeats and getattr(connection, 'received_heartbeat') and connection.received_heartbeat:
62
- heartbeat_period_seconds = max(0, self._heartbeats[0], self._heartbeats[1]) / 1000
184
+ Raises:
185
+ RuntimeError: If cannot parse config sections 'brokers' or 'use_ssl' or if misconfigured.
63
186
 
64
- if not heartbeat_period_seconds:
65
- return False
187
+ Returns:
188
+ Stomp manager configuration object.
189
+ """
190
+ try:
191
+ brokers = config_get(config_section, 'brokers')
192
+ except Exception as exc:
193
+ self._logger(logging.ERROR, "Could not load brokers from configuration")
194
+ raise RuntimeError('Could not load brokers from configuration') from exc
66
195
 
67
- now = monotonic()
68
- if connection.received_heartbeat + 10 * heartbeat_period_seconds < now:
69
- logger(logging.WARNING, "Stomp connection missed heartbeats for a long time")
70
- return True
196
+ try:
197
+ use_ssl = config_get_bool(config_section, 'use_ssl')
198
+ except Exception as exc:
199
+ self._logger(logging.ERROR, "could not find use_ssl in configuration -- please update your rucio.cfg")
200
+ raise RuntimeError('could not find use_ssl in configuration -- please update your rucio.cfg') from exc
71
201
 
72
- return False
202
+ port = config_get_int(config_section, 'port')
203
+ vhost = config_get(config_section, 'broker_virtual_host', raise_exception=False)
204
+ destination = config_get(config_section, "destination")
205
+ key_file = config_get(config_section, 'ssl_key_file', default=None, raise_exception=False)
206
+ cert_file = config_get(config_section, 'ssl_cert_file', default=None, raise_exception=False)
207
+ username = config_get(config_section, 'username', default=None, raise_exception=False)
208
+ password = config_get(config_section, 'password', default=None, raise_exception=False)
209
+ nonssl_port = config_get_int(config_section, 'nonssl_port', default=0, raise_exception=False)
210
+ timeout = config_get_float(config_section, 'timeout', default=None, raise_exception=False)
211
+ heartbeats = tuple(config_get_list(config_section, 'heartbeats', default=[0., 0.], raise_exception=False))
212
+ reconnect_attempts = config_get_int(config_section, 'reconnect_attempts', default=100)
213
+ if use_ssl and (key_file is None or cert_file is None):
214
+ self._logger(logging.ERROR, "If use_ssl is True in config you must provide both 'ssl_cert_file' "
215
+ "and 'ssl_key_file'")
216
+ raise RuntimeError("If use_ssl is True in config you must provide both 'ssl_cert_file' and 'ssl_key_file'")
217
+ if not use_ssl and (username is None or password is None or nonssl_port == 0):
218
+ self._logger(logging.ERROR, "If use_ssl is False in config you must provide "
219
+ "'username', 'password' and 'nonssl_port'")
220
+ raise RuntimeError("If use_ssl is False in config you must provide "
221
+ "'username', 'password' and 'nonssl_port'")
222
+ return StompConfig(brokers=self._resolve_host_and_port(brokers, port if use_ssl else nonssl_port),
223
+ use_ssl=use_ssl,
224
+ port=port, vhost=vhost,
225
+ destination=destination, key_file=key_file, cert_file=cert_file,
226
+ username=username, password=password, nonssl_port=nonssl_port,
227
+ reconnect_attempts_max=reconnect_attempts, timeout=timeout, heartbeats=heartbeats)
73
228
 
74
- def disconnect(self):
75
- for conn in self._connections.values():
229
+ def _resolve_host_and_port(self, fqdns: "str | Iterable[str]", port: int) -> list[tuple[str, int]]:
230
+ """
231
+ Resolve host and port.
232
+
233
+ Args:
234
+ fqdns: fully qualified domain name(s)
235
+ port: port
236
+
237
+ Returns:
238
+ list of (host, port) tuples.
239
+ """
240
+ if isinstance(fqdns, str):
241
+ fqdns = fqdns.split(',')
242
+
243
+ hosts_and_ports = []
244
+ for fqdn in fqdns:
245
+ try:
246
+ addrinfos = socket.getaddrinfo(fqdn.strip(), port, socket.AF_INET, 0, socket.IPPROTO_TCP)
247
+ except socket.gaierror as exc:
248
+ self._logger(logging.ERROR, "[broker] Cannot resolve domain name %s (%s)", fqdn.strip(), str(exc))
249
+ continue
250
+
251
+ hosts_and_ports.extend(addrinfo[4] for addrinfo in addrinfos)
252
+ if not hosts_and_ports:
253
+ self._logger(logging.WARNING, "[broker] No resolved brokers")
254
+ return hosts_and_ports
255
+
256
+ def _is_stalled(self, conn: Connection) -> bool:
257
+ """
258
+ Determine if a connection is stalled.
259
+
260
+ Args:
261
+ conn: The Connection object
262
+
263
+ Returns:
264
+ Whether the connection has stalled.
265
+ """
266
+ received_heartbeat = getattr(conn, 'received_heartbeat', None)
267
+ if received_heartbeat is None or not any(self._config.heartbeats):
268
+ return False
269
+
270
+ heartbeat_period_seconds = max(0, self._config.heartbeats[0], self._config.heartbeats[1]) / 1000
271
+ if heartbeat_period_seconds == 0.:
272
+ return False
273
+
274
+ now = monotonic()
275
+ if received_heartbeat + 10 * heartbeat_period_seconds >= now:
276
+ return False
277
+
278
+ return True
279
+
280
+ def connect(self) -> "Iterator[Connection]":
281
+ """
282
+ Connect.
283
+
284
+ Yields:
285
+ Each connection object after ensuring it's connected.
286
+ """
287
+ config = self._config
288
+ params = {'wait': True, "heartbeats": self._config.heartbeats}
289
+ self._logger(logging.WARNING, 'heartbeats: %s', self._config.heartbeats)
290
+ if config.use_ssl:
291
+ params.update(username=config.username, password=config.password)
292
+
293
+ for conn in self._conns:
294
+ if self._is_stalled(conn):
295
+ try:
296
+ conn.disconnect()
297
+ except Exception:
298
+ self._logger(logging.ERROR, "[broker] Stalled connection could not be disconnected")
76
299
  if not conn.is_connected():
77
- conn.disconnect()
300
+ self._logger(logging.INFO, 'connecting to %s:%s', *conn.brokers[0])
301
+ METRICS.counter('reconnect.{host}').labels(host=conn.brokers[0][0]).inc()
302
+ if self._listener_factory is not None:
303
+ conn.set_listener(*self._listener_factory(conn=conn))
304
+
305
+ try:
306
+ conn.connect(**params)
307
+ except ConnectFailedException as error:
308
+ self._logger(logging.WARNING, "[broker] Could not deliver message due to "
309
+ "ConnectFailedException: %s", str(error))
310
+ continue
311
+ except Exception as error:
312
+ self._logger(logging.ERROR, "[broker] Could not connect: %s", str(error))
313
+ continue
314
+ try:
315
+ yield conn
316
+ except Exception:
317
+ self._logger(logging.ERROR, "[broker] Error in yielded code, skipping to next connection.")
318
+
319
+ def deliver_messages(self, messages: "Iterable[dict[str, Any]]") -> list[int]:
320
+ """
321
+ Deliver messages.
322
+
323
+ Args:
324
+ messages: Messages to deliver.
325
+
326
+ Returns:
327
+ delivered message ids, ready for deletion.
328
+ """
329
+ config = self._config
330
+ conn = random.sample(list(self.connect()), 1)[0]
331
+ to_delete = []
332
+ for message in messages:
333
+ try:
334
+ body = json.dumps({"event_type": str(message["event_type"]).lower(),
335
+ "payload": message["payload"],
336
+ "created_at": str(message["created_at"])})
337
+ except ValueError:
338
+ self._logger(logging.ERROR, "[broker] Cannot serialize payload to JSON: %s", str(message["payload"]))
339
+ to_delete.append(message["id"])
340
+ continue
341
+
342
+ try:
343
+ conn.send(
344
+ body=body,
345
+ destination=config.destination,
346
+ headers={"persistent": "true",
347
+ "event_type": str(message["event_type"]).lower()}
348
+ )
349
+ to_delete.append(message["id"])
350
+ except NotConnectedException as error:
351
+ self._logger(logging.WARNING, "[broker] Could not deliver message due to NotConnectedException: %s",
352
+ str(error))
353
+ continue
354
+ except Exception as error:
355
+ self._logger(logging.ERROR, "[broker] Could not deliver message: %s", str(error))
356
+ continue
357
+
358
+ msg_event_type = str(message["event_type"]).lower()
359
+ msg_payload = message.get("payload", {})
360
+ if msg_event_type.startswith("transfer") or msg_event_type.startswith("stagein"):
361
+ self._logger(logging.DEBUG,
362
+ "[broker] - event_type: %s, scope: %s, name: %s, rse: %s, request-id: %s, "
363
+ "transfer-id: %s, created_at: %s",
364
+ msg_event_type,
365
+ msg_payload.get("scope", None),
366
+ msg_payload.get("name", None),
367
+ msg_payload.get("dst-rse", None),
368
+ msg_payload.get("request-id", None),
369
+ msg_payload.get("transfer-id", None),
370
+ str(message["created_at"]))
371
+
372
+ elif msg_event_type.startswith("dataset"):
373
+ self._logger(logging.DEBUG,
374
+ "[broker] - event_type: %s, scope: %s, name: %s, rse: %s, rule-id: %s, created_at: %s)",
375
+ msg_event_type,
376
+ msg_payload.get("scope", None),
377
+ msg_payload.get("name", None),
378
+ msg_payload.get("rse", None),
379
+ msg_payload.get("rule_id", None),
380
+ str(message["created_at"]))
381
+
382
+ elif msg_event_type.startswith("deletion"):
383
+ if "url" not in msg_payload:
384
+ msg_payload["url"] = "unknown"
385
+ self._logger(logging.DEBUG,
386
+ "[broker] - event_type: %s, scope: %s, name: %s, rse: %s, url: %s, created_at: %s)",
387
+ msg_event_type,
388
+ msg_payload.get("scope", None),
389
+ msg_payload.get("name", None),
390
+ msg_payload.get("rse", None),
391
+ msg_payload.get("url", None),
392
+ str(message["created_at"]))
393
+ else:
394
+ self._logger(logging.DEBUG, "[broker] Other message: %s", message)
395
+
396
+ return to_delete
397
+
398
+ def subscribe(self, id_: str, ack: str, destination: "None | str" = None, **kwargs) -> None:
399
+ """
400
+ Subscribe
401
+
402
+ Args:
403
+ id_: The identifier to uniquely identify the subscription
404
+ ack: Either auto, client or client-individual
405
+ destination: The topic or queue to subscribe to. If None then
406
+ destination is taken from the rucio config Defaults to None.
407
+
408
+ Kwargs:
409
+ Arguments to pass to the Construction objects subscribe method.
410
+ """
411
+ if destination is None:
412
+ destination = self._config.destination
413
+ for conn in self.connect():
414
+ conn.subscribe(destination=destination,
415
+ id=id_, ack=ack, **kwargs)
78
416
 
79
- def re_configure(
80
- self,
81
- brokers: "Sequence[str]",
82
- port: int,
83
- use_ssl: bool,
84
- vhost,
85
- reconnect_attempts: int,
86
- ssl_key_file,
87
- ssl_cert_file,
88
- timeout,
89
- heartbeats=(0, 1000),
90
- *,
91
- logger: "LoggerFunction" = logging.log
92
- ) -> tuple[list, list]:
93
-
94
- configuration_changed = any([
95
- self._brokers != brokers,
96
- self._port != port,
97
- self._use_ssl != use_ssl,
98
- self._vhost != vhost,
99
- self._reconnect_attempts != reconnect_attempts,
100
- self._ssl_key_file != ssl_key_file,
101
- self._timeout != timeout,
102
- self._heartbeats != heartbeats,
103
- ])
104
- if configuration_changed:
105
- self._brokers = brokers
106
- self._port = port
107
- self._use_ssl = use_ssl
108
- self._vhost = vhost
109
- self._reconnect_attempts = reconnect_attempts
110
- self._ssl_key_file = ssl_key_file
111
- self._timeout = timeout
112
- self._heartbeats = heartbeats
113
-
114
- current_remotes = set(self._connections)
115
- desired_remotes = set((ip, port) for ip in resolve_ips(brokers, logger=logger))
116
-
117
- if configuration_changed:
118
- # Re-create all connections
119
- to_delete = current_remotes
120
- to_create = desired_remotes
121
- else:
122
- to_delete = current_remotes.difference(desired_remotes)
123
- to_create = desired_remotes.difference(current_remotes)
124
-
125
- for remote in current_remotes.intersection(desired_remotes):
126
- conn = self._connections[remote]
127
-
128
- if self.is_stalled(conn, logger=logger):
129
- # Re-create stalled connections
130
- to_delete.add(remote)
131
- to_create.add(remote)
132
-
133
- deleted_conns = []
134
- for remote in to_delete:
135
- conn = self._connections.pop(remote)
136
- if conn.is_connected():
417
+ def disconnect(self) -> None:
418
+ """Disconnect."""
419
+ for conn in self._conns:
420
+ try:
137
421
  conn.disconnect()
138
- deleted_conns.append(to_delete)
139
-
140
- created_conns = []
141
- for remote in to_create:
142
- conn = Connection(
143
- host_and_ports=[remote],
144
- vhost=vhost,
145
- timeout=timeout,
146
- heartbeats=heartbeats,
147
- reconnect_attempts_max=reconnect_attempts
148
- )
149
- if use_ssl:
150
- conn.set_ssl(key_file=ssl_key_file, cert_file=ssl_cert_file)
151
- self._connections[remote] = conn
152
- created_conns.append(conn)
153
-
154
- if not to_delete and not to_create:
155
- logger(logging.INFO, "Stomp connections didn't change")
156
- else:
157
- logger(logging.INFO, f"Stomp connections refreshed. Deleted: {list(to_delete)}. Added: {list(to_create)}")
158
-
159
- return created_conns, deleted_conns
422
+ except Exception:
423
+ self._logger(logging.ERROR, "[broker] Could not disconnect")
@@ -36,27 +36,33 @@ def get_scope_and_rses():
36
36
 
37
37
  :return: A tuple (scope, rses) for the rucio client where scope is mock/test and rses is a list or (None, [None]) if no suitable rse exists.
38
38
  """
39
- cmd = "rucio list-rses --rses 'test_container_xrd=True'"
39
+ cmd = "rucio rse list 'test_container_xrd=True'"
40
40
  print(cmd)
41
41
  exitcode, out, err = execute(cmd)
42
42
  print(out, err)
43
43
  rses = out.split()
44
44
  if len(rses) == 0:
45
45
  return None, [None]
46
- return 'test', rses
46
+
47
+ scope = 'test'
48
+ account = 'root'
49
+ cmd = f"rucio scope add {scope} --account {account}"
50
+ _, out, err = execute(cmd)
51
+ print(out, err)
52
+ return scope, rses
47
53
 
48
54
 
49
55
  def delete_rules(did):
50
56
  # get the rules for the file
51
57
  print('Deleting rules')
52
- cmd = "rucio list-rules {0} | grep {0} | cut -f1 -d\\ ".format(did)
58
+ cmd = "rucio rule list {0} | grep {0} | cut -f1 -d\\ ".format(did)
53
59
  print(cmd)
54
60
  exitcode, out, err = execute(cmd)
55
61
  print(out, err)
56
62
  rules = out.split()
57
63
  # delete the rules for the file
58
64
  for rule in rules:
59
- cmd = "rucio delete-rule {0}".format(rule)
65
+ cmd = "rucio rule remove {0}".format(rule)
60
66
  print(cmd)
61
67
  exitcode, out, err = execute(cmd)
62
68
 
@@ -112,7 +118,7 @@ class TestRucioServer(unittest.TestCase):
112
118
  self.assertEqual(exitcode, 0)
113
119
 
114
120
  # List the files
115
- cmd = 'rucio list-files {0}:{1}'.format(self.scope, tmp_dsn)
121
+ cmd = 'rucio did content list --did {0}:{1}'.format(self.scope, tmp_dsn)
116
122
  print(self.marker + cmd)
117
123
  exitcode, out, err = execute(cmd)
118
124
  print(out)
@@ -120,7 +126,7 @@ class TestRucioServer(unittest.TestCase):
120
126
  self.assertEqual(exitcode, 0)
121
127
 
122
128
  # List the replicas
123
- cmd = 'rucio list-file-replicas {0}:{1}'.format(self.scope, tmp_dsn)
129
+ cmd = 'rucio replica list file {0}:{1}'.format(self.scope, tmp_dsn)
124
130
  print(self.marker + cmd)
125
131
  exitcode, out, err = execute(cmd)
126
132
  print(out)