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

Files changed (202) hide show
  1. rucio/cli/bin_legacy/rucio.py +41 -22
  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/rule.py +9 -5
  6. rucio/cli/subscription.py +1 -1
  7. rucio/client/baseclient.py +9 -4
  8. rucio/client/didclient.py +16 -16
  9. rucio/client/downloadclient.py +16 -15
  10. rucio/client/exportclient.py +45 -4
  11. rucio/client/lockclient.py +3 -3
  12. rucio/client/pingclient.py +35 -4
  13. rucio/client/replicaclient.py +2 -2
  14. rucio/client/touchclient.py +3 -2
  15. rucio/client/uploadclient.py +728 -183
  16. rucio/common/cache.py +1 -2
  17. rucio/common/client.py +4 -30
  18. rucio/common/config.py +27 -3
  19. rucio/common/constants.py +5 -1
  20. rucio/common/didtype.py +2 -2
  21. rucio/common/dumper/__init__.py +1 -1
  22. rucio/common/pcache.py +20 -25
  23. rucio/common/plugins.py +12 -19
  24. rucio/common/policy.py +3 -2
  25. rucio/common/schema/__init__.py +11 -8
  26. rucio/common/types.py +7 -5
  27. rucio/common/utils.py +1 -1
  28. rucio/core/account.py +2 -1
  29. rucio/core/account_limit.py +3 -2
  30. rucio/core/authentication.py +1 -1
  31. rucio/core/credential.py +1 -1
  32. rucio/core/did.py +62 -61
  33. rucio/core/did_meta_plugins/__init__.py +10 -10
  34. rucio/core/did_meta_plugins/did_column_meta.py +9 -9
  35. rucio/core/did_meta_plugins/did_meta_plugin_interface.py +3 -3
  36. rucio/core/did_meta_plugins/elasticsearch_meta.py +7 -7
  37. rucio/core/did_meta_plugins/json_meta.py +2 -2
  38. rucio/core/did_meta_plugins/mongo_meta.py +9 -9
  39. rucio/core/did_meta_plugins/postgres_meta.py +7 -7
  40. rucio/core/dirac.py +3 -2
  41. rucio/core/distance.py +2 -1
  42. rucio/core/exporter.py +3 -2
  43. rucio/core/importer.py +5 -5
  44. rucio/core/lifetime_exception.py +2 -2
  45. rucio/core/lock.py +7 -7
  46. rucio/core/meta_conventions.py +2 -2
  47. rucio/core/monitor.py +1 -1
  48. rucio/core/naming_convention.py +1 -1
  49. rucio/core/nongrid_trace.py +2 -2
  50. rucio/core/oidc.py +2 -2
  51. rucio/core/permission/__init__.py +9 -6
  52. rucio/core/permission/generic.py +2 -2
  53. rucio/core/permission/generic_multi_vo.py +2 -2
  54. rucio/core/replica.py +22 -22
  55. rucio/core/request.py +2 -2
  56. rucio/core/rse.py +7 -7
  57. rucio/core/rule.py +38 -38
  58. rucio/core/rule_grouping.py +2 -3
  59. rucio/core/scope.py +1 -1
  60. rucio/core/trace.py +2 -2
  61. rucio/core/transfer.py +2 -2
  62. rucio/core/vo.py +2 -1
  63. rucio/daemons/atropos/atropos.py +2 -1
  64. rucio/daemons/auditor/__init__.py +1 -1
  65. rucio/daemons/automatix/automatix.py +5 -5
  66. rucio/daemons/badreplicas/minos.py +12 -5
  67. rucio/daemons/badreplicas/minos_temporary_expiration.py +5 -2
  68. rucio/daemons/badreplicas/necromancer.py +9 -3
  69. rucio/daemons/bb8/bb8.py +2 -1
  70. rucio/daemons/bb8/common.py +1 -1
  71. rucio/daemons/bb8/nuclei_background_rebalance.py +3 -3
  72. rucio/daemons/bb8/t2_background_rebalance.py +1 -1
  73. rucio/daemons/cache/consumer.py +1 -1
  74. rucio/daemons/conveyor/common.py +3 -3
  75. rucio/daemons/conveyor/finisher.py +13 -4
  76. rucio/daemons/conveyor/poller.py +5 -2
  77. rucio/daemons/conveyor/receiver.py +1 -1
  78. rucio/daemons/conveyor/submitter.py +2 -1
  79. rucio/daemons/follower/follower.py +1 -1
  80. rucio/daemons/hermes/hermes.py +29 -8
  81. rucio/daemons/judge/cleaner.py +2 -2
  82. rucio/daemons/judge/evaluator.py +7 -7
  83. rucio/daemons/judge/injector.py +2 -2
  84. rucio/daemons/judge/repairer.py +2 -2
  85. rucio/daemons/reaper/dark_reaper.py +5 -4
  86. rucio/daemons/reaper/reaper.py +7 -7
  87. rucio/daemons/replicarecoverer/suspicious_replica_recoverer.py +4 -4
  88. rucio/daemons/storage/consistency/actions.py +3 -3
  89. rucio/daemons/tracer/kronos.py +3 -2
  90. rucio/daemons/transmogrifier/transmogrifier.py +71 -69
  91. rucio/daemons/undertaker/undertaker.py +8 -7
  92. rucio/db/sqla/constants.py +4 -3
  93. rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py +1 -1
  94. rucio/db/sqla/migrate_repo/versions/4df2c5ddabc0_remove_temporary_dids.py +1 -1
  95. rucio/db/sqla/migrate_repo/versions/c129ccdb2d5_add_lumiblocknr_to_dids.py +1 -1
  96. rucio/db/sqla/models.py +3 -3
  97. rucio/db/sqla/session.py +7 -7
  98. rucio/db/sqla/util.py +3 -2
  99. rucio/gateway/account.py +77 -101
  100. rucio/gateway/account_limit.py +90 -116
  101. rucio/gateway/authentication.py +9 -8
  102. rucio/gateway/config.py +11 -10
  103. rucio/gateway/credential.py +2 -1
  104. rucio/gateway/did.py +58 -58
  105. rucio/gateway/dirac.py +3 -2
  106. rucio/gateway/exporter.py +2 -1
  107. rucio/gateway/heartbeat.py +3 -2
  108. rucio/gateway/identity.py +4 -3
  109. rucio/gateway/importer.py +2 -1
  110. rucio/gateway/lifetime_exception.py +5 -4
  111. rucio/gateway/lock.py +6 -5
  112. rucio/gateway/meta_conventions.py +3 -2
  113. rucio/gateway/permission.py +2 -1
  114. rucio/gateway/quarantined_replica.py +2 -1
  115. rucio/gateway/replica.py +20 -20
  116. rucio/gateway/request.py +10 -10
  117. rucio/gateway/rse.py +27 -26
  118. rucio/gateway/rule.py +12 -11
  119. rucio/gateway/scope.py +4 -3
  120. rucio/gateway/subscription.py +7 -6
  121. rucio/gateway/vo.py +5 -4
  122. rucio/rse/__init__.py +7 -6
  123. rucio/rse/protocols/ngarc.py +2 -2
  124. rucio/rse/protocols/srm.py +1 -1
  125. rucio/rse/protocols/webdav.py +8 -1
  126. rucio/rse/rsemanager.py +5 -4
  127. rucio/rse/translation.py +2 -2
  128. rucio/tests/common.py +6 -5
  129. rucio/vcsversion.py +3 -3
  130. rucio/web/rest/flaskapi/v1/accountlimits.py +5 -5
  131. rucio/web/rest/flaskapi/v1/accounts.py +20 -20
  132. rucio/web/rest/flaskapi/v1/archives.py +4 -3
  133. rucio/web/rest/flaskapi/v1/common.py +5 -4
  134. rucio/web/rest/flaskapi/v1/dids.py +382 -331
  135. rucio/web/rest/flaskapi/v1/lifetime_exceptions.py +5 -5
  136. rucio/web/rest/flaskapi/v1/locks.py +13 -13
  137. rucio/web/rest/flaskapi/v1/main.py +1 -0
  138. rucio/web/rest/flaskapi/v1/redirect.py +2 -2
  139. rucio/web/rest/flaskapi/v1/replicas.py +16 -16
  140. rucio/web/rest/flaskapi/v1/requests.py +16 -16
  141. rucio/web/rest/flaskapi/v1/subscriptions.py +7 -7
  142. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-abacus-account +8 -1
  143. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-abacus-rse +8 -1
  144. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-auditor +1 -1
  145. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-throttler +7 -1
  146. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-follower +1 -1
  147. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-judge-cleaner +9 -1
  148. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-necromancer +7 -1
  149. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-replica-recoverer +31 -9
  150. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-undertaker +8 -2
  151. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/METADATA +1 -1
  152. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/RECORD +202 -202
  153. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/alembic.ini.template +0 -0
  154. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/alembic_offline.ini.template +0 -0
  155. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/globus-config.yml.template +0 -0
  156. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/ldap.cfg.template +0 -0
  157. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
  158. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
  159. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
  160. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
  161. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
  162. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
  163. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
  164. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/rucio.cfg.atlas.client.template +0 -0
  165. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/rucio.cfg.template +0 -0
  166. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/etc/rucio_multi_vo.cfg.template +0 -0
  167. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/requirements.server.txt +0 -0
  168. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/tools/bootstrap.py +0 -0
  169. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
  170. {rucio-37.5.0.data → rucio-37.7.0.data}/data/rucio/tools/reset_database.py +0 -0
  171. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio +0 -0
  172. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-abacus-collection-replica +0 -0
  173. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-admin +0 -0
  174. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-atropos +0 -0
  175. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-automatix +0 -0
  176. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-bb8 +0 -0
  177. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-cache-client +0 -0
  178. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-cache-consumer +0 -0
  179. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-finisher +0 -0
  180. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-poller +0 -0
  181. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-preparer +0 -0
  182. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-receiver +0 -0
  183. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-stager +0 -0
  184. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-conveyor-submitter +0 -0
  185. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-dark-reaper +0 -0
  186. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-dumper +0 -0
  187. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-hermes +0 -0
  188. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-judge-evaluator +0 -0
  189. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-judge-injector +0 -0
  190. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-judge-repairer +0 -0
  191. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-kronos +0 -0
  192. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-minos +0 -0
  193. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-minos-temporary-expiration +0 -0
  194. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-oauth-manager +0 -0
  195. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-reaper +0 -0
  196. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-rse-decommissioner +0 -0
  197. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-storage-consistency-actions +0 -0
  198. {rucio-37.5.0.data → rucio-37.7.0.data}/scripts/rucio-transmogrifier +0 -0
  199. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/WHEEL +0 -0
  200. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/licenses/AUTHORS.rst +0 -0
  201. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/licenses/LICENSE +0 -0
  202. {rucio-37.5.0.dist-info → rucio-37.7.0.dist-info}/top_level.txt +0 -0
rucio/gateway/account.py CHANGED
@@ -17,32 +17,28 @@ from typing import TYPE_CHECKING, Any, Optional
17
17
  import rucio.common.exception
18
18
  import rucio.core.identity
19
19
  import rucio.gateway.permission
20
+ from rucio.common.constants import DEFAULT_VO
20
21
  from rucio.common.schema import validate_schema
21
22
  from rucio.common.types import InternalAccount
22
23
  from rucio.common.utils import gateway_update_return_dict
23
24
  from rucio.core import account as account_core
24
25
  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
26
+ from rucio.db.sqla.constants import AccountType, DatabaseOperationType
27
+ from rucio.db.sqla.session import db_session
27
28
 
28
29
  if TYPE_CHECKING:
29
30
  from collections.abc import Iterator
30
31
 
31
- from sqlalchemy.orm import Session
32
-
33
32
  from rucio.common.types import AccountAttributesDict, IdentityDict, UsageDict
34
33
  from rucio.db.sqla.models import Account
35
34
 
36
35
 
37
- @transactional_session
38
36
  def add_account(
39
37
  account: str,
40
38
  type_: str,
41
39
  email: str,
42
40
  issuer: str,
43
- vo: str = 'def',
44
- *,
45
- session: "Session"
41
+ vo: str = DEFAULT_VO,
46
42
  ) -> None:
47
43
  """
48
44
  Creates an account with the provided account name, contact information, etc.
@@ -53,29 +49,27 @@ def add_account(
53
49
 
54
50
  :param issuer: The issuer account_core.
55
51
  :param vo: The VO to act on.
56
- :param session: The database session in use.
57
52
 
58
53
  """
59
54
 
60
55
  validate_schema(name='account', obj=account, vo=vo)
61
56
 
62
57
  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
58
 
67
- internal_account = InternalAccount(account, vo=vo)
59
+ with db_session(DatabaseOperationType.WRITE) as session:
60
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_account', kwargs=kwargs, session=session)
61
+ if not auth_result.allowed:
62
+ raise rucio.common.exception.AccessDenied('Account %s can not add account. %s' % (issuer, auth_result.message))
63
+
64
+ internal_account = InternalAccount(account, vo=vo)
68
65
 
69
- account_core.add_account(internal_account, AccountType[type_.upper()], email, session=session)
66
+ account_core.add_account(internal_account, AccountType[type_.upper()], email, session=session)
70
67
 
71
68
 
72
- @transactional_session
73
69
  def del_account(
74
70
  account: str,
75
71
  issuer: str,
76
- vo: str = 'def',
77
- *,
78
- session: "Session"
72
+ vo: str = DEFAULT_VO,
79
73
  ) -> None:
80
74
  """
81
75
  Disables an account with the provided account name.
@@ -83,25 +77,22 @@ def del_account(
83
77
  :param account: The account name.
84
78
  :param issuer: The issuer account.
85
79
  :param vo: The VO to act on.
86
- :param session: The database session in use.
87
80
 
88
81
  """
89
82
  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))
83
+ with db_session(DatabaseOperationType.WRITE) as session:
84
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_account', kwargs=kwargs, session=session)
85
+ if not auth_result.allowed:
86
+ raise rucio.common.exception.AccessDenied('Account %s can not delete account. %s' % (issuer, auth_result.message))
93
87
 
94
- internal_account = InternalAccount(account, vo=vo)
88
+ internal_account = InternalAccount(account, vo=vo)
95
89
 
96
- account_core.del_account(internal_account, session=session)
90
+ account_core.del_account(internal_account, session=session)
97
91
 
98
92
 
99
- @read_session
100
93
  def get_account_info(
101
94
  account: str,
102
- vo: str = 'def',
103
- *,
104
- session: "Session"
95
+ vo: str = DEFAULT_VO,
105
96
  ) -> "Account":
106
97
  """
107
98
  Returns the info like the statistics information associated to an account_core.
@@ -109,25 +100,23 @@ def get_account_info(
109
100
  :param account: The account name.
110
101
  :returns: A list with all account information.
111
102
  :param vo: The VO to act on.
112
- :param session: The database session in use.
103
+
113
104
  """
114
105
 
115
106
  internal_account = InternalAccount(account, vo=vo)
116
107
 
117
- acc = account_core.get_account(internal_account, session=session)
118
- acc.account = acc.account.external
119
- return acc
108
+ with db_session(DatabaseOperationType.READ) as session:
109
+ acc = account_core.get_account(internal_account, session=session)
110
+ acc.account = acc.account.external
111
+ return acc
120
112
 
121
113
 
122
- @transactional_session
123
114
  def update_account(
124
115
  account: str,
125
116
  key: str,
126
117
  value: Any,
127
118
  issuer: str = 'root',
128
- vo: str = 'def',
129
- *,
130
- session: "Session"
119
+ vo: str = DEFAULT_VO,
131
120
  ) -> None:
132
121
  """ Update a property of an account_core.
133
122
 
@@ -136,21 +125,21 @@ def update_account(
136
125
  :param value: Property value.
137
126
  :param issuer: The issuer account
138
127
  :param vo: The VO to act on.
139
- :param session: The database session in use.
128
+
140
129
  """
141
130
  validate_schema(name='account', obj=account, vo=vo)
142
131
  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))
132
+ with db_session(DatabaseOperationType.WRITE) as session:
133
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='update_account', kwargs=kwargs, session=session)
134
+ if not auth_result.allowed:
135
+ raise rucio.common.exception.AccessDenied('Account %s can not change %s of the account. %s' % (issuer, key, auth_result.message))
146
136
 
147
- internal_account = InternalAccount(account, vo=vo)
137
+ internal_account = InternalAccount(account, vo=vo)
148
138
 
149
- return account_core.update_account(internal_account, key, value, session=session)
139
+ return account_core.update_account(internal_account, key, value, session=session)
150
140
 
151
141
 
152
- @stream_session
153
- def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *, session: "Session") -> 'Iterator[dict[str, Any]]':
142
+ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = DEFAULT_VO) -> 'Iterator[dict[str, Any]]':
154
143
  """
155
144
  Lists all the Rucio account names.
156
145
 
@@ -158,7 +147,6 @@ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *,
158
147
 
159
148
  :param filter_: Dictionary of attributes by which the input data should be filtered
160
149
  :param vo: The VO to act on.
161
- :param session: The database session in use.
162
150
 
163
151
  :returns: List of all accounts.
164
152
  """
@@ -169,80 +157,73 @@ def list_accounts(filter_: Optional[dict[str, Any]] = None, vo: str = 'def', *,
169
157
  filter_['account'] = InternalAccount(filter_['account'], vo=vo)
170
158
  else:
171
159
  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)
160
+
161
+ with db_session(DatabaseOperationType.READ) as session:
162
+ for result in account_core.list_accounts(filter_=filter_, session=session):
163
+ yield gateway_update_return_dict(result, session=session)
174
164
 
175
165
 
176
- @read_session
177
166
  def account_exists(
178
167
  account: str,
179
- vo: str = 'def',
180
- *,
181
- session: "Session"
168
+ vo: str = DEFAULT_VO,
182
169
  ) -> bool:
183
170
  """
184
171
  Checks to see if account exists. This procedure does not check it's status.
185
172
 
186
173
  :param account: Name of the account.
187
174
  :param vo: The VO to act on.
188
- :param session: The database session in use.
175
+
189
176
  :returns: True if found, otherwise false.
190
177
  """
191
178
 
192
179
  internal_account = InternalAccount(account, vo=vo)
193
180
 
194
- return account_core.account_exists(internal_account, session=session)
181
+ with db_session(DatabaseOperationType.READ) as session:
182
+ return account_core.account_exists(internal_account, session=session)
195
183
 
196
184
 
197
- @read_session
198
185
  def list_identities(
199
186
  account: str,
200
- vo: str = 'def',
201
- *,
202
- session: "Session"
187
+ vo: str = DEFAULT_VO,
203
188
  ) -> list["IdentityDict"]:
204
189
  """
205
190
  List all identities on an account_core.
206
191
 
207
192
  :param account: The account name.
208
193
  :param vo: The VO to act on.
209
- :param session: The database session in use.
194
+
210
195
  """
211
196
 
212
197
  internal_account = InternalAccount(account, vo=vo)
213
198
 
214
- return account_core.list_identities(internal_account, session=session)
199
+ with db_session(DatabaseOperationType.READ) as session:
200
+ return account_core.list_identities(internal_account, session=session)
215
201
 
216
202
 
217
- @read_session
218
203
  def list_account_attributes(
219
204
  account: str,
220
- vo: str = 'def',
221
- *,
222
- session: "Session"
205
+ vo: str = DEFAULT_VO,
223
206
  ) -> list["AccountAttributesDict"]:
224
207
  """
225
208
  Returns all the attributes for the given account.
226
209
 
227
210
  :param account: The account name.
228
211
  :param vo: The VO to act on
229
- :param session: The database session in use.
212
+
230
213
  """
231
214
 
232
215
  internal_account = InternalAccount(account, vo=vo)
233
216
 
234
- return account_core.list_account_attributes(internal_account, session=session)
217
+ with db_session(DatabaseOperationType.READ) as session:
218
+ return account_core.list_account_attributes(internal_account, session=session)
235
219
 
236
220
 
237
- @transactional_session
238
221
  def add_account_attribute(
239
222
  key: str,
240
223
  value: Any,
241
224
  account: str,
242
225
  issuer: str,
243
- vo: str = 'def',
244
- *,
245
- session: "Session"
226
+ vo: str = DEFAULT_VO,
246
227
  ) -> None:
247
228
  """
248
229
  Add an attribute to an account.
@@ -252,29 +233,27 @@ def add_account_attribute(
252
233
  :param account: The account name.
253
234
  :param issuer: The issuer account.
254
235
  :param vo: The VO to act on.
255
- :param session: The database session in use.
236
+
256
237
  """
257
238
  validate_schema(name='account_attribute', obj=key, vo=vo)
258
239
  validate_schema(name='account_attribute', obj=value, vo=vo)
259
240
 
260
241
  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))
242
+ with db_session(DatabaseOperationType.WRITE) as session:
243
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='add_attribute', kwargs=kwargs, session=session)
244
+ if not auth_result.allowed:
245
+ raise rucio.common.exception.AccessDenied('Account %s can not add attributes. %s' % (issuer, auth_result.message))
264
246
 
265
- internal_account = InternalAccount(account, vo=vo)
247
+ internal_account = InternalAccount(account, vo=vo)
266
248
 
267
- account_core.add_account_attribute(internal_account, key, value, session=session)
249
+ account_core.add_account_attribute(internal_account, key, value, session=session)
268
250
 
269
251
 
270
- @transactional_session
271
252
  def del_account_attribute(
272
253
  key: str,
273
254
  account: str,
274
255
  issuer: str,
275
- vo: str = 'def',
276
- *,
277
- session: "Session"
256
+ vo: str = DEFAULT_VO,
278
257
  ) -> None:
279
258
  """
280
259
  Delete an attribute to an account.
@@ -283,26 +262,24 @@ def del_account_attribute(
283
262
  :param account: The account name.
284
263
  :param issuer: The issuer account.
285
264
  :param vo: The VO to act on.
286
- :param session: The database session in use.
265
+
287
266
  """
288
267
  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))
268
+ with db_session(DatabaseOperationType.WRITE) as session:
269
+ auth_result = rucio.gateway.permission.has_permission(issuer=issuer, vo=vo, action='del_attribute', kwargs=kwargs, session=session)
270
+ if not auth_result.allowed:
271
+ raise rucio.common.exception.AccessDenied('Account %s can not delete attribute. %s' % (issuer, auth_result.message))
292
272
 
293
- internal_account = InternalAccount(account, vo=vo)
273
+ internal_account = InternalAccount(account, vo=vo)
294
274
 
295
- account_core.del_account_attribute(internal_account, key, session=session)
275
+ account_core.del_account_attribute(internal_account, key, session=session)
296
276
 
297
277
 
298
- @read_session
299
278
  def get_usage(
300
279
  rse: str,
301
280
  account: str,
302
281
  issuer: str,
303
- vo: str = 'def',
304
- *,
305
- session: "Session"
282
+ vo: str = DEFAULT_VO,
306
283
  ) -> "UsageDict":
307
284
  """
308
285
  Returns current values of the specified counter, or raises CounterNotFound if the counter does not exist.
@@ -311,23 +288,21 @@ def get_usage(
311
288
  :param account: The account name.
312
289
  :param issuer: The issuer account.
313
290
  :param vo: The VO to act on.
314
- :param session: The database session in use.
291
+
315
292
  :returns: A dictionary with total and bytes.
316
293
  """
317
- rse_id = get_rse_id(rse=rse, vo=vo, session=session)
318
- internal_account = InternalAccount(account, vo=vo)
294
+ with db_session(DatabaseOperationType.READ) as session:
295
+ rse_id = get_rse_id(rse=rse, vo=vo, session=session)
296
+ internal_account = InternalAccount(account, vo=vo)
319
297
 
320
- return account_core.get_usage(rse_id, internal_account, session=session)
298
+ return account_core.get_usage(rse_id, internal_account, session=session)
321
299
 
322
300
 
323
- @read_session
324
301
  def get_usage_history(
325
302
  rse: str,
326
303
  account: str,
327
304
  issuer: str,
328
- vo: str = 'def',
329
- *,
330
- session: "Session"
305
+ vo: str = DEFAULT_VO,
331
306
  ) -> list["UsageDict"]:
332
307
  """
333
308
  Returns historical values of the specified counter, or raises CounterNotFound if the counter does not exist.
@@ -336,10 +311,11 @@ def get_usage_history(
336
311
  :param account: The account name.
337
312
  :param issuer: The issuer account.
338
313
  :param vo: The VO to act on.
339
- :param session: The database session in use.
314
+
340
315
  :returns: A dictionary with total and bytes.
341
316
  """
342
- rse_id = get_rse_id(rse=rse, vo=vo, session=session)
343
- internal_account = InternalAccount(account, vo=vo)
317
+ with db_session(DatabaseOperationType.READ) as session:
318
+ rse_id = get_rse_id(rse=rse, vo=vo, session=session)
319
+ internal_account = InternalAccount(account, vo=vo)
344
320
 
345
- return account_core.get_usage_history(rse_id, internal_account, session=session)
321
+ return account_core.get_usage_history(rse_id, internal_account, session=session)