rucio 37.5.0__py3-none-any.whl → 37.6.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 might be problematic. Click here for more details.

Files changed (155) hide show
  1. rucio/cli/bin_legacy/rucio.py +1 -1
  2. rucio/cli/bin_legacy/rucio_admin.py +1 -1
  3. rucio/cli/did.py +2 -2
  4. rucio/cli/rse.py +2 -3
  5. rucio/cli/subscription.py +1 -1
  6. rucio/client/baseclient.py +5 -1
  7. rucio/client/didclient.py +16 -16
  8. rucio/client/downloadclient.py +14 -14
  9. rucio/client/lockclient.py +3 -3
  10. rucio/client/replicaclient.py +2 -2
  11. rucio/client/touchclient.py +1 -1
  12. rucio/client/uploadclient.py +725 -181
  13. rucio/common/config.py +1 -2
  14. rucio/common/constants.py +2 -0
  15. rucio/common/didtype.py +2 -2
  16. rucio/common/dumper/__init__.py +1 -1
  17. rucio/common/pcache.py +20 -25
  18. rucio/common/plugins.py +10 -17
  19. rucio/common/schema/__init__.py +7 -5
  20. rucio/common/utils.py +1 -1
  21. rucio/core/authentication.py +1 -1
  22. rucio/core/credential.py +1 -1
  23. rucio/core/did.py +54 -54
  24. rucio/core/did_meta_plugins/__init__.py +10 -10
  25. rucio/core/did_meta_plugins/did_column_meta.py +9 -9
  26. rucio/core/did_meta_plugins/did_meta_plugin_interface.py +3 -3
  27. rucio/core/did_meta_plugins/elasticsearch_meta.py +7 -7
  28. rucio/core/did_meta_plugins/json_meta.py +2 -2
  29. rucio/core/did_meta_plugins/mongo_meta.py +9 -9
  30. rucio/core/did_meta_plugins/postgres_meta.py +7 -7
  31. rucio/core/dirac.py +1 -1
  32. rucio/core/lifetime_exception.py +2 -2
  33. rucio/core/lock.py +7 -7
  34. rucio/core/meta_conventions.py +2 -2
  35. rucio/core/monitor.py +1 -1
  36. rucio/core/naming_convention.py +1 -1
  37. rucio/core/nongrid_trace.py +2 -2
  38. rucio/core/oidc.py +2 -2
  39. rucio/core/permission/__init__.py +7 -5
  40. rucio/core/permission/generic.py +2 -2
  41. rucio/core/permission/generic_multi_vo.py +2 -2
  42. rucio/core/replica.py +17 -17
  43. rucio/core/rule.py +30 -30
  44. rucio/core/rule_grouping.py +2 -3
  45. rucio/core/scope.py +1 -1
  46. rucio/core/trace.py +2 -2
  47. rucio/daemons/auditor/__init__.py +1 -1
  48. rucio/daemons/badreplicas/minos.py +9 -3
  49. rucio/daemons/badreplicas/minos_temporary_expiration.py +5 -2
  50. rucio/daemons/badreplicas/necromancer.py +9 -3
  51. rucio/daemons/bb8/common.py +1 -1
  52. rucio/daemons/bb8/nuclei_background_rebalance.py +1 -1
  53. rucio/daemons/bb8/t2_background_rebalance.py +1 -1
  54. rucio/daemons/cache/consumer.py +1 -1
  55. rucio/daemons/conveyor/finisher.py +13 -4
  56. rucio/daemons/conveyor/poller.py +5 -2
  57. rucio/daemons/conveyor/receiver.py +1 -1
  58. rucio/daemons/follower/follower.py +1 -1
  59. rucio/daemons/hermes/hermes.py +2 -2
  60. rucio/daemons/judge/cleaner.py +2 -2
  61. rucio/daemons/judge/evaluator.py +7 -7
  62. rucio/daemons/judge/injector.py +2 -2
  63. rucio/daemons/judge/repairer.py +2 -2
  64. rucio/daemons/replicarecoverer/suspicious_replica_recoverer.py +1 -1
  65. rucio/daemons/storage/consistency/actions.py +3 -3
  66. rucio/daemons/transmogrifier/transmogrifier.py +1 -1
  67. rucio/daemons/undertaker/undertaker.py +6 -6
  68. rucio/db/sqla/constants.py +4 -3
  69. rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py +1 -1
  70. rucio/db/sqla/migrate_repo/versions/4df2c5ddabc0_remove_temporary_dids.py +1 -1
  71. rucio/db/sqla/migrate_repo/versions/c129ccdb2d5_add_lumiblocknr_to_dids.py +1 -1
  72. rucio/db/sqla/models.py +1 -1
  73. rucio/db/sqla/session.py +7 -7
  74. rucio/gateway/account.py +65 -90
  75. rucio/gateway/did.py +26 -26
  76. rucio/gateway/dirac.py +1 -1
  77. rucio/gateway/lifetime_exception.py +1 -1
  78. rucio/gateway/replica.py +2 -2
  79. rucio/rse/protocols/ngarc.py +2 -2
  80. rucio/rse/protocols/srm.py +1 -1
  81. rucio/rse/protocols/webdav.py +8 -1
  82. rucio/tests/common.py +4 -4
  83. rucio/vcsversion.py +3 -3
  84. rucio/web/rest/flaskapi/v1/accounts.py +20 -20
  85. rucio/web/rest/flaskapi/v1/archives.py +2 -2
  86. rucio/web/rest/flaskapi/v1/common.py +1 -1
  87. rucio/web/rest/flaskapi/v1/dids.py +188 -188
  88. rucio/web/rest/flaskapi/v1/lifetime_exceptions.py +5 -5
  89. rucio/web/rest/flaskapi/v1/locks.py +13 -13
  90. rucio/web/rest/flaskapi/v1/main.py +1 -0
  91. rucio/web/rest/flaskapi/v1/redirect.py +2 -2
  92. rucio/web/rest/flaskapi/v1/replicas.py +16 -16
  93. rucio/web/rest/flaskapi/v1/requests.py +16 -16
  94. rucio/web/rest/flaskapi/v1/subscriptions.py +7 -7
  95. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-abacus-account +8 -1
  96. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-abacus-rse +8 -1
  97. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-auditor +1 -1
  98. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-throttler +7 -1
  99. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-follower +1 -1
  100. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-judge-cleaner +9 -1
  101. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-necromancer +7 -1
  102. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-replica-recoverer +31 -9
  103. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-undertaker +8 -2
  104. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/METADATA +1 -1
  105. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/RECORD +155 -155
  106. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/alembic.ini.template +0 -0
  107. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/alembic_offline.ini.template +0 -0
  108. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/globus-config.yml.template +0 -0
  109. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/ldap.cfg.template +0 -0
  110. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
  111. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
  112. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
  113. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
  114. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
  115. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
  116. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
  117. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/rucio.cfg.atlas.client.template +0 -0
  118. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/rucio.cfg.template +0 -0
  119. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/etc/rucio_multi_vo.cfg.template +0 -0
  120. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/requirements.server.txt +0 -0
  121. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/tools/bootstrap.py +0 -0
  122. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
  123. {rucio-37.5.0.data → rucio-37.6.0.data}/data/rucio/tools/reset_database.py +0 -0
  124. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio +0 -0
  125. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-abacus-collection-replica +0 -0
  126. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-admin +0 -0
  127. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-atropos +0 -0
  128. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-automatix +0 -0
  129. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-bb8 +0 -0
  130. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-cache-client +0 -0
  131. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-cache-consumer +0 -0
  132. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-finisher +0 -0
  133. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-poller +0 -0
  134. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-preparer +0 -0
  135. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-receiver +0 -0
  136. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-stager +0 -0
  137. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-conveyor-submitter +0 -0
  138. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-dark-reaper +0 -0
  139. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-dumper +0 -0
  140. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-hermes +0 -0
  141. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-judge-evaluator +0 -0
  142. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-judge-injector +0 -0
  143. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-judge-repairer +0 -0
  144. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-kronos +0 -0
  145. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-minos +0 -0
  146. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-minos-temporary-expiration +0 -0
  147. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-oauth-manager +0 -0
  148. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-reaper +0 -0
  149. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-rse-decommissioner +0 -0
  150. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-storage-consistency-actions +0 -0
  151. {rucio-37.5.0.data → rucio-37.6.0.data}/scripts/rucio-transmogrifier +0 -0
  152. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/WHEEL +0 -0
  153. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/licenses/AUTHORS.rst +0 -0
  154. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/licenses/LICENSE +0 -0
  155. {rucio-37.5.0.dist-info → rucio-37.6.0.dist-info}/top_level.txt +0 -0
rucio/gateway/account.py CHANGED
@@ -22,27 +22,22 @@ from rucio.common.types import InternalAccount
22
22
  from rucio.common.utils import gateway_update_return_dict
23
23
  from rucio.core import account as account_core
24
24
  from rucio.core.rse import get_rse_id
25
- from rucio.db.sqla.constants import AccountType
26
- from rucio.db.sqla.session import read_session, stream_session, transactional_session
25
+ from rucio.db.sqla.constants import AccountType, DatabaseOperationType
26
+ from rucio.db.sqla.session import db_session
27
27
 
28
28
  if TYPE_CHECKING:
29
29
  from collections.abc import Iterator
30
30
 
31
- from sqlalchemy.orm import Session
32
-
33
31
  from rucio.common.types import AccountAttributesDict, IdentityDict, UsageDict
34
32
  from rucio.db.sqla.models import Account
35
33
 
36
34
 
37
- @transactional_session
38
35
  def add_account(
39
36
  account: str,
40
37
  type_: str,
41
38
  email: str,
42
39
  issuer: str,
43
40
  vo: str = 'def',
44
- *,
45
- session: "Session"
46
41
  ) -> None:
47
42
  """
48
43
  Creates an account with the provided account name, contact information, etc.
@@ -53,29 +48,27 @@ def add_account(
53
48
 
54
49
  :param issuer: The issuer account_core.
55
50
  :param vo: The VO to act on.
56
- :param session: The database session in use.
57
51
 
58
52
  """
59
53
 
60
54
  validate_schema(name='account', obj=account, vo=vo)
61
55
 
62
56
  kwargs = {'account': account, 'type': type_}
63
- auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_account', kwargs=kwargs, session=session)
64
- if not auth_result.allowed:
65
- raise rucio.common.exception.AccessDenied('Account %s can not add account. %s' % (issuer, auth_result.message))
66
57
 
67
- internal_account = InternalAccount(account, vo=vo)
58
+ with db_session(DatabaseOperationType.WRITE) as session:
59
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_account', kwargs=kwargs, session=session)
60
+ if not auth_result.allowed:
61
+ raise rucio.common.exception.AccessDenied('Account %s can not add account. %s' % (issuer, auth_result.message))
62
+
63
+ internal_account = InternalAccount(account, vo=vo)
68
64
 
69
- account_core.add_account(internal_account, AccountType[type_.upper()], email, session=session)
65
+ account_core.add_account(internal_account, AccountType[type_.upper()], email, session=session)
70
66
 
71
67
 
72
- @transactional_session
73
68
  def del_account(
74
69
  account: str,
75
70
  issuer: str,
76
71
  vo: str = 'def',
77
- *,
78
- session: "Session"
79
72
  ) -> None:
80
73
  """
81
74
  Disables an account with the provided account name.
@@ -83,25 +76,22 @@ def del_account(
83
76
  :param account: The account name.
84
77
  :param issuer: The issuer account.
85
78
  :param vo: The VO to act on.
86
- :param session: The database session in use.
87
79
 
88
80
  """
89
81
  kwargs = {'account': account}
90
- auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_account', kwargs=kwargs, session=session)
91
- if not auth_result.allowed:
92
- raise rucio.common.exception.AccessDenied('Account %s can not delete account. %s' % (issuer, auth_result.message))
82
+ with db_session(DatabaseOperationType.WRITE) as session:
83
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_account', kwargs=kwargs, session=session)
84
+ if not auth_result.allowed:
85
+ raise rucio.common.exception.AccessDenied('Account %s can not delete account. %s' % (issuer, auth_result.message))
93
86
 
94
- internal_account = InternalAccount(account, vo=vo)
87
+ internal_account = InternalAccount(account, vo=vo)
95
88
 
96
- account_core.del_account(internal_account, session=session)
89
+ account_core.del_account(internal_account, session=session)
97
90
 
98
91
 
99
- @read_session
100
92
  def get_account_info(
101
93
  account: str,
102
94
  vo: str = 'def',
103
- *,
104
- session: "Session"
105
95
  ) -> "Account":
106
96
  """
107
97
  Returns the info like the statistics information associated to an account_core.
@@ -109,25 +99,23 @@ def get_account_info(
109
99
  :param account: The account name.
110
100
  :returns: A list with all account information.
111
101
  :param vo: The VO to act on.
112
- :param session: The database session in use.
102
+
113
103
  """
114
104
 
115
105
  internal_account = InternalAccount(account, vo=vo)
116
106
 
117
- acc = account_core.get_account(internal_account, session=session)
118
- acc.account = acc.account.external
119
- return acc
107
+ with db_session(DatabaseOperationType.READ) as session:
108
+ acc = account_core.get_account(internal_account, session=session)
109
+ acc.account = acc.account.external
110
+ return acc
120
111
 
121
112
 
122
- @transactional_session
123
113
  def update_account(
124
114
  account: str,
125
115
  key: str,
126
116
  value: Any,
127
117
  issuer: str = 'root',
128
118
  vo: str = 'def',
129
- *,
130
- session: "Session"
131
119
  ) -> None:
132
120
  """ Update a property of an account_core.
133
121
 
@@ -136,21 +124,21 @@ def update_account(
136
124
  :param value: Property value.
137
125
  :param issuer: The issuer account
138
126
  :param vo: The VO to act on.
139
- :param session: The database session in use.
127
+
140
128
  """
141
129
  validate_schema(name='account', obj=account, vo=vo)
142
130
  kwargs = {}
143
- auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='update_account', kwargs=kwargs, session=session)
144
- if not auth_result.allowed:
145
- raise rucio.common.exception.AccessDenied('Account %s can not change %s of the account. %s' % (issuer, key, auth_result.message))
131
+ with db_session(DatabaseOperationType.WRITE) as session:
132
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='update_account', kwargs=kwargs, session=session)
133
+ if not auth_result.allowed:
134
+ raise rucio.common.exception.AccessDenied('Account %s can not change %s of the account. %s' % (issuer, key, auth_result.message))
146
135
 
147
- internal_account = InternalAccount(account, vo=vo)
136
+ internal_account = InternalAccount(account, vo=vo)
148
137
 
149
- return account_core.update_account(internal_account, key, value, session=session)
138
+ return account_core.update_account(internal_account, key, value, session=session)
150
139
 
151
140
 
152
- @stream_session
153
- def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *, session: "Session") -> 'Iterator[dict[str, Any]]':
141
+ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def') -> 'Iterator[dict[str, Any]]':
154
142
  """
155
143
  Lists all the Rucio account names.
156
144
 
@@ -158,7 +146,6 @@ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *,
158
146
 
159
147
  :param filter_: Dictionary of attributes by which the input data should be filtered
160
148
  :param vo: The VO to act on.
161
- :param session: The database session in use.
162
149
 
163
150
  :returns: List of all accounts.
164
151
  """
@@ -169,80 +156,73 @@ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *,
169
156
  filter_['account'] = InternalAccount(filter_['account'], vo=vo)
170
157
  else:
171
158
  filter_['account'] = InternalAccount(account='*', vo=vo)
172
- for result in account_core.list_accounts(filter_=filter_, session=session):
173
- yield gateway_update_return_dict(result, session=session)
159
+
160
+ with db_session(DatabaseOperationType.READ) as session:
161
+ for result in account_core.list_accounts(filter_=filter_, session=session):
162
+ yield gateway_update_return_dict(result, session=session)
174
163
 
175
164
 
176
- @read_session
177
165
  def account_exists(
178
166
  account: str,
179
167
  vo: str = 'def',
180
- *,
181
- session: "Session"
182
168
  ) -> bool:
183
169
  """
184
170
  Checks to see if account exists. This procedure does not check it's status.
185
171
 
186
172
  :param account: Name of the account.
187
173
  :param vo: The VO to act on.
188
- :param session: The database session in use.
174
+
189
175
  :returns: True if found, otherwise false.
190
176
  """
191
177
 
192
178
  internal_account = InternalAccount(account, vo=vo)
193
179
 
194
- return account_core.account_exists(internal_account, session=session)
180
+ with db_session(DatabaseOperationType.READ) as session:
181
+ return account_core.account_exists(internal_account, session=session)
195
182
 
196
183
 
197
- @read_session
198
184
  def list_identities(
199
185
  account: str,
200
186
  vo: str = 'def',
201
- *,
202
- session: "Session"
203
187
  ) -> list["IdentityDict"]:
204
188
  """
205
189
  List all identities on an account_core.
206
190
 
207
191
  :param account: The account name.
208
192
  :param vo: The VO to act on.
209
- :param session: The database session in use.
193
+
210
194
  """
211
195
 
212
196
  internal_account = InternalAccount(account, vo=vo)
213
197
 
214
- return account_core.list_identities(internal_account, session=session)
198
+ with db_session(DatabaseOperationType.READ) as session:
199
+ return account_core.list_identities(internal_account, session=session)
215
200
 
216
201
 
217
- @read_session
218
202
  def list_account_attributes(
219
203
  account: str,
220
204
  vo: str = 'def',
221
- *,
222
- session: "Session"
223
205
  ) -> list["AccountAttributesDict"]:
224
206
  """
225
207
  Returns all the attributes for the given account.
226
208
 
227
209
  :param account: The account name.
228
210
  :param vo: The VO to act on
229
- :param session: The database session in use.
211
+
230
212
  """
231
213
 
232
214
  internal_account = InternalAccount(account, vo=vo)
233
215
 
234
- return account_core.list_account_attributes(internal_account, session=session)
216
+ with db_session(DatabaseOperationType.READ) as session:
217
+ return account_core.list_account_attributes(internal_account, session=session)
235
218
 
236
219
 
237
- @transactional_session
238
220
  def add_account_attribute(
239
221
  key: str,
240
222
  value: Any,
241
223
  account: str,
242
224
  issuer: str,
243
225
  vo: str = 'def',
244
- *,
245
- session: "Session"
246
226
  ) -> None:
247
227
  """
248
228
  Add an attribute to an account.
@@ -252,29 +232,27 @@ def add_account_attribute(
252
232
  :param account: The account name.
253
233
  :param issuer: The issuer account.
254
234
  :param vo: The VO to act on.
255
- :param session: The database session in use.
235
+
256
236
  """
257
237
  validate_schema(name='account_attribute', obj=key, vo=vo)
258
238
  validate_schema(name='account_attribute', obj=value, vo=vo)
259
239
 
260
240
  kwargs = {'account': account, 'key': key, 'value': value}
261
- auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_attribute', kwargs=kwargs, session=session)
262
- if not auth_result.allowed:
263
- raise rucio.common.exception.AccessDenied('Account %s can not add attributes. %s' % (issuer, auth_result.message))
241
+ with db_session(DatabaseOperationType.WRITE) as session:
242
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_attribute', kwargs=kwargs, session=session)
243
+ if not auth_result.allowed:
244
+ raise rucio.common.exception.AccessDenied('Account %s can not add attributes. %s' % (issuer, auth_result.message))
264
245
 
265
- internal_account = InternalAccount(account, vo=vo)
246
+ internal_account = InternalAccount(account, vo=vo)
266
247
 
267
- account_core.add_account_attribute(internal_account, key, value, session=session)
248
+ account_core.add_account_attribute(internal_account, key, value, session=session)
268
249
 
269
250
 
270
- @transactional_session
271
251
  def del_account_attribute(
272
252
  key: str,
273
253
  account: str,
274
254
  issuer: str,
275
255
  vo: str = 'def',
276
- *,
277
- session: "Session"
278
256
  ) -> None:
279
257
  """
280
258
  Delete an attribute to an account.
@@ -283,26 +261,24 @@ def del_account_attribute(
283
261
  :param account: The account name.
284
262
  :param issuer: The issuer account.
285
263
  :param vo: The VO to act on.
286
- :param session: The database session in use.
264
+
287
265
  """
288
266
  kwargs = {'account': account, 'key': key}
289
- auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_attribute', kwargs=kwargs, session=session)
290
- if not auth_result.allowed:
291
- raise rucio.common.exception.AccessDenied('Account %s can not delete attribute. %s' % (issuer, auth_result.message))
267
+ with db_session(DatabaseOperationType.WRITE) as session:
268
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_attribute', kwargs=kwargs, session=session)
269
+ if not auth_result.allowed:
270
+ raise rucio.common.exception.AccessDenied('Account %s can not delete attribute. %s' % (issuer, auth_result.message))
292
271
 
293
- internal_account = InternalAccount(account, vo=vo)
272
+ internal_account = InternalAccount(account, vo=vo)
294
273
 
295
- account_core.del_account_attribute(internal_account, key, session=session)
274
+ account_core.del_account_attribute(internal_account, key, session=session)
296
275
 
297
276
 
298
- @read_session
299
277
  def get_usage(
300
278
  rse: str,
301
279
  account: str,
302
280
  issuer: str,
303
281
  vo: str = 'def',
304
- *,
305
- session: "Session"
306
282
  ) -> "UsageDict":
307
283
  """
308
284
  Returns current values of the specified counter, or raises CounterNotFound if the counter does not exist.
@@ -311,23 +287,21 @@ def get_usage(
311
287
  :param account: The account name.
312
288
  :param issuer: The issuer account.
313
289
  :param vo: The VO to act on.
314
- :param session: The database session in use.
290
+
315
291
  :returns: A dictionary with total and bytes.
316
292
  """
317
- rse_id = get_rse_id(rse=rse, vo=vo, session=session)
318
- internal_account = InternalAccount(account, vo=vo)
293
+ with db_session(DatabaseOperationType.READ) as session:
294
+ rse_id = get_rse_id(rse=rse, vo=vo, session=session)
295
+ internal_account = InternalAccount(account, vo=vo)
319
296
 
320
- return account_core.get_usage(rse_id, internal_account, session=session)
297
+ return account_core.get_usage(rse_id, internal_account, session=session)
321
298
 
322
299
 
323
- @read_session
324
300
  def get_usage_history(
325
301
  rse: str,
326
302
  account: str,
327
303
  issuer: str,
328
304
  vo: str = 'def',
329
- *,
330
- session: "Session"
331
305
  ) -> list["UsageDict"]:
332
306
  """
333
307
  Returns historical values of the specified counter, or raises CounterNotFound if the counter does not exist.
@@ -336,10 +310,11 @@ def get_usage_history(
336
310
  :param account: The account name.
337
311
  :param issuer: The issuer account.
338
312
  :param vo: The VO to act on.
339
- :param session: The database session in use.
313
+
340
314
  :returns: A dictionary with total and bytes.
341
315
  """
342
- rse_id = get_rse_id(rse=rse, vo=vo, session=session)
343
- internal_account = InternalAccount(account, vo=vo)
316
+ with db_session(DatabaseOperationType.READ) as session:
317
+ rse_id = get_rse_id(rse=rse, vo=vo, session=session)
318
+ internal_account = InternalAccount(account, vo=vo)
344
319
 
345
- return account_core.get_usage_history(rse_id, internal_account, session=session)
320
+ return account_core.get_usage_history(rse_id, internal_account, session=session)
rucio/gateway/did.py CHANGED
@@ -43,11 +43,11 @@ def list_dids(
43
43
  vo: str = 'def',
44
44
  ) -> 'Iterator[dict[str, Any]]':
45
45
  """
46
- List dids in a scope.
46
+ List DIDs in a scope.
47
47
 
48
48
  :param scope: The scope name.
49
49
  :param filters: Filter arguments in form supported by the filter engine.
50
- :param did_type: The type of the did: all(container, dataset, file), collection(dataset or container), dataset, container
50
+ :param did_type: The type of the DID: all(container, dataset, file), collection(dataset or container), dataset, container
51
51
  :param ignore_case: Ignore case distinctions.
52
52
  :param limit: The maximum number of DIDs returned.
53
53
  :param offset: Offset number.
@@ -87,7 +87,7 @@ def add_did(
87
87
  vo: str = 'def',
88
88
  ) -> None:
89
89
  """
90
- Add data did.
90
+ Add data DID.
91
91
 
92
92
  :param scope: The scope name.
93
93
  :param name: The data identifier name.
@@ -96,7 +96,7 @@ def add_did(
96
96
  :param account: The account owner. If None, then issuer is selected as owner.
97
97
  :param statuses: Dictionary with statuses, e.g.g {'monotonic':True}.
98
98
  :meta: Meta-data associated with the data identifier is represented using key/value pairs in a dictionary.
99
- :rules: Replication rules associated with the data did. A list of dictionaries, e.g., [{'copies': 2, 'rse_expression': 'TIERS1'}, ].
99
+ :rules: Replication rules associated with the data DID. A list of dictionaries, e.g., [{'copies': 2, 'rse_expression': 'TIERS1'}, ].
100
100
  :param lifetime: DID's lifetime (in seconds).
101
101
  :param dids: The content.
102
102
  :param rse: The RSE name when registering replicas.
@@ -155,9 +155,9 @@ def add_dids(
155
155
  vo: str = 'def',
156
156
  ) -> None:
157
157
  """
158
- Bulk Add did.
158
+ Bulk Add DID.
159
159
 
160
- :param dids: A list of dids.
160
+ :param dids: A list of DIDs.
161
161
  :param issuer: The issuer account.
162
162
  :param vo: The VO to act on.
163
163
  """
@@ -193,7 +193,7 @@ def attach_dids(
193
193
  vo='def',
194
194
  ) -> None:
195
195
  """
196
- Append content to data did.
196
+ Append content to data DID.
197
197
 
198
198
  :param attachment: The attachment.
199
199
  :param issuer: The issuer account.
@@ -240,7 +240,7 @@ def attach_dids_to_dids(
240
240
  vo: str = 'def',
241
241
  ) -> None:
242
242
  """
243
- Append content to dids.
243
+ Append content to DIDs.
244
244
 
245
245
  :param attachments: The contents.
246
246
  :param issuer: The issuer account.
@@ -468,15 +468,15 @@ def scope_list(
468
468
 
469
469
  def get_did(scope: str, name: str, dynamic_depth: Optional[DIDType] = None, vo: str = 'def') -> "dict[str, Any]":
470
470
  """
471
- Retrieve a single data did.
471
+ Retrieve a single data DID.
472
472
 
473
473
  :param scope: The scope name.
474
474
  :param name: The data identifier name.
475
475
  :param dynamic_depth: the DID type to use as source for estimation of this DIDs length/bytes.
476
- If set to None, or to a value which doesn't make sense (ex: requesting depth = CONTAINER for a did of type DATASET)
476
+ If set to None, or to a value which doesn't make sense (ex: requesting depth = CONTAINER for a DID of type DATASET)
477
477
  will not compute the size dynamically.
478
478
  :param vo: The VO to act on.
479
- :return did: Dictionary containing {'name', 'scope', 'type'}, Exception otherwise
479
+ :return DID: Dictionary containing {'name', 'scope', 'type'}, Exception otherwise
480
480
  """
481
481
 
482
482
  internal_scope = InternalScope(scope, vo=vo)
@@ -496,7 +496,7 @@ def set_metadata(
496
496
  vo: str = 'def',
497
497
  ) -> None:
498
498
  """
499
- Add metadata to data did.
499
+ Add metadata to data DID.
500
500
 
501
501
  :param scope: The scope name.
502
502
  :param name: The data identifier name.
@@ -529,7 +529,7 @@ def set_metadata_bulk(
529
529
  vo: str = 'def',
530
530
  ) -> None:
531
531
  """
532
- Add metadata to data did.
532
+ Add metadata to data DID.
533
533
 
534
534
  :param scope: The scope name.
535
535
  :param name: The data identifier name.
@@ -563,7 +563,7 @@ def set_dids_metadata_bulk(
563
563
  Add metadata to a list of data identifiers.
564
564
 
565
565
  :param issuer: The issuer account.
566
- :param dids: A list of dids including metadata.
566
+ :param dids: A list of DIDs including metadata.
567
567
  :param recursive: Option to propagate the metadata update to content.
568
568
  :param vo: The VO to act on.
569
569
  """
@@ -612,8 +612,8 @@ def get_metadata_bulk(
612
612
  vo: str = 'def',
613
613
  ) -> 'Iterator[dict[str, Any]]':
614
614
  """
615
- Get metadata for a list of dids
616
- :param dids: A list of dids.
615
+ Get metadata for a list of DIDs
616
+ :param dids: A list of DIDs.
617
617
  :param inherit: A boolean. If set to true, the metadata of the parent are concatenated.
618
618
  :param plugin: The metadata plugin to query, 'ALL' for all available plugins
619
619
  :param vo: The VO to act on.
@@ -638,8 +638,8 @@ def delete_metadata(
638
638
  """
639
639
  Delete a key from the metadata column
640
640
 
641
- :param scope: the scope of did
642
- :param name: the name of the did
641
+ :param scope: the scope of DID
642
+ :param name: the name of the DID
643
643
  :param key: the key to be deleted
644
644
  :param vo: The VO to act on.
645
645
  """
@@ -685,7 +685,7 @@ def get_dataset_by_guid(
685
685
  :param guid: The GUID.
686
686
  :param vo: The VO to act on.
687
687
 
688
- :returns: A did
688
+ :returns: A DID
689
689
  """
690
690
  with db_session(DatabaseOperationType.READ) as session:
691
691
  dids = did.get_dataset_by_guid(guid=guid, session=session)
@@ -702,7 +702,7 @@ def list_parent_dids(
702
702
  vo: str = 'def',
703
703
  ) -> 'Iterator[dict[str, Any]]':
704
704
  """
705
- List parent datasets and containers of a did.
705
+ List parent datasets and containers of a DID.
706
706
 
707
707
  :param scope: The scope.
708
708
  :param name: The name.
@@ -763,7 +763,7 @@ def resurrect(
763
763
  """
764
764
  Resurrect DIDs.
765
765
 
766
- :param dids: A list of dids.
766
+ :param dids: A list of DIDs.
767
767
  :param issuer: The issuer account.
768
768
  :param vo: The VO to act on.
769
769
  """
@@ -808,7 +808,7 @@ def add_did_to_followed(
808
808
  vo: str = 'def'
809
809
  ) -> None:
810
810
  """
811
- Mark a did as followed by the given account
811
+ Mark a DID as followed by the given account
812
812
 
813
813
  :param scope: The scope name.
814
814
  :param name: The data identifier name.
@@ -828,7 +828,7 @@ def add_dids_to_followed(
828
828
  """
829
829
  Bulk mark datasets as followed
830
830
 
831
- :param dids: A list of dids.
831
+ :param dids: A list of DIDs.
832
832
  :param account: The account owner.
833
833
  """
834
834
  internal_account = InternalAccount(account, vo=vo)
@@ -842,7 +842,7 @@ def get_users_following_did(
842
842
  vo: str = 'def'
843
843
  ) -> 'Iterator[dict[str, str]]':
844
844
  """
845
- Return list of users following a did
845
+ Return list of users following a DID
846
846
 
847
847
  :param scope: The scope name.
848
848
  :param name: The data identifier name.
@@ -863,7 +863,7 @@ def remove_did_from_followed(
863
863
  vo: str = 'def'
864
864
  ) -> None:
865
865
  """
866
- Mark a did as not followed
866
+ Mark a DID as not followed
867
867
 
868
868
  :param scope: The scope name.
869
869
  :param name: The data identifier name.
@@ -890,7 +890,7 @@ def remove_dids_from_followed(
890
890
  """
891
891
  Bulk mark datasets as not followed
892
892
 
893
- :param dids: A list of dids.
893
+ :param dids: A list of DIDs.
894
894
  :param account: The account owner.
895
895
  """
896
896
  kwargs = {'dids': dids, 'issuer': issuer}
rucio/gateway/dirac.py CHANGED
@@ -63,7 +63,7 @@ def add_files(
63
63
  rses[rse] = rse_id
64
64
  lfn['rse_id'] = rses[rse]
65
65
 
66
- # Check if the issuer can add dids and use skip_availabitlity
66
+ # Check if the issuer can add DIDs and use skip_availabitlity
67
67
  for rse in rses:
68
68
  rse_id = rses[rse]
69
69
  kwargs = {'rse': rse, 'rse_id': rse_id}
@@ -59,7 +59,7 @@ def add_exception(
59
59
  """
60
60
  Add exceptions to Lifetime Model.
61
61
 
62
- :param dids: The list of dids
62
+ :param dids: The list of DIDs
63
63
  :param account: The account of the requester.
64
64
  :param pattern: The account.
65
65
  :param comments: The comments associated to the exception.
rucio/gateway/replica.py CHANGED
@@ -434,7 +434,7 @@ def list_dataset_replicas_bulk(
434
434
  vo: str = 'def'
435
435
  ) -> 'Iterator[dict[str, Any]]':
436
436
  """
437
- :param dids: The list of did dictionaries with scope and name.
437
+ :param dids: The list of DID dictionaries with scope and name.
438
438
  :param vo: The VO to act on.
439
439
 
440
440
  :returns: A list of dict dataset replicas
@@ -552,7 +552,7 @@ def add_bad_dids(
552
552
  """
553
553
  Add bad replica entries for DIDs.
554
554
 
555
- :param dids: the list of dids with bad replicas at rse.
555
+ :param dids: the list of DIDs with bad replicas at rse.
556
556
  :param rse: the rse with the bad replicas.
557
557
  :param issuer: The issuer account.
558
558
  :param state: One of the possible states : BAD
@@ -20,7 +20,7 @@ from rucio.rse.protocols import protocol
20
20
 
21
21
  try:
22
22
  import arc # pylint: disable=import-error
23
- except:
23
+ except Exception:
24
24
  pass
25
25
 
26
26
 
@@ -59,7 +59,7 @@ class Default(protocol.RSEProtocol):
59
59
  self.cfg = arc.UserConfig()
60
60
  try:
61
61
  self.cfg.ProxyPath(os.environ['X509_USER_PROXY'])
62
- except:
62
+ except Exception:
63
63
  pass
64
64
 
65
65
  def path2pfn(self, path):
@@ -101,7 +101,7 @@ class Default(protocol.RSEProtocol):
101
101
  # force type conversion
102
102
  try:
103
103
  port = int(port)
104
- except:
104
+ except Exception:
105
105
  port = ''
106
106
 
107
107
  if self.attributes['hostname'] != hostname and\
@@ -253,8 +253,15 @@ class Default(protocol.RSEProtocol):
253
253
  :raise ServiceUnavailable, RSEAccessDenied
254
254
  """
255
255
  path = self.path2pfn(pfn)
256
+
257
+ using_presigned_urls = self.rse['sign_url'] is not None
258
+
256
259
  try:
257
- result = self.session.request('HEAD', path, verify=False, timeout=self.timeout, cert=self.cert)
260
+ # use GET instead of HEAD for presigned urls
261
+ if not using_presigned_urls:
262
+ result = self.session.request('HEAD', path, verify=False, timeout=self.timeout, cert=self.cert)
263
+ else:
264
+ result = self.session.request('GET', path, verify=False, timeout=self.timeout, cert=self.cert)
258
265
  if result.status_code == 200:
259
266
  return True
260
267
  elif result.status_code in [401, ]:
rucio/tests/common.py CHANGED
@@ -102,13 +102,13 @@ def scope_name_generator() -> str:
102
102
 
103
103
 
104
104
  def did_name_generator(did_type: str = 'file', name_prefix: str = '', name_suffix: str = '', path: Optional[str] = None) -> str:
105
- """ Generate random did name.
105
+ """ Generate random DID name.
106
106
  :param did_type: A string to create a meaningful did_name depending on the did_type (file, dataset, container)
107
- :param name_prefix: String to prefix to the did name
108
- :param name_suffix: String to append to the did name
107
+ :param name_prefix: String to prefix to the DID name
108
+ :param name_suffix: String to append to the DID name
109
109
  :param path: If specified, use the path to generate the did_name
110
110
 
111
- :returns: A random did name
111
+ :returns: A random DID name
112
112
  """
113
113
  if os.getenv('POLICY') == 'belleii':
114
114
  if path is not None: