rucio 37.2.0__py3-none-any.whl → 37.3.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 (95) hide show
  1. rucio/common/plugins.py +1 -1
  2. rucio/core/did.py +2 -3
  3. rucio/core/replica.py +1 -1
  4. rucio/db/sqla/util.py +1 -1
  5. rucio/gateway/authentication.py +58 -88
  6. rucio/gateway/config.py +63 -75
  7. rucio/gateway/did.py +245 -329
  8. rucio/gateway/dirac.py +33 -34
  9. rucio/gateway/exporter.py +27 -30
  10. rucio/gateway/importer.py +12 -14
  11. rucio/gateway/lifetime_exception.py +16 -24
  12. rucio/gateway/lock.py +27 -40
  13. rucio/gateway/replica.py +223 -226
  14. rucio/gateway/rse.py +191 -218
  15. rucio/gateway/rule.py +115 -146
  16. rucio/gateway/scope.py +18 -25
  17. rucio/gateway/trace.py +48 -0
  18. rucio/vcsversion.py +3 -3
  19. rucio/web/rest/flaskapi/v1/accounts.py +2 -2
  20. rucio/web/rest/flaskapi/v1/auth.py +15 -0
  21. rucio/web/rest/flaskapi/v1/common.py +3 -0
  22. rucio/web/rest/flaskapi/v1/config.py +7 -7
  23. rucio/web/rest/flaskapi/v1/dids.py +55 -55
  24. rucio/web/rest/flaskapi/v1/dirac.py +2 -2
  25. rucio/web/rest/flaskapi/v1/export.py +1 -1
  26. rucio/web/rest/flaskapi/v1/import.py +1 -1
  27. rucio/web/rest/flaskapi/v1/lifetime_exceptions.py +5 -5
  28. rucio/web/rest/flaskapi/v1/locks.py +4 -4
  29. rucio/web/rest/flaskapi/v1/main.py +17 -10
  30. rucio/web/rest/flaskapi/v1/replicas.py +29 -28
  31. rucio/web/rest/flaskapi/v1/rses.py +37 -37
  32. rucio/web/rest/flaskapi/v1/rules.py +15 -15
  33. rucio/web/rest/flaskapi/v1/scopes.py +3 -3
  34. rucio/web/rest/flaskapi/v1/traces.py +75 -77
  35. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/METADATA +1 -1
  36. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/RECORD +95 -94
  37. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/WHEEL +1 -1
  38. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/alembic.ini.template +0 -0
  39. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/alembic_offline.ini.template +0 -0
  40. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/globus-config.yml.template +0 -0
  41. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/ldap.cfg.template +0 -0
  42. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_approval_request.tmpl +0 -0
  43. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_approved_admin.tmpl +0 -0
  44. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_approved_user.tmpl +0 -0
  45. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_denied_admin.tmpl +0 -0
  46. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_denied_user.tmpl +0 -0
  47. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/mail_templates/rule_ok_notification.tmpl +0 -0
  48. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/rse-accounts.cfg.template +0 -0
  49. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/rucio.cfg.atlas.client.template +0 -0
  50. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/rucio.cfg.template +0 -0
  51. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/etc/rucio_multi_vo.cfg.template +0 -0
  52. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/requirements.server.txt +0 -0
  53. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/tools/bootstrap.py +0 -0
  54. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/tools/merge_rucio_configs.py +0 -0
  55. {rucio-37.2.0.data → rucio-37.3.0.data}/data/rucio/tools/reset_database.py +0 -0
  56. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio +0 -0
  57. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-abacus-account +0 -0
  58. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-abacus-collection-replica +0 -0
  59. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-abacus-rse +0 -0
  60. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-admin +0 -0
  61. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-atropos +0 -0
  62. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-auditor +0 -0
  63. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-automatix +0 -0
  64. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-bb8 +0 -0
  65. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-cache-client +0 -0
  66. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-cache-consumer +0 -0
  67. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-finisher +0 -0
  68. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-poller +0 -0
  69. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-preparer +0 -0
  70. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-receiver +0 -0
  71. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-stager +0 -0
  72. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-submitter +0 -0
  73. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-conveyor-throttler +0 -0
  74. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-dark-reaper +0 -0
  75. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-dumper +0 -0
  76. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-follower +0 -0
  77. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-hermes +0 -0
  78. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-judge-cleaner +0 -0
  79. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-judge-evaluator +0 -0
  80. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-judge-injector +0 -0
  81. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-judge-repairer +0 -0
  82. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-kronos +0 -0
  83. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-minos +0 -0
  84. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-minos-temporary-expiration +0 -0
  85. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-necromancer +0 -0
  86. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-oauth-manager +0 -0
  87. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-reaper +0 -0
  88. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-replica-recoverer +0 -0
  89. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-rse-decommissioner +0 -0
  90. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-storage-consistency-actions +0 -0
  91. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-transmogrifier +0 -0
  92. {rucio-37.2.0.data → rucio-37.3.0.data}/scripts/rucio-undertaker +0 -0
  93. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/licenses/AUTHORS.rst +0 -0
  94. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/licenses/LICENSE +0 -0
  95. {rucio-37.2.0.dist-info → rucio-37.3.0.dist-info}/top_level.txt +0 -0
rucio/gateway/rse.py CHANGED
@@ -20,16 +20,14 @@ from rucio.common.utils import gateway_update_return_dict
20
20
  from rucio.core import distance as distance_module
21
21
  from rucio.core import rse as rse_module
22
22
  from rucio.core.rse_expression_parser import parse_expression
23
- from rucio.db.sqla.session import read_session, stream_session, transactional_session
23
+ from rucio.db.sqla.constants import DatabaseOperationType
24
+ from rucio.db.sqla.session import db_session
24
25
  from rucio.gateway import permission
25
26
 
26
27
  if TYPE_CHECKING:
27
28
  from typing import Optional
28
29
 
29
- from sqlalchemy.orm import Session
30
30
 
31
-
32
- @transactional_session
33
31
  def add_rse(
34
32
  rse,
35
33
  issuer,
@@ -49,7 +47,7 @@ def add_rse(
49
47
  ASN=None, # noqa: N803
50
48
  availability_read: "Optional[bool]" = None,
51
49
  availability_write: "Optional[bool]" = None,
52
- availability_delete: "Optional[bool]" = None, *, session: "Session"
50
+ availability_delete: "Optional[bool]" = None,
53
51
  ):
54
52
  """
55
53
  Creates a new Rucio Storage Element(RSE).
@@ -73,67 +71,64 @@ def add_rse(
73
71
  :param availability_read: If the RSE is readable.
74
72
  :param availability_write: If the RSE is writable.
75
73
  :param availability_delete: If the RSE is deletable.
76
- :param session: The database session in use.
77
74
  """
78
75
  validate_schema(name='rse', obj=rse, vo=vo)
79
76
  kwargs = {'rse': rse}
80
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_rse', kwargs=kwargs, session=session)
81
- if not auth_result.allowed:
82
- raise exception.AccessDenied('Account %s can not add RSE. %s' % (issuer, auth_result.message))
77
+ with db_session(DatabaseOperationType.WRITE) as session:
78
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_rse', kwargs=kwargs, session=session)
79
+ if not auth_result.allowed:
80
+ raise exception.AccessDenied('Account %s can not add RSE. %s' % (issuer, auth_result.message))
83
81
 
84
- return rse_module.add_rse(rse, vo=vo, deterministic=deterministic, volatile=volatile, city=city,
85
- region_code=region_code, country_name=country_name, staging_area=staging_area,
86
- continent=continent, time_zone=time_zone, ISP=ISP, rse_type=rse_type, latitude=latitude,
87
- longitude=longitude, ASN=ASN, availability_read=availability_read,
88
- availability_write=availability_write, availability_delete=availability_delete, session=session)
82
+ return rse_module.add_rse(rse, vo=vo, deterministic=deterministic, volatile=volatile, city=city,
83
+ region_code=region_code, country_name=country_name, staging_area=staging_area,
84
+ continent=continent, time_zone=time_zone, ISP=ISP, rse_type=rse_type, latitude=latitude,
85
+ longitude=longitude, ASN=ASN, availability_read=availability_read,
86
+ availability_write=availability_write, availability_delete=availability_delete, session=session)
89
87
 
90
88
 
91
- @read_session
92
- def get_rse(rse, vo='def', *, session: "Session"):
89
+ def get_rse(rse, vo='def'):
93
90
  """
94
91
  Provides details about the specified RSE.
95
92
 
96
93
  :param rse: The RSE name.
97
94
  :param vo: The VO to act on.
98
- :param session: The database session in use.
99
95
 
100
96
  :returns: a dict with details about the RSE
101
97
 
102
98
  :raises RSENotFound: if the referred RSE was not found in the database
103
99
  """
104
100
 
105
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
106
- return rse_module.get_rse_protocols(rse_id=rse_id, session=session)
101
+ with db_session(DatabaseOperationType.READ) as session:
102
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
103
+ return rse_module.get_rse_protocols(rse_id=rse_id, session=session)
107
104
 
108
105
 
109
- @transactional_session
110
- def del_rse(rse, issuer, vo='def', *, session: "Session"):
106
+ def del_rse(rse, issuer, vo='def'):
111
107
  """
112
108
  Disables an RSE with the provided RSE name.
113
109
 
114
110
  :param rse: The RSE name.
115
111
  :param issuer: The issuer account.
116
112
  :param vo: The VO to act on.
117
- :param session: The database session in use.
118
113
  """
119
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
120
114
 
121
- kwargs = {'rse': rse, 'rse_id': rse_id}
122
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_rse', kwargs=kwargs, session=session)
123
- if not auth_result.allowed:
124
- raise exception.AccessDenied('Account %s can not delete RSE. %s' % (issuer, auth_result.message))
115
+ with db_session(DatabaseOperationType.WRITE) as session:
116
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
117
+
118
+ kwargs = {'rse': rse, 'rse_id': rse_id}
119
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_rse', kwargs=kwargs, session=session)
120
+ if not auth_result.allowed:
121
+ raise exception.AccessDenied('Account %s can not delete RSE. %s' % (issuer, auth_result.message))
125
122
 
126
- return rse_module.del_rse(rse_id, session=session)
123
+ return rse_module.del_rse(rse_id, session=session)
127
124
 
128
125
 
129
- @read_session
130
- def list_rses(filters: "Optional[dict[str, Any]]" = None, vo: str = 'def', *, session: "Session") -> list[dict[str, Any]]:
126
+ def list_rses(filters: "Optional[dict[str, Any]]" = None, vo: str = 'def') -> list[dict[str, Any]]:
131
127
  """
132
128
  Lists all RSEs.
133
129
 
134
130
  :param filters: dictionary of attributes by which the results should be filtered.
135
131
  :param vo: The VO to act on.
136
- :param session: The database session in use.
137
132
 
138
133
  :returns: List of all RSEs.
139
134
  """
@@ -141,34 +136,33 @@ def list_rses(filters: "Optional[dict[str, Any]]" = None, vo: str = 'def', *, se
141
136
 
142
137
  filters['vo'] = vo
143
138
 
144
- return rse_module.list_rses(filters=filters, session=session)
139
+ with db_session(DatabaseOperationType.READ) as session:
140
+ return rse_module.list_rses(filters=filters, session=session)
145
141
 
146
142
 
147
- @transactional_session
148
- def del_rse_attribute(rse, key, issuer, vo='def', *, session: "Session"):
143
+ def del_rse_attribute(rse, key, issuer, vo='def'):
149
144
  """
150
145
  Delete a RSE attribute.
151
146
 
152
147
  :param rse: the name of the rse_module.
153
148
  :param key: the attribute key.
154
149
  :param vo: The VO to act on.
155
- :param session: The database session in use.
156
150
 
157
151
  :return: True if RSE attribute was deleted successfully, False otherwise.
158
152
  """
159
153
 
160
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
154
+ with db_session(DatabaseOperationType.WRITE) as session:
155
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
161
156
 
162
- kwargs = {'rse': rse, 'rse_id': rse_id, 'key': key}
163
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_rse_attribute', kwargs=kwargs, session=session)
164
- if not auth_result.allowed:
165
- raise exception.AccessDenied('Account %s can not delete RSE attributes. %s' % (issuer, auth_result.message))
157
+ kwargs = {'rse': rse, 'rse_id': rse_id, 'key': key}
158
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_rse_attribute', kwargs=kwargs, session=session)
159
+ if not auth_result.allowed:
160
+ raise exception.AccessDenied('Account %s can not delete RSE attributes. %s' % (issuer, auth_result.message))
166
161
 
167
- return rse_module.del_rse_attribute(rse_id=rse_id, key=key, session=session)
162
+ return rse_module.del_rse_attribute(rse_id=rse_id, key=key, session=session)
168
163
 
169
164
 
170
- @transactional_session
171
- def add_rse_attribute(rse, key, value, issuer, vo='def', *, session: "Session"):
165
+ def add_rse_attribute(rse, key, value, issuer, vo='def'):
172
166
  """ Adds a RSE attribute.
173
167
 
174
168
  :param rse: the rse name.
@@ -176,65 +170,61 @@ def add_rse_attribute(rse, key, value, issuer, vo='def', *, session: "Session"):
176
170
  :param value: the value name.
177
171
  :param issuer: The issuer account.
178
172
  :param vo: The VO to act on.
179
- :param session: The database session in use.
180
173
 
181
174
  returns: True if successful, False otherwise.
182
175
  """
183
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
176
+ with db_session(DatabaseOperationType.WRITE) as session:
177
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
184
178
 
185
- kwargs = {'rse': rse, 'rse_id': rse_id, 'key': key, 'value': value}
186
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_rse_attribute', kwargs=kwargs, session=session)
187
- if not auth_result.allowed:
188
- raise exception.AccessDenied('Account %s can not add RSE attributes. %s' % (issuer, auth_result.message))
179
+ kwargs = {'rse': rse, 'rse_id': rse_id, 'key': key, 'value': value}
180
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_rse_attribute', kwargs=kwargs, session=session)
181
+ if not auth_result.allowed:
182
+ raise exception.AccessDenied('Account %s can not add RSE attributes. %s' % (issuer, auth_result.message))
189
183
 
190
- return rse_module.add_rse_attribute(rse_id=rse_id, key=key, value=value, session=session)
184
+ return rse_module.add_rse_attribute(rse_id=rse_id, key=key, value=value, session=session)
191
185
 
192
186
 
193
- @read_session
194
- def list_rse_attributes(rse, vo='def', *, session: "Session"):
187
+ def list_rse_attributes(rse, vo='def'):
195
188
  """
196
189
  List RSE attributes for a RSE_MODULE.
197
190
 
198
191
  :param rse: The RSE name.
199
192
  :param vo: The VO to act on.
200
- :param session: The database session in use.
201
193
 
202
194
  :returns: List of all RSE attributes for a RSE_MODULE.
203
195
  """
204
196
 
205
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
206
- return rse_module.list_rse_attributes(rse_id=rse_id, session=session)
197
+ with db_session(DatabaseOperationType.READ) as session:
198
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
199
+ return rse_module.list_rse_attributes(rse_id=rse_id, session=session)
207
200
 
208
201
 
209
- @read_session
210
- def has_rse_attribute(rse_id, key, *, session: "Session"):
202
+ def has_rse_attribute(rse_id, key):
211
203
  """
212
204
  Indicates whether the named key is present for the RSE.
213
205
 
214
206
  :param rse_id: The RSE id.
215
207
  :param key: The key for the attribute.
216
- :param session: The database session in use.
217
208
 
218
209
  :returns: True or False
219
210
  """
220
- return rse_module.has_rse_attribute(rse_id=rse_id, key=key, session=session)
211
+ with db_session(DatabaseOperationType.READ) as session:
212
+ return rse_module.has_rse_attribute(rse_id=rse_id, key=key, session=session)
221
213
 
222
214
 
223
- @read_session
224
- def get_rses_with_attribute(key, *, session: "Session"):
215
+ def get_rses_with_attribute(key):
225
216
  """
226
217
  Return all RSEs with a certain attribute.
227
218
 
228
219
  :param key: The key for the attribute.
229
- :param session: The database session in use.
230
220
 
231
221
  :returns: List of rse dictionaries
232
222
  """
233
- return rse_module.get_rses_with_attribute(key=key, session=session)
223
+ with db_session(DatabaseOperationType.READ) as session:
224
+ return rse_module.get_rses_with_attribute(key=key, session=session)
234
225
 
235
226
 
236
- @transactional_session
237
- def add_protocol(rse, issuer, vo='def', *, session: "Session", **data):
227
+ def add_protocol(rse, issuer, vo='def', **data):
238
228
  """
239
229
  Creates a new protocol entry for an existing RSE.
240
230
 
@@ -242,35 +232,33 @@ def add_protocol(rse, issuer, vo='def', *, session: "Session", **data):
242
232
  :param issuer: The issuer account.
243
233
  :param vo: The VO to act on.
244
234
  :param data: Parameters (protocol identifier, port, hostname, ...) provided by the request.
245
- :param session: The database session in use.
246
235
  """
247
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
236
+ with db_session(DatabaseOperationType.WRITE) as session:
237
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
248
238
 
249
- kwargs = {'rse': rse, 'rse_id': rse_id}
250
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_protocol', kwargs=kwargs, session=session)
251
- if not auth_result.allowed:
252
- raise exception.AccessDenied('Account %s can not add protocols to RSE %s. %s' % (issuer, rse, auth_result.message))
253
- rse_module.add_protocol(rse_id, data['data'], session=session)
239
+ kwargs = {'rse': rse, 'rse_id': rse_id}
240
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_protocol', kwargs=kwargs, session=session)
241
+ if not auth_result.allowed:
242
+ raise exception.AccessDenied('Account %s can not add protocols to RSE %s. %s' % (issuer, rse, auth_result.message))
243
+ rse_module.add_protocol(rse_id, data['data'], session=session)
254
244
 
255
245
 
256
- @read_session
257
- def get_rse_protocols(rse, issuer, vo='def', *, session: "Session"):
246
+ def get_rse_protocols(rse, issuer, vo='def'):
258
247
  """
259
248
  Returns all matching protocols (including detailed information) for the given RSE.
260
249
 
261
250
  :param rse: The RSE name.
262
251
  :param issuer: The issuer account.
263
252
  :param vo: The VO to act on.
264
- :param session: The database session in use.
265
253
 
266
254
  :returns: A dict with all supported protocols and their attributes.
267
255
  """
268
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
269
- return rse_module.get_rse_protocols(rse_id, session=session)
256
+ with db_session(DatabaseOperationType.READ) as session:
257
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
258
+ return rse_module.get_rse_protocols(rse_id, session=session)
270
259
 
271
260
 
272
- @transactional_session
273
- def del_protocols(rse, scheme, issuer, vo='def', hostname=None, port=None, *, session: "Session"):
261
+ def del_protocols(rse, scheme, issuer, vo='def', hostname=None, port=None):
274
262
  """
275
263
  Deletes all matching protocol entries for the given RSE..
276
264
 
@@ -282,18 +270,17 @@ def del_protocols(rse, scheme, issuer, vo='def', hostname=None, port=None, *, se
282
270
  same identifier are present)
283
271
  :param port: The port (to be used if more than one protocol using the same
284
272
  identifier and hostname are present)
285
- :param session: The database session in use.
286
273
  """
287
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
288
- kwargs = {'rse': rse, 'rse_id': rse_id}
289
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_protocol', kwargs=kwargs, session=session)
290
- if not auth_result.allowed:
291
- raise exception.AccessDenied('Account %s can not delete protocols from RSE %s. %s' % (issuer, rse, auth_result.message))
292
- rse_module.del_protocols(rse_id=rse_id, scheme=scheme, hostname=hostname, port=port, session=session)
274
+ with db_session(DatabaseOperationType.WRITE) as session:
275
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
276
+ kwargs = {'rse': rse, 'rse_id': rse_id}
277
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='del_protocol', kwargs=kwargs, session=session)
278
+ if not auth_result.allowed:
279
+ raise exception.AccessDenied('Account %s can not delete protocols from RSE %s. %s' % (issuer, rse, auth_result.message))
280
+ rse_module.del_protocols(rse_id=rse_id, scheme=scheme, hostname=hostname, port=port, session=session)
293
281
 
294
282
 
295
- @transactional_session
296
- def update_protocols(rse, scheme, data, issuer, vo='def', hostname=None, port=None, *, session: "Session"):
283
+ def update_protocols(rse, scheme, data, issuer, vo='def', hostname=None, port=None):
297
284
  """
298
285
  Updates all provided attributes for all matching protocol entries of the given RSE..
299
286
 
@@ -304,18 +291,17 @@ def update_protocols(rse, scheme, data, issuer, vo='def', hostname=None, port=No
304
291
  :param data: A dict including the attributes of the protocol to be updated. Keys must match the column names in the database.
305
292
  :param hostname: The hostname (to be used if more then one protocol using the same identifier are present)
306
293
  :param port: The port (to be used if more than one protocol using the same identifier and hostname are present)
307
- :param session: The database session in use.
308
294
  """
309
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
310
- kwargs = {'rse': rse, 'rse_id': rse_id}
311
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_protocol', kwargs=kwargs, session=session)
312
- if not auth_result.allowed:
313
- raise exception.AccessDenied('Account %s can not update protocols from RSE %s. %s' % (issuer, rse, auth_result.message))
314
- rse_module.update_protocols(rse_id=rse_id, scheme=scheme, hostname=hostname, port=port, data=data, session=session)
295
+ with db_session(DatabaseOperationType.WRITE) as session:
296
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
297
+ kwargs = {'rse': rse, 'rse_id': rse_id}
298
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_protocol', kwargs=kwargs, session=session)
299
+ if not auth_result.allowed:
300
+ raise exception.AccessDenied('Account %s can not update protocols from RSE %s. %s' % (issuer, rse, auth_result.message))
301
+ rse_module.update_protocols(rse_id=rse_id, scheme=scheme, hostname=hostname, port=port, data=data, session=session)
315
302
 
316
303
 
317
- @transactional_session
318
- def set_rse_usage(rse, source, used, free, issuer, files=None, vo='def', *, session: "Session"):
304
+ def set_rse_usage(rse, source, used, free, issuer, files=None, vo='def'):
319
305
  """
320
306
  Set RSE usage information.
321
307
 
@@ -326,22 +312,21 @@ def set_rse_usage(rse, source, used, free, issuer, files=None, vo='def', *, sess
326
312
  :param issuer: The issuer account.
327
313
  :param files: the number of files
328
314
  :param vo: The VO to act on.
329
- :param session: The database session in use.
330
315
 
331
316
  :returns: True if successful, otherwise false.
332
317
  """
333
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
318
+ with db_session(DatabaseOperationType.WRITE) as session:
319
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
334
320
 
335
- kwargs = {'rse': rse, 'rse_id': rse_id}
336
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='set_rse_usage', kwargs=kwargs, session=session)
337
- if not auth_result.allowed:
338
- raise exception.AccessDenied('Account %s can not update RSE usage information for RSE %s. %s' % (issuer, rse, auth_result.message))
321
+ kwargs = {'rse': rse, 'rse_id': rse_id}
322
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='set_rse_usage', kwargs=kwargs, session=session)
323
+ if not auth_result.allowed:
324
+ raise exception.AccessDenied('Account %s can not update RSE usage information for RSE %s. %s' % (issuer, rse, auth_result.message))
339
325
 
340
- return rse_module.set_rse_usage(rse_id=rse_id, source=source, used=used, free=free, files=files, session=session)
326
+ return rse_module.set_rse_usage(rse_id=rse_id, source=source, used=used, free=free, files=files, session=session)
341
327
 
342
328
 
343
- @read_session
344
- def get_rse_usage(rse, issuer, source=None, per_account=False, vo='def', *, session: "Session"):
329
+ def get_rse_usage(rse, issuer, source=None, per_account=False, vo='def'):
345
330
  """
346
331
  get RSE usage information.
347
332
 
@@ -349,23 +334,22 @@ def get_rse_usage(rse, issuer, source=None, per_account=False, vo='def', *, sess
349
334
  :param issuer: The issuer account.
350
335
  :param source: dictionary of attributes by which the results should be filtered
351
336
  :param vo: The VO to act on.
352
- :param session: The database session in use.
353
337
 
354
338
  :returns: List of RSE usage data.
355
339
  """
356
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
357
- usages = rse_module.get_rse_usage(rse_id=rse_id, source=source, per_account=per_account, session=session)
340
+ with db_session(DatabaseOperationType.READ) as session:
341
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
342
+ usages = rse_module.get_rse_usage(rse_id=rse_id, source=source, per_account=per_account, session=session)
358
343
 
359
- for u in usages:
360
- u['rse'] = rse
361
- if 'account_usages' in u:
362
- for account_usage in u['account_usages']:
363
- account_usage['account'] = account_usage['account'].external
364
- return [gateway_update_return_dict(u, session=session) for u in usages]
344
+ for u in usages:
345
+ u['rse'] = rse
346
+ if 'account_usages' in u:
347
+ for account_usage in u['account_usages']:
348
+ account_usage['account'] = account_usage['account'].external
349
+ return [gateway_update_return_dict(u, session=session) for u in usages]
365
350
 
366
351
 
367
- @stream_session
368
- def list_rse_usage_history(rse, issuer, source=None, vo='def', *, session: "Session"):
352
+ def list_rse_usage_history(rse, issuer, source=None, vo='def'):
369
353
  """
370
354
  List RSE usage history information.
371
355
 
@@ -373,17 +357,16 @@ def list_rse_usage_history(rse, issuer, source=None, vo='def', *, session: "Sess
373
357
  :param issuer: The issuer account.
374
358
  :param source: The source of the usage information (srm, rucio).
375
359
  :param vo: The VO to act on.
376
- :param session: The database session in use.
377
360
 
378
361
  :returns: A list of historic RSE usage.
379
362
  """
380
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
381
- for u in rse_module.list_rse_usage_history(rse_id=rse_id, source=source, session=session):
382
- yield gateway_update_return_dict(u, session=session)
363
+ with db_session(DatabaseOperationType.READ) as session:
364
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
365
+ for u in rse_module.list_rse_usage_history(rse_id=rse_id, source=source, session=session):
366
+ yield gateway_update_return_dict(u, session=session)
383
367
 
384
368
 
385
- @transactional_session
386
- def set_rse_limits(rse, name, value, issuer, vo='def', *, session: "Session"):
369
+ def set_rse_limits(rse, name, value, issuer, vo='def'):
387
370
  """
388
371
  Set RSE limits.
389
372
 
@@ -392,21 +375,20 @@ def set_rse_limits(rse, name, value, issuer, vo='def', *, session: "Session"):
392
375
  :param value: The feature value.
393
376
  :param issuer: The issuer account.
394
377
  :param vo: The VO to act on.
395
- :param session: The database session in use.
396
378
 
397
379
  :returns: True if successful, otherwise false.
398
380
  """
399
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
400
- kwargs = {'rse': rse, 'rse_id': rse_id}
401
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='set_rse_limits', kwargs=kwargs, session=session)
402
- if not auth_result.allowed:
403
- raise exception.AccessDenied('Account %s can not update RSE limits for RSE %s. %s' % (issuer, rse, auth_result.message))
381
+ with db_session(DatabaseOperationType.WRITE) as session:
382
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
383
+ kwargs = {'rse': rse, 'rse_id': rse_id}
384
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='set_rse_limits', kwargs=kwargs, session=session)
385
+ if not auth_result.allowed:
386
+ raise exception.AccessDenied('Account %s can not update RSE limits for RSE %s. %s' % (issuer, rse, auth_result.message))
404
387
 
405
- return rse_module.set_rse_limits(rse_id=rse_id, name=name, value=value, session=session)
388
+ return rse_module.set_rse_limits(rse_id=rse_id, name=name, value=value, session=session)
406
389
 
407
390
 
408
- @transactional_session
409
- def delete_rse_limits(rse, name, issuer, vo='def', *, session: "Session"):
391
+ def delete_rse_limits(rse, name, issuer, vo='def'):
410
392
  """
411
393
  Set RSE limits.
412
394
 
@@ -414,53 +396,50 @@ def delete_rse_limits(rse, name, issuer, vo='def', *, session: "Session"):
414
396
  :param name: The name of the limit.
415
397
  :param issuer: The issuer account.
416
398
  :param vo: The VO to act on.
417
- :param session: The database session in use.
418
399
 
419
400
  :returns: True if successful, otherwise false.
420
401
  """
421
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
422
- kwargs = {'rse': rse, 'rse_id': rse_id}
423
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='delete_rse_limits', kwargs=kwargs, session=session)
424
- if not auth_result.allowed:
425
- raise exception.AccessDenied('Account %s can not update RSE limits for RSE %s. %s' % (issuer, rse, auth_result.message))
402
+ with db_session(DatabaseOperationType.WRITE) as session:
403
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
404
+ kwargs = {'rse': rse, 'rse_id': rse_id}
405
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='delete_rse_limits', kwargs=kwargs, session=session)
406
+ if not auth_result.allowed:
407
+ raise exception.AccessDenied('Account %s can not update RSE limits for RSE %s. %s' % (issuer, rse, auth_result.message))
426
408
 
427
- return rse_module.delete_rse_limits(rse_id=rse_id, name=name, session=session)
409
+ return rse_module.delete_rse_limits(rse_id=rse_id, name=name, session=session)
428
410
 
429
411
 
430
- @read_session
431
- def get_rse_limits(rse, issuer, vo='def', *, session: "Session"):
412
+ def get_rse_limits(rse, issuer, vo='def'):
432
413
  """
433
414
  Get RSE limits.
434
415
 
435
416
  :param rse: The RSE name.
436
417
  :param issuer: The issuer account.
437
418
  :param vo: The VO to act on.
438
- :param session: The database session in use.
439
419
 
440
420
  :returns: True if successful, otherwise false.
441
421
  """
442
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
443
- return rse_module.get_rse_limits(rse_id=rse_id, session=session)
422
+ with db_session(DatabaseOperationType.READ) as session:
423
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
424
+ return rse_module.get_rse_limits(rse_id=rse_id, session=session)
444
425
 
445
426
 
446
- @transactional_session
447
- def parse_rse_expression(rse_expression, vo='def', *, session: "Session"):
427
+ def parse_rse_expression(rse_expression, vo='def'):
448
428
  """
449
429
  Parse an RSE expression and return the list of RSEs.
450
430
 
451
431
  :param rse_expression: The RSE expression.
452
432
  :param vo: The VO to act on.
453
- :param session: The database session in use.
454
433
 
455
434
  :returns: List of RSEs
456
435
  :raises: InvalidRSEExpression
457
436
  """
458
- rses = parse_expression(rse_expression, filter_={'vo': vo}, session=session)
437
+ with db_session(DatabaseOperationType.WRITE) as session:
438
+ rses = parse_expression(rse_expression, filter_={'vo': vo}, session=session)
459
439
  return [rse['rse'] for rse in rses]
460
440
 
461
441
 
462
- @transactional_session
463
- def update_rse(rse, parameters, issuer, vo='def', *, session: "Session"):
442
+ def update_rse(rse, parameters, issuer, vo='def'):
464
443
  """
465
444
  Update RSE properties like availability or name.
466
445
 
@@ -468,20 +447,19 @@ def update_rse(rse, parameters, issuer, vo='def', *, session: "Session"):
468
447
  :param parameters: A dictionary with property (name, read, write, delete as keys).
469
448
  :param issuer: The issuer account.
470
449
  :param vo: The VO to act on.
471
- :param session: The database session in use.
472
450
 
473
451
  :raises RSENotFound: If RSE is not found.
474
452
  """
475
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
476
- kwargs = {'rse': rse, 'rse_id': rse_id}
477
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_rse', kwargs=kwargs, session=session)
478
- if not auth_result.allowed:
479
- raise exception.AccessDenied('Account %s can not update RSE. %s' % (issuer, auth_result.message))
480
- return rse_module.update_rse(rse_id=rse_id, parameters=parameters, session=session)
453
+ with db_session(DatabaseOperationType.WRITE) as session:
454
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
455
+ kwargs = {'rse': rse, 'rse_id': rse_id}
456
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_rse', kwargs=kwargs, session=session)
457
+ if not auth_result.allowed:
458
+ raise exception.AccessDenied('Account %s can not update RSE. %s' % (issuer, auth_result.message))
459
+ return rse_module.update_rse(rse_id=rse_id, parameters=parameters, session=session)
481
460
 
482
461
 
483
- @transactional_session
484
- def add_distance(source, destination, issuer, vo='def', distance=None, *, session: "Session"):
462
+ def add_distance(source, destination, issuer, vo='def', distance=None):
485
463
  """
486
464
  Add a src-dest distance.
487
465
 
@@ -490,23 +468,22 @@ def add_distance(source, destination, issuer, vo='def', distance=None, *, sessio
490
468
  :param issuer: The issuer account.
491
469
  :param vo: The VO to act on.
492
470
  :param distance: Distance as an integer.
493
- :param session: The database session in use.
494
471
  """
495
472
  kwargs = {'source': source, 'destination': destination}
496
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_distance', kwargs=kwargs, session=session)
497
- if not auth_result.allowed:
498
- raise exception.AccessDenied('Account %s can not add RSE distances. %s' % (issuer, auth_result.message))
499
- try:
500
- return distance_module.add_distance(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
501
- dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
502
- distance=distance, session=session)
503
- except exception.Duplicate:
504
- # use source and destination RSE names
505
- raise exception.Duplicate('Distance from %s to %s already exists!' % (source, destination))
473
+ with db_session(DatabaseOperationType.WRITE) as session:
474
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='add_distance', kwargs=kwargs, session=session)
475
+ if not auth_result.allowed:
476
+ raise exception.AccessDenied('Account %s can not add RSE distances. %s' % (issuer, auth_result.message))
477
+ try:
478
+ return distance_module.add_distance(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
479
+ dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
480
+ distance=distance, session=session)
481
+ except exception.Duplicate:
482
+ # use source and destination RSE names
483
+ raise exception.Duplicate('Distance from %s to %s already exists!' % (source, destination))
506
484
 
507
485
 
508
- @transactional_session
509
- def update_distance(source, destination, distance, issuer, vo='def', *, session: "Session"):
486
+ def update_distance(source, destination, distance, issuer, vo='def'):
510
487
  """
511
488
  Update distances with the given RSE ids.
512
489
 
@@ -515,20 +492,19 @@ def update_distance(source, destination, distance, issuer, vo='def', *, session:
515
492
  :param distance: The new distance to set
516
493
  :param issuer: The issuer account.
517
494
  :param vo: The VO to act on.
518
- :param session: The database session to use.
519
495
  """
520
496
  kwargs = {'source': source, 'destination': destination}
521
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_distance', kwargs=kwargs, session=session)
522
- if not auth_result.allowed:
523
- raise exception.AccessDenied('Account %s can not update RSE distances. %s' % (issuer, auth_result.message))
497
+ with db_session(DatabaseOperationType.WRITE) as session:
498
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='update_distance', kwargs=kwargs, session=session)
499
+ if not auth_result.allowed:
500
+ raise exception.AccessDenied('Account %s can not update RSE distances. %s' % (issuer, auth_result.message))
524
501
 
525
- return distance_module.update_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
526
- dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
527
- distance=distance, session=session)
502
+ return distance_module.update_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
503
+ dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
504
+ distance=distance, session=session)
528
505
 
529
506
 
530
- @read_session
531
- def get_distance(source, destination, issuer, vo='def', *, session: "Session"):
507
+ def get_distance(source, destination, issuer, vo='def'):
532
508
  """
533
509
  Get distances between rses.
534
510
 
@@ -536,19 +512,18 @@ def get_distance(source, destination, issuer, vo='def', *, session: "Session"):
536
512
  :param destination: The destination RSE.
537
513
  :param issuer: The issuer account.
538
514
  :param vo: The VO to act on.
539
- :param session: The database session in use.
540
515
 
541
516
  :returns distance: List of dictionaries.
542
517
  """
543
- distances = distance_module.get_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
544
- dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
545
- session=session)
518
+ with db_session(DatabaseOperationType.READ) as session:
519
+ distances = distance_module.get_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
520
+ dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
521
+ session=session)
546
522
 
547
- return [gateway_update_return_dict(d, session=session) for d in distances]
523
+ return [gateway_update_return_dict(d, session=session) for d in distances]
548
524
 
549
525
 
550
- @transactional_session
551
- def delete_distance(source, destination, issuer, vo='def', *, session: "Session"):
526
+ def delete_distance(source, destination, issuer, vo='def'):
552
527
  """
553
528
  Delete distances with the given RSE ids.
554
529
 
@@ -556,20 +531,20 @@ def delete_distance(source, destination, issuer, vo='def', *, session: "Session"
556
531
  :param destination: The destination RSE.
557
532
  :param issuer: The issuer account.
558
533
  :param vo: The VO to act on.
559
- :param session: The database session in use.
560
534
  """
561
535
  kwargs = {'source': source, 'destination': destination}
562
- auth_result = permission.has_permission(issuer=issuer, vo=vo, action='delete_distance', kwargs=kwargs, session=session)
563
- if not auth_result.allowed:
564
- raise exception.AccessDenied('Account %s can not update RSE distances. %s' % (issuer, auth_result.message))
565
536
 
566
- return distance_module.delete_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
567
- dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
568
- session=session)
537
+ with db_session(DatabaseOperationType.WRITE) as session:
538
+ auth_result = permission.has_permission(issuer=issuer, vo=vo, action='delete_distance', kwargs=kwargs, session=session)
539
+ if not auth_result.allowed:
540
+ raise exception.AccessDenied('Account %s can not update RSE distances. %s' % (issuer, auth_result.message))
541
+
542
+ return distance_module.delete_distances(src_rse_id=rse_module.get_rse_id(source, vo=vo, session=session),
543
+ dest_rse_id=rse_module.get_rse_id(destination, vo=vo, session=session),
544
+ session=session)
569
545
 
570
546
 
571
- @transactional_session
572
- def add_qos_policy(rse, qos_policy, issuer, vo='def', *, session: "Session"):
547
+ def add_qos_policy(rse, qos_policy, issuer, vo='def'):
573
548
  """
574
549
  Add a QoS policy from an RSE.
575
550
 
@@ -577,23 +552,22 @@ def add_qos_policy(rse, qos_policy, issuer, vo='def', *, session: "Session"):
577
552
  :param qos_policy: The QoS policy to add.
578
553
  :param issuer: The issuer account.
579
554
  :param vo: The VO to act on.
580
- :param session: The database session in use.
581
555
 
582
556
  :raises Duplicate: If the QoS policy already exists.
583
557
  :returns: True if successful, except otherwise.
584
558
  """
585
559
 
586
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
587
- kwargs = {'rse_id': rse_id}
588
- auth_result = permission.has_permission(issuer=issuer, action='add_qos_policy', kwargs=kwargs, session=session)
589
- if not auth_result.allowed:
590
- raise exception.AccessDenied('Account %s cannot add QoS policies to RSE %s. %s' % (issuer, rse, auth_result.message))
560
+ with db_session(DatabaseOperationType.WRITE) as session:
561
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
562
+ kwargs = {'rse_id': rse_id}
563
+ auth_result = permission.has_permission(issuer=issuer, action='add_qos_policy', kwargs=kwargs, session=session)
564
+ if not auth_result.allowed:
565
+ raise exception.AccessDenied('Account %s cannot add QoS policies to RSE %s. %s' % (issuer, rse, auth_result.message))
591
566
 
592
- return rse_module.add_qos_policy(rse_id, qos_policy, session=session)
567
+ return rse_module.add_qos_policy(rse_id, qos_policy, session=session)
593
568
 
594
569
 
595
- @transactional_session
596
- def delete_qos_policy(rse, qos_policy, issuer, vo='def', *, session: "Session"):
570
+ def delete_qos_policy(rse, qos_policy, issuer, vo='def'):
597
571
  """
598
572
  Delete a QoS policy from an RSE.
599
573
 
@@ -601,32 +575,31 @@ def delete_qos_policy(rse, qos_policy, issuer, vo='def', *, session: "Session"):
601
575
  :param qos_policy: The QoS policy to delete.
602
576
  :param issuer: The issuer account.
603
577
  :param vo: The VO to act on.
604
- :param session: The database session in use.
605
578
 
606
579
  :returns: True if successful, silent failure if QoS policy does not exist.
607
580
  """
608
581
 
609
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
610
- kwargs = {'rse_id': rse}
611
- auth_result = permission.has_permission(issuer=issuer, action='delete_qos_policy', kwargs=kwargs, session=session)
612
- if not auth_result.allowed:
613
- raise exception.AccessDenied('Account %s cannot delete QoS policies from RSE %s. %s' % (issuer, rse, auth_result.message))
582
+ with db_session(DatabaseOperationType.WRITE) as session:
583
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
584
+ kwargs = {'rse_id': rse}
585
+ auth_result = permission.has_permission(issuer=issuer, action='delete_qos_policy', kwargs=kwargs, session=session)
586
+ if not auth_result.allowed:
587
+ raise exception.AccessDenied('Account %s cannot delete QoS policies from RSE %s. %s' % (issuer, rse, auth_result.message))
614
588
 
615
- return rse_module.delete_qos_policy(rse_id, qos_policy, session=session)
589
+ return rse_module.delete_qos_policy(rse_id, qos_policy, session=session)
616
590
 
617
591
 
618
- @read_session
619
- def list_qos_policies(rse, issuer, vo='def', *, session: "Session"):
592
+ def list_qos_policies(rse, issuer, vo='def'):
620
593
  """
621
594
  List all QoS policies of an RSE.
622
595
 
623
596
  :param rse: The id of the RSE.
624
597
  :param issuer: The issuer account.
625
598
  :param vo: The VO to act on.
626
- :param session: The database session in use.
627
599
 
628
600
  :returns: List containing all QoS policies.
629
601
  """
630
602
 
631
- rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
632
- return rse_module.list_qos_policies(rse_id, session=session)
603
+ with db_session(DatabaseOperationType.READ) as session:
604
+ rse_id = rse_module.get_rse_id(rse=rse, vo=vo, session=session)
605
+ return rse_module.list_qos_policies(rse_id, session=session)