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.

Files changed (88) hide show
  1. rucio/__init__.py +17 -0
  2. rucio/alembicrevision.py +15 -0
  3. rucio/client/__init__.py +15 -0
  4. rucio/client/accountclient.py +433 -0
  5. rucio/client/accountlimitclient.py +183 -0
  6. rucio/client/baseclient.py +974 -0
  7. rucio/client/client.py +76 -0
  8. rucio/client/configclient.py +126 -0
  9. rucio/client/credentialclient.py +59 -0
  10. rucio/client/didclient.py +866 -0
  11. rucio/client/diracclient.py +56 -0
  12. rucio/client/downloadclient.py +1785 -0
  13. rucio/client/exportclient.py +44 -0
  14. rucio/client/fileclient.py +50 -0
  15. rucio/client/importclient.py +42 -0
  16. rucio/client/lifetimeclient.py +90 -0
  17. rucio/client/lockclient.py +109 -0
  18. rucio/client/metaconventionsclient.py +140 -0
  19. rucio/client/pingclient.py +44 -0
  20. rucio/client/replicaclient.py +454 -0
  21. rucio/client/requestclient.py +125 -0
  22. rucio/client/rseclient.py +746 -0
  23. rucio/client/ruleclient.py +294 -0
  24. rucio/client/scopeclient.py +90 -0
  25. rucio/client/subscriptionclient.py +173 -0
  26. rucio/client/touchclient.py +82 -0
  27. rucio/client/uploadclient.py +955 -0
  28. rucio/common/__init__.py +13 -0
  29. rucio/common/cache.py +74 -0
  30. rucio/common/config.py +801 -0
  31. rucio/common/constants.py +159 -0
  32. rucio/common/constraints.py +17 -0
  33. rucio/common/didtype.py +189 -0
  34. rucio/common/exception.py +1151 -0
  35. rucio/common/extra.py +36 -0
  36. rucio/common/logging.py +420 -0
  37. rucio/common/pcache.py +1408 -0
  38. rucio/common/plugins.py +153 -0
  39. rucio/common/policy.py +84 -0
  40. rucio/common/schema/__init__.py +150 -0
  41. rucio/common/schema/atlas.py +413 -0
  42. rucio/common/schema/belleii.py +408 -0
  43. rucio/common/schema/domatpc.py +401 -0
  44. rucio/common/schema/escape.py +426 -0
  45. rucio/common/schema/generic.py +433 -0
  46. rucio/common/schema/generic_multi_vo.py +412 -0
  47. rucio/common/schema/icecube.py +406 -0
  48. rucio/common/stomp_utils.py +159 -0
  49. rucio/common/stopwatch.py +55 -0
  50. rucio/common/test_rucio_server.py +148 -0
  51. rucio/common/types.py +403 -0
  52. rucio/common/utils.py +2238 -0
  53. rucio/rse/__init__.py +96 -0
  54. rucio/rse/protocols/__init__.py +13 -0
  55. rucio/rse/protocols/bittorrent.py +184 -0
  56. rucio/rse/protocols/cache.py +122 -0
  57. rucio/rse/protocols/dummy.py +111 -0
  58. rucio/rse/protocols/gfal.py +703 -0
  59. rucio/rse/protocols/globus.py +243 -0
  60. rucio/rse/protocols/gsiftp.py +92 -0
  61. rucio/rse/protocols/http_cache.py +82 -0
  62. rucio/rse/protocols/mock.py +123 -0
  63. rucio/rse/protocols/ngarc.py +209 -0
  64. rucio/rse/protocols/posix.py +250 -0
  65. rucio/rse/protocols/protocol.py +594 -0
  66. rucio/rse/protocols/rclone.py +364 -0
  67. rucio/rse/protocols/rfio.py +136 -0
  68. rucio/rse/protocols/srm.py +338 -0
  69. rucio/rse/protocols/ssh.py +413 -0
  70. rucio/rse/protocols/storm.py +206 -0
  71. rucio/rse/protocols/webdav.py +550 -0
  72. rucio/rse/protocols/xrootd.py +301 -0
  73. rucio/rse/rsemanager.py +764 -0
  74. rucio/vcsversion.py +11 -0
  75. rucio/version.py +38 -0
  76. rucio_clients-35.7.0.data/data/etc/rse-accounts.cfg.template +25 -0
  77. rucio_clients-35.7.0.data/data/etc/rucio.cfg.atlas.client.template +42 -0
  78. rucio_clients-35.7.0.data/data/etc/rucio.cfg.template +257 -0
  79. rucio_clients-35.7.0.data/data/requirements.client.txt +15 -0
  80. rucio_clients-35.7.0.data/data/rucio_client/merge_rucio_configs.py +144 -0
  81. rucio_clients-35.7.0.data/scripts/rucio +2542 -0
  82. rucio_clients-35.7.0.data/scripts/rucio-admin +2447 -0
  83. rucio_clients-35.7.0.dist-info/METADATA +50 -0
  84. rucio_clients-35.7.0.dist-info/RECORD +88 -0
  85. rucio_clients-35.7.0.dist-info/WHEEL +5 -0
  86. rucio_clients-35.7.0.dist-info/licenses/AUTHORS.rst +97 -0
  87. rucio_clients-35.7.0.dist-info/licenses/LICENSE +201 -0
  88. rucio_clients-35.7.0.dist-info/top_level.txt +1 -0
rucio/vcsversion.py ADDED
@@ -0,0 +1,11 @@
1
+
2
+ '''
3
+ This file is automatically generated; Do not edit it. :)
4
+ '''
5
+ VERSION_INFO = {
6
+ 'final': True,
7
+ 'version': '35.7.0',
8
+ 'branch_nick': 'release-35-LTS',
9
+ 'revision_id': 'c96dca5cf90ca93cb024f30f987ed8c48815a64d',
10
+ 'revno': 13202
11
+ }
rucio/version.py ADDED
@@ -0,0 +1,38 @@
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 rucio.vcsversion import VERSION_INFO
16
+
17
+ RUCIO_VERSION = [VERSION_INFO['version'], ]
18
+ FINAL = VERSION_INFO['final'] # This becomes true at Release Candidate time
19
+
20
+
21
+ def canonical_version_string() -> str:
22
+ """ Get the canonical string """
23
+ return '.'.join(filter(None, RUCIO_VERSION))
24
+
25
+
26
+ def version_string() -> str:
27
+ """ Get the version string """
28
+ return canonical_version_string()
29
+
30
+
31
+ def vcs_version_string() -> str:
32
+ """ Get the VCS version string """
33
+ return "%s:%s" % (VERSION_INFO['branch_nick'], VERSION_INFO['revision_id'])
34
+
35
+
36
+ def version_string_with_vcs() -> str:
37
+ """ Get the version string with VCS """
38
+ return "%s-%s" % (canonical_version_string(), vcs_version_string())
@@ -0,0 +1,25 @@
1
+ {
2
+ "lxplus.cern.ch":{
3
+ "username":"USERNAME",
4
+ "password":"PASSWORD",
5
+ "host":"lxplus.cern.ch"
6
+ },
7
+ "swift.cern.ch": {
8
+ "access_key": "ACCESSKEY",
9
+ "secret_key": "PASSWORD",
10
+ "host_base": "swift.cern.ch",
11
+ "host_bucket": "swift.cern.ch",
12
+ "progress_meter": "False",
13
+ "skip_existing": "False"
14
+ },
15
+ "posix": {},
16
+ "DESY-ZN_SCRATCHDISK": {
17
+ "auth_type": "cert",
18
+ "timeout":300
19
+ },
20
+ "TAIWAN-LCG2_PPSSCRATCHDISK": {
21
+ "cert": ["/tmp/x509up","/tmp/x509up"],
22
+ "auth_type": "cert",
23
+ "timeout":300
24
+ }
25
+ }
@@ -0,0 +1,42 @@
1
+ # Copyright 2014-2021 CERN
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
+ # Authors:
16
+ # - Vincent Garonne <vincent.garonne@cern.ch>, 2014
17
+ # - Mario Lassnig <mario.lassnig@cern.ch>, 2018
18
+ # - Nicolo Magini <nicolo.magini@cern.ch>, 2018
19
+ # - Tomas Javurek <tomas.javurek@cern.ch>, 2019
20
+ # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
21
+
22
+ [common]
23
+
24
+ [client]
25
+ rucio_host = https://voatlasrucio-server-prod.cern.ch:443
26
+ auth_host = https://voatlasrucio-auth-prod.cern.ch:443
27
+ client_x509_proxy = $X509_USER_PROXY
28
+ request_retries = 3
29
+ auth_type = x509_proxy
30
+
31
+ [policy]
32
+ permission = atlas
33
+ schema = atlas
34
+ lfn2pfn_algorithm_default = hash
35
+ support = hn-atlas-dist-analysis-help@cern.ch
36
+ support_rucio = https://github.com/rucio/rucio/issues/
37
+
38
+ [upload]
39
+ #transfer_timeout = 3600
40
+
41
+ [download]
42
+ #transfer_timeout = 3600
@@ -0,0 +1,257 @@
1
+ # Copyright 2012-2022 CERN
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
+ # Authors:
16
+ # - Mario Lassnig <mario.lassnig@cern.ch>, 2012-2020
17
+ # - Vincent Garonne <vincent.garonne@cern.ch>, 2012-2017
18
+ # - Thomas Beermann <thomas.beermann@cern.ch>, 2012-2021
19
+ # - Luis Rodrigues <lfrodrigues@gmail.com>, 2013
20
+ # - Cedric Serfon <cedric.serfon@cern.ch>, 2013
21
+ # - Wen Guan <wen.guan@cern.ch>, 2014
22
+ # - Fernando López <felopez@cern.ch>, 2015
23
+ # - Martin Barisits <martin.barisits@cern.ch>, 2015-2021
24
+ # - Vitjan Zavrtanik <vitjan.zavrtanik@cern.ch>, 2017
25
+ # - Stefan Prenner <stefan.prenner@cern.ch>, 2018
26
+ # - Nicolo Magini <nicolo.magini@cern.ch>, 2018
27
+ # - Frank Berghaus <berghaus@cern.ch>, 2019
28
+ # - Dilaksun Bavarajan <dilaksun.bavarajan@cern.ch>, 2019
29
+ # - James Perry <j.perry@epcc.ed.ac.uk>, 2019
30
+ # - Ruturaj Gujar <ruturaj.gujar23@gmail.com>, 2019
31
+ # - Jaroslav Guenther <jaroslav.guenther@cern.ch>, 2019
32
+ # - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020-2021
33
+ # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
34
+ # - Radu Carpa <radu.carpa@cern.ch>, 2021-2022
35
+ # - Rakshita Varadarajan <rakshitajps@gmail.com>, 2021
36
+ # - Joel Dierkes <joel.dierkes@cern.ch>, 2021
37
+
38
+ [common]
39
+ logdir = /var/log/rucio
40
+ loglevel = DEBUG
41
+ logformat = %%(asctime)s\t%%(process)d\t%%(levelname)s\t%%(message)s
42
+ mailtemplatedir=/opt/rucio/etc/mail_templates
43
+
44
+ [client]
45
+ rucio_host = https://rucio-server-prod.cern.ch:443
46
+ auth_host = https://rucio-auth-prod.cern.ch:443
47
+ auth_type = userpass
48
+ #auth_type = gss
49
+ #auth_type = x509_proxy
50
+ #auth_type = ssh
51
+ username = ddmlab
52
+ password = secret
53
+ ca_cert = /opt/rucio/etc/web/ca.crt
54
+ #client_cert = /opt/rucio/etc/web/client.crt
55
+ #client_key = /opt/rucio/etc/web/client.key
56
+ #client_x509_proxy = $X509_USER_PROXY
57
+ #ssh_private_key = $HOME/.ssh/id_rsa
58
+ account = root
59
+ request_retries = 3
60
+ protocol_stat_retries = 6
61
+
62
+ [upload]
63
+ #transfer_timeout = 3600
64
+ #preferred_impl = xrootd, rclone
65
+
66
+ [download]
67
+ #transfer_timeout = 3600
68
+ #preferred_impl = xrootd, rclone
69
+
70
+ [core]
71
+ geoip_licence_key = LICENCEKEYGOESHERE # Get a free licence key at https://www.maxmind.com/en/geolite2/signup
72
+ default_mail_from = spamspamspam@cern.ch
73
+
74
+ [database]
75
+ default = sqlite:////tmp/rucio.db
76
+ #default = oracle://_____________:___________@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=_________)(PORT=______))(ADDRESS=(PROTOCOL=TCP)(HOST=_________)(PORT=_____))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=__________)))
77
+ #default = oracle://_____________:___________@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=______))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=_____________)))
78
+ #schema=atlas_rucio # only for cern oracle
79
+ #default = mysql+pymysql://rucio:rucio@localhost/rucio
80
+ #default = postgresql://rucio:rucio@localhost/rucio
81
+ pool_recycle=3600
82
+ echo=0
83
+ pool_reset_on_return=rollback
84
+ # Uncomment the following line to disable database connection pooling.
85
+ #poolclass = nullpool
86
+
87
+ [bootstrap]
88
+ # Hardcoded salt = 0, String = secret, Python: hashlib.sha256("0secret").hexdigest()
89
+ userpass_identity = ddmlab
90
+ userpass_pwd = 2ccee6f6dd1bc2269cddd7cd5e47578e98e430539807c36df23fab7dd13e7583
91
+ userpass_email = ph-adp-ddm-lab@cern.ch
92
+
93
+ # Default DDMLAB client certificate from /opt/rucio/etc/web/client.crt
94
+ x509_identity = emailAddress=ph-adp-ddm-lab@cern.ch,CN=DDMLAB Client Certificate,OU=PH-ADP-CO,O=CERN,ST=Geneva,C=CH
95
+ x509_email = ph-adp-ddm-lab@cern.ch
96
+
97
+ # Default DDMLAB cern account
98
+ gss_identity = ddmlab@CERN.CH
99
+ gss_email = ph-adp-ddm-lab@cern.ch
100
+
101
+ # Default DDMLAB ssh key
102
+ ssh_identity = ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq5LySllrQFpPL614sulXQ7wnIr1aGhGtl8b+HCB/0FhMSMTHwSjX78UbfqEorZV16rXrWPgUpvcbp2hqctw6eCbxwqcgu3uGWaeS5A0iWRw7oXUh6ydnVy89zGzX1FJFFDZ+AgiZ3ytp55tg1bjqqhK1OSC0pJxdNe878TRVVo5MLI0S/rZY2UovCSGFaQG2iLj14wz/YqI7NFMUuJFR4e6xmNsOP7fCZ4bGMsmnhR0GmY0dWYTupNiP5WdYXAfKExlnvFLTlDI5Mgh4Z11NraQ8pv4YE1woolYpqOc/IMMBBXFniTT4tC7cgikxWb9ZmFe+r4t6yCDpX4IL8L5GOQ== ddmlab
103
+ ssh_email = ph-adp-ddm-lab@cern.ch
104
+
105
+ # Default DDMLAB SAML Name ID
106
+ saml_id = ddmlab
107
+ saml_email = ph-adp-ddm-lab@cern.ch
108
+
109
+ [monitor]
110
+ carbon_server = rucio-graphite-int.cern.ch
111
+ carbon_port = 8125
112
+ user_scope = your_username
113
+ enable_metrics = False
114
+ metrics_port = 8080
115
+
116
+ [conveyor]
117
+ scheme = srm,gsiftp,root,http,https
118
+ transfertool = fts3
119
+ ftshosts = https://fts3-pilot.cern.ch:8446, https://fts3-pilot.cern.ch:8446
120
+ cacert = /opt/rucio/etc/web/ca.crt
121
+ usercert = /opt/rucio/tools/x509up
122
+
123
+ [messaging-fts3]
124
+ port = 61123
125
+ ssl_key_file = /home/mario/.ssh/hostkey.pem
126
+ ssl_cert_file = /home/mario/.ssh/hostcert.pem
127
+ destination = /topic/transfer.fts_monitoring_queue_state
128
+ brokers = dashb-test-mb.cern.ch
129
+ voname = atlas
130
+
131
+ [messaging-hermes]
132
+ username = ____
133
+ password = ____
134
+ port = 61023
135
+ nonssl_port = 61013
136
+ use_ssl = True
137
+ ssl_key_file = /etc/grid-security/hostkey.pem
138
+ ssl_cert_file = /etc/grid-security/hostcert.pem
139
+ destination = /topic/rucio.events
140
+ brokers = localhost
141
+ voname = atlas
142
+ email_from = Rucio <spamspamspam@cern.ch>
143
+ email_test = spamspamspam@cern.ch
144
+
145
+ [transmogrifier]
146
+ maxdids = 100000
147
+
148
+ [accounts]
149
+ # These are accounts that can write into scopes owned by another account
150
+ special_accounts = panda, tier0
151
+
152
+ [trace]
153
+ tracedir = /var/log/rucio/trace
154
+ brokers=localhost
155
+ port=61013
156
+ username = _________
157
+ password = _________
158
+ topic = /topic/rucio.tracer
159
+ trace_host = https://rucio-server-prod.cern.ch:443
160
+
161
+ [tracer-kronos]
162
+ brokers=localhost
163
+ port=61013
164
+ ssl_key_file = /etc/grid-security/hostkey.pem
165
+ ssl_cert_file = /etc/grid-security/hostcert.pem
166
+ queue = /queue/Consumer.kronos.rucio.tracer
167
+ prefetch_size = 10
168
+ chunksize = 10
169
+ subscription_id = rucio-tracer-listener
170
+ use_ssl = False
171
+ reconnect_attempts = 100
172
+ excluded_usrdns = CN=proxy,CN=Robot: Ganga Robot,CN=722147,CN=gangarbt,OU=Users,OU=Organic Units,DC=cern,DC=ch
173
+ username = _________
174
+ password = _________
175
+ dataset_wait = 60
176
+
177
+ [injector]
178
+ file = /opt/rucio/tools/test.file.1000
179
+ bytes = 1000
180
+ md5 = fd21ce524a9e45060fd3f62c4ef6a386
181
+ adler32 = 52590737
182
+ #file = /opt/rucio/tools/test.file.1G
183
+ #bytes = 1000000000
184
+ #md5sum = 1a3031f43cc0c0cf4f8341920a9faf52
185
+ #adler32 = 5ff2d417
186
+
187
+ [alembic]
188
+ cfg = /opt/rucio/etc/alembic.ini
189
+
190
+ [messaging-cache]
191
+ port = 61023
192
+ ssl_key_file = /etc/grid-security/hostkey.pem
193
+ ssl_cert_file = /etc/grid-security/hostcert.pem
194
+ destination = /topic/rucio.fax
195
+ brokers = localhost
196
+ voname = atlas
197
+ account = cache_mb
198
+
199
+ [test]
200
+ cacert = /opt/rucio/etc/web/ca.crt
201
+ #cacert = /etc/pki/tls/certs/CERN-bundle.pem
202
+ usercert = /opt/rucio/etc/web/usercert.pem
203
+ #usercert = /home/mario/.ssh/usercert_with_key.pem
204
+
205
+ [nagios]
206
+ proxy = /opt/rucio/etc/ddmadmin.proxy.nagios
207
+ rfcproxy = /opt/rucio/etc/ddmusr01.rfc.proxy
208
+ fts_servers = https://fts3-pilot.cern.ch:8446, https://fts3-devel.cern.ch:8446, https://fts3.cern.ch:8446, https://lcgfts3.gridpp.rl.ac.uk:8446, https://fts3-test.gridpp.rl.ac.uk:8446, https://fts.usatlas.bnl.gov:8446
209
+
210
+ [auditor]
211
+ cache = /opt/rucio/auditor-cache
212
+ results = /opt/rucio/auditor-results
213
+
214
+ [c3po]
215
+ placement_algorithm = t2_free_space
216
+ elastic_url = http://aianalytics01.cern.ch:9200
217
+ redis_host = localhost
218
+ redis_port = 6379
219
+
220
+ [c3po-popularity]
221
+ elastic_url = http://rucio-logger-prod-01.cern.ch:9200
222
+
223
+ [c3po-site-mapper]
224
+ panda_url = http://atlas-agis-api.cern.ch/request/pandaqueue/query/list/?json
225
+ ddm_url = http://atlas-agis-api.cern.ch/request/ddmendpoint/query/list/?json
226
+
227
+ [c3po-workload]
228
+ panda_url = http://bigpanda.cern.ch/jobs/?category=analysis&jobstatus=running
229
+ window = 604800
230
+
231
+ [policy]
232
+ package = ATLASRucioPolicy
233
+ permission = atlas
234
+ schema = atlas
235
+ lfn2pfn_algorithm_default = hash
236
+ support = hn-atlas-dist-analysis-help@cern.ch
237
+ support_rucio = https://github.com/rucio/rucio/issues/
238
+
239
+ [webui]
240
+ usercert = /opt/rucio/etc/usercert_with_key.pem
241
+
242
+ [credentials]
243
+ gcs = /opt/rucio/etc/google-cloud-storage-test.json
244
+ signature_lifetime = 3600
245
+
246
+ [saml]
247
+ config_path = /opt/rucio/lib/rucio/web/ui/common/saml/
248
+
249
+ [oidc]
250
+ idpsecrets = /opt/rucio/etc/idpsecrets.json
251
+ admin_issuer = wlcg
252
+
253
+ [api]
254
+ #endpoints = accountlimits, accounts, config, credentials, dids, export, heartbeats, identities, import, lifetime_exceptions, locks, meta, ping, redirect, replicas, requests, rses, rules, scopes, subscriptions
255
+
256
+ [transfers]
257
+ srm_https_compatibility = False
@@ -0,0 +1,15 @@
1
+ # All dependencies needed to run rucio client should be defined here
2
+ requests>=2.32.2 # Python HTTP for Humans.
3
+ urllib3>=1.26.18 # HTTP library with thread-safe connection pooling, file post, etc.
4
+ dogpile-cache>=1.2.2 # Caching API plugins (1.1.2 is the first version to support pymemcache)
5
+ tabulate>=0.9.0 # Pretty-print tabular data
6
+ jsonschema>=4.20.0 # For JSON schema validation (Policy modules)
7
+
8
+ # All dependencies needed in extras for rucio client should be defined here
9
+ paramiko>=3.4.1 # ssh_extras; SSH2 protocol library (also needed in the server)
10
+ kerberos>=1.3.1 # kerberos_extras for client and server
11
+ pykerberos>=1.2.4 # kerberos_extras for client and server
12
+ requests-kerberos>=0.14.0 # kerberos_extras for client and server
13
+ python-swiftclient>=4.4.0 # swift_extras
14
+ argcomplete>=3.1.6 # argcomplete_extras; Bash tab completion for argparse
15
+ python-magic>=0.4.27 # dumper_extras; File type identification using libmagic
@@ -0,0 +1,144 @@
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
+ import argparse
16
+ import json
17
+ import logging
18
+ import os
19
+ import sys
20
+ from pathlib import Path
21
+
22
+ try:
23
+ import yaml
24
+ except ImportError:
25
+ yaml = None
26
+ import configparser
27
+
28
+ # Multi-word sections used in kubernetes are slightly different from what rucio expects.
29
+ # Usually, it's just a .replace('-', '_'), but not for hermes2, which doesn't follow any convention.
30
+ multi_word_sections = {
31
+ 'messaging_fts3': 'messaging-fts3',
32
+ 'messaging_cache': 'messaging-cache',
33
+ 'messaging_hermes': 'messaging-hermes',
34
+ 'messaging_hermes2': 'hermes',
35
+ 'nongrid_trace': 'nongrid-trace',
36
+ 'tracer_kronos': 'tracer-kronos',
37
+ }
38
+
39
+
40
+ def load_flat_config(flat_config):
41
+ """
42
+ takes a dict of the form: {"section_option": "value"}
43
+ and converts to {"section": {"option": "value"}
44
+ """
45
+ config_dict = {}
46
+ for flat_key, config_value in flat_config.items():
47
+ section = option = None
48
+ # Try parsing a multi-word section
49
+ for mw_key in multi_word_sections:
50
+ if flat_key.startswith(mw_key + '_'):
51
+ section = mw_key
52
+ option = flat_key[len(mw_key) + 1:]
53
+
54
+ # It didn't match any known multi-word section, assume it's a single word
55
+ if not section:
56
+ section, option = flat_key.split('_', maxsplit=1)
57
+
58
+ config_dict.setdefault(section, {})[option] = config_value
59
+ return config_dict
60
+
61
+
62
+ def fix_multi_word_sections(config_dict):
63
+ return {multi_word_sections.get(section, section): config_for_section for section, config_for_section in config_dict.items()}
64
+
65
+
66
+ def config_len(config_dict):
67
+ return sum(len(option) for _, option in config_dict.items())
68
+
69
+
70
+ def merge_configs(source_file_paths, dest_file_path, use_env=True, logger=logging.log):
71
+ """
72
+ Merge multiple configuration sources into one rucio.cfg.
73
+ On conflicting values, relies on the default python's ConfigParser behavior: the value from last source wins.
74
+ Sources can be .ini, .yaml, or .json files. Json is supported as a compromise solution for easier integration
75
+ with kubernetes (because both python and helm natively support it).
76
+ If use_env=True, env variables starting with RUCIO_CFG_ are also merged as the last (highest priority) source.
77
+ """
78
+
79
+ parser = configparser.ConfigParser()
80
+ for path in source_file_paths:
81
+ path = Path(path)
82
+
83
+ if not path.exists():
84
+ logger(logging.WARNING, "Skipping {}: path doesn't exist".format(path))
85
+ continue
86
+
87
+ if path.is_dir():
88
+ file_paths = sorted(p for p in path.iterdir() if not p.name.startswith(".") and p.is_file())
89
+ else:
90
+ file_paths = [path]
91
+
92
+ for file_path in file_paths:
93
+ try:
94
+ if file_path.suffix == '.json':
95
+ with open(file_path, 'r') as f:
96
+ file_config = fix_multi_word_sections(json.load(f))
97
+ parser.read_dict(file_config)
98
+ elif yaml and file_path.suffix in ['.yaml', '.yml']:
99
+ with open(file_path, 'r') as f:
100
+ file_config = fix_multi_word_sections(yaml.safe_load(f))
101
+ parser.read_dict(file_config)
102
+ elif path.is_file() or file_path.suffix in ['.ini', '.cfg', '.config']:
103
+ local_parser = configparser.ConfigParser()
104
+ local_parser.read(file_path)
105
+ file_config = {section: {option: value for option, value in section_proxy.items()} for section, section_proxy in local_parser.items()}
106
+ else:
107
+ logger(logging.WARNING, "Skipping file {} due to wrong extension".format(file_path))
108
+ continue
109
+
110
+ parser.read_dict(file_config)
111
+ logger(logging.INFO, "Merged {} configuration values from {}".format(config_len(file_config), file_path))
112
+ except Exception as error:
113
+ logger(logging.WARNING, "Skipping file {} due to error: {}".format(file_path, error))
114
+
115
+ if use_env:
116
+ # env variables use the following format: "RUCIO_CFG_{section.substitute('-','_').upper}_{option.substitute('-', '_').upper}"
117
+ env_config = {}
118
+ for env_key, env_value in os.environ.items():
119
+ rucio_cfg_prefix = 'RUCIO_CFG_'
120
+ if not env_key.startswith(rucio_cfg_prefix):
121
+ continue
122
+ env_key = env_key[len(rucio_cfg_prefix):].lower() # convert "RUCIO_CFG_WHATEVER" to "whatever"
123
+ env_config[env_key] = env_value
124
+
125
+ env_config = fix_multi_word_sections(load_flat_config(env_config))
126
+ parser.read_dict(env_config)
127
+ logger(logging.INFO, "Merged {} configuration values from ENV".format(config_len(env_config)))
128
+
129
+ if dest_file_path:
130
+ logger(logging.INFO, "Writing {}".format(dest_file_path))
131
+ with open(dest_file_path, 'w') as dest_file:
132
+ parser.write(dest_file)
133
+ else:
134
+ parser.write(sys.stdout)
135
+
136
+
137
+ logging.getLogger().setLevel(logging.INFO)
138
+ parser = argparse.ArgumentParser(description="Merge multiple rucio configuration sources into one rucio.cfg")
139
+ parser.add_argument("--use-env", action="store_true", default=False, help='Also source config from RUCIO_CFG_* env variables')
140
+ parser.add_argument('-s', '--source', type=str, nargs='*', help='Source config file paths (in .json, .yaml or .ini format)')
141
+ parser.add_argument('-d', '--destination', default=None, help='Destination file path')
142
+ args = parser.parse_args()
143
+
144
+ merge_configs(args.source or [], args.destination, use_env=args.use_env)