Skip to content

Commit 14d0d47

Browse files
committed
change: use defaults for StatusTypes
1 parent 51e77bf commit 14d0d47

File tree

10 files changed

+13
-111
lines changed

10 files changed

+13
-111
lines changed

docs/source/AdministratorGuide/Systems/ResourceStatus/configuration.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ preferably on Defaults subsection. ::
1212
State = Active
1313
Cache = 720
1414
FromAddress = email@address
15-
/StatusTypes
16-
default = all
17-
StorageElement = ReadAccess,WriteAccess,CheckAccess,RemoveAccess
1815

1916
.. _config section :
2017

@@ -27,4 +24,3 @@ This section is all you need to get the RSS working. The parameters are the foll
2724
:State: < Active || InActive ( default if not specified ) > is the flag used on the ResourceStatus helper to switch between CS and RSS. If Active, RSS is used.
2825
:Cache: < <int> || 300 ( default if not specified ) > [ seconds ] sets the lifetime for the cached information on RSSCache.
2926
:FromAddress: < <string> || ( default dirac mail address ) > email used t osend the emails from ( sometimes a valid email address is needed ).
30-
:StatusTypes: if a ElementType has more than one StatusType ( aka StorageElement ), we have to specify them here, Otherwise, "all" is taken as StatusType.

docs/source/AdministratorGuide/Systems/ResourceStatus/install.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ Please, make sure you have the following schema::
2121
/Operations/Defaults/ResourceStatus
2222
/Config
2323
Cache = 300
24-
/StatusTypes
25-
default = all
26-
StorageElement = ReadAccess,WriteAccess,CheckAccess,RemoveAccess
2724

2825
For a more detailed explanation, take a look to the official documentation:
2926
:ref:`rss-configuration`.

docs/source/DeveloperGuide/Systems/ResourceStatus/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,6 @@ Policies
544544
Actions
545545
``/Operations/Defaults/ResourceStatus/PolicyActions``
546546

547-
Status Types
548-
``/Operations/Defaults/ResourceStatus/Config/StatusTypes``
549-
550547
Services
551548
``/Systems/ResourceStatus/Services/``
552549

src/DIRAC/ResourceStatusSystem/Utilities/RSSCacheNoThread.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Cache
1+
"""Cache
22
33
This module provides a generic Cache extended to be used on RSS, RSSCache.
44
This cache features a lazy update method. It will only be updated if it is
@@ -7,6 +7,7 @@
77
After that, the cache is empty.
88
99
"""
10+
1011
import itertools
1112
import random
1213

@@ -215,7 +216,7 @@ def __init__(self, lifeTime, updateFunc):
215216

216217
super().__init__(lifeTime, updateFunc)
217218

218-
self.allStatusTypes = RssConfiguration().getConfigStatusType()
219+
self.allStatusTypes = ["All"]
219220

220221
def match(self, elementNames, elementType, statusTypes, vO):
221222
"""

src/DIRAC/ResourceStatusSystem/Utilities/RssConfiguration.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from DIRAC import S_OK
9-
from DIRAC.Core.Utilities import List
109
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1110
from DIRAC.ResourceStatusSystem.PolicySystem.StateMachine import RSSMachine
1211
from DIRAC.ResourceStatusSystem.Utilities import Utils
@@ -51,25 +50,6 @@ def getConfigFromAddress(self, default=None):
5150

5251
return self.opsHelper.getValue(f"{_rssConfigPath}/Config/FromAddress", default)
5352

54-
def getConfigStatusType(self, elementType=None):
55-
"""
56-
Gets all the status types per elementType, if not given, it takes default
57-
from CS. If not, hardcoded variable DEFAULT.
58-
"""
59-
60-
_DEFAULTS = ("all",)
61-
62-
res = self.opsHelper.getOptionsDict(f"{_rssConfigPath}/Config/StatusTypes")
63-
64-
if res["OK"]:
65-
if elementType in res["Value"]:
66-
return List.fromChar(res["Value"][elementType])
67-
68-
if "default" in res["Value"]:
69-
return List.fromChar(res["Value"]["default"])
70-
71-
return _DEFAULTS
72-
7353

7454
def getPolicies():
7555
"""

src/DIRAC/ResourceStatusSystem/Utilities/Synchronizer.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ def __syncComputingElements(self):
235235
if not deleteQuery["OK"]:
236236
return deleteQuery
237237

238-
# statusTypes = RssConfiguration.getValidStatusTypes()[ 'Resource' ]
239-
statusTypes = self.rssConfig.getConfigStatusType("ComputingElement")
240-
241238
result = self.rStatus.selectStatusElement(
242239
"Resource", "Status", elementType="ComputingElement", meta={"columns": ["Name", "StatusType"]}
243240
)
@@ -246,7 +243,7 @@ def __syncComputingElements(self):
246243
cesTuple = [(x[0], x[1]) for x in result["Value"]]
247244

248245
# For each ( se, statusType ) tuple not present in the DB, add it.
249-
cesStatusTuples = [(se, statusType) for se in cesCS for statusType in statusTypes]
246+
cesStatusTuples = [(se, "All") for se in cesCS]
250247
toBeAdded = list(set(cesStatusTuples).difference(set(cesTuple)))
251248

252249
gLogger.debug(f"{len(toBeAdded)} Computing elements entries to be added")
@@ -302,9 +299,6 @@ def __syncFTS(self):
302299
if not deleteQuery["OK"]:
303300
return deleteQuery
304301

305-
statusTypes = self.rssConfig.getConfigStatusType("FTS")
306-
# statusTypes = RssConfiguration.getValidStatusTypes()[ 'Resource' ]
307-
308302
result = self.rStatus.selectStatusElement(
309303
"Resource", "Status", elementType="FTS", meta={"columns": ["Name", "StatusType"]}
310304
)
@@ -313,7 +307,7 @@ def __syncFTS(self):
313307
sesTuple = [(x[0], x[1]) for x in result["Value"]]
314308

315309
# For each ( se, statusType ) tuple not present in the DB, add it.
316-
ftsStatusTuples = [(se, statusType) for se in ftsCS for statusType in statusTypes]
310+
ftsStatusTuples = [(se, "All") for se in ftsCS]
317311
toBeAdded = list(set(ftsStatusTuples).difference(set(sesTuple)))
318312

319313
gLogger.verbose(f"{len(toBeAdded)} FTS endpoints entries to be added")
@@ -368,9 +362,6 @@ def __syncStorageElements(self):
368362
if not deleteQuery["OK"]:
369363
return deleteQuery
370364

371-
statusTypes = self.rssConfig.getConfigStatusType("StorageElement")
372-
# statusTypes = RssConfiguration.getValidStatusTypes()[ 'Resource' ]
373-
374365
result = self.rStatus.selectStatusElement(
375366
"Resource", "Status", elementType="StorageElement", meta={"columns": ["Name", "StatusType"]}
376367
)
@@ -379,7 +370,11 @@ def __syncStorageElements(self):
379370
sesTuple = [(x[0], x[1]) for x in result["Value"]]
380371

381372
# For each ( se, statusType ) tuple not present in the DB, add it.
382-
sesStatusTuples = [(se, statusType) for se in sesCS for statusType in statusTypes]
373+
sesStatusTuples = [
374+
(se, statusType)
375+
for se in sesCS
376+
for statusType in ["ReadAccess", "WriteAccess", "CheckAccess", "RemoveAccess"]
377+
]
383378
toBeAdded = list(set(sesStatusTuples).difference(set(sesTuple)))
384379

385380
gLogger.verbose(f"{len(toBeAdded)} storage element entries to be added")

src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_query_db.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from DIRAC import S_OK
1010
from DIRAC import exit as DIRACExit
1111
from DIRAC import gLogger
12-
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1312
from DIRAC.Core.Base.Script import Script
1413
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1514
from DIRAC.Core.Utilities import TimeUtilities
@@ -126,29 +125,6 @@ def getToken(key):
126125
return expirationDate
127126

128127

129-
def checkStatusTypes(statusTypes):
130-
"""
131-
To check if values for 'statusType' are valid
132-
"""
133-
134-
opsH = Operations().getValue(
135-
"ResourceStatus/Config/StatusTypes/StorageElement", "ReadAccess,WriteAccess,CheckAccess,RemoveAccess"
136-
)
137-
acceptableStatusTypes = opsH.replace(",", "").split()
138-
139-
for statusType in statusTypes:
140-
if statusType not in acceptableStatusTypes and statusType != "all":
141-
acceptableStatusTypes.append("all")
142-
error(
143-
"'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
144-
% (statusType, str(acceptableStatusTypes))
145-
)
146-
147-
if "all" in statusType:
148-
return acceptableStatusTypes
149-
return statusTypes
150-
151-
152128
def unpack(switchDict):
153129
"""
154130
To split and process comma-separated list of values for 'name' and 'statusType'
@@ -163,7 +139,6 @@ def unpack(switchDict):
163139

164140
if switchDict["statusType"] is not None:
165141
statusTypes = list(filter(None, switchDict["statusType"].split(",")))
166-
statusTypes = checkStatusTypes(statusTypes)
167142

168143
if names and statusTypes:
169144
combinations = [(a, b) for a in names for b in statusTypes]

src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_set_status.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from DIRAC import S_OK, gLogger
1111
from DIRAC import exit as DIRACExit
12-
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1312
from DIRAC.Core.Base.Script import Script
1413
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1514
from DIRAC.ResourceStatusSystem.Client import ResourceStatusClient
@@ -78,27 +77,6 @@ def parseSwitches():
7877
return switches
7978

8079

81-
def checkStatusTypes(statusTypes):
82-
"""
83-
To check if values for 'statusType' are valid
84-
"""
85-
86-
opsH = Operations().getValue("ResourceStatus/Config/StatusTypes/StorageElement")
87-
acceptableStatusTypes = opsH.replace(",", "").split()
88-
89-
for statusType in statusTypes:
90-
if statusType not in acceptableStatusTypes and statusType != "all":
91-
acceptableStatusTypes.append("all")
92-
gLogger.error(
93-
"'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
94-
% (statusType, str(acceptableStatusTypes))
95-
)
96-
97-
if "all" in statusType:
98-
return acceptableStatusTypes
99-
return statusTypes
100-
101-
10280
def unpack(switchDict):
10381
"""
10482
To split and process comma-separated list of values for 'name' and 'statusType'
@@ -113,7 +91,6 @@ def unpack(switchDict):
11391

11492
if switchDict["statusType"] is not None:
11593
statusTypes = list(filter(None, switchDict["statusType"].split(",")))
116-
statusTypes = checkStatusTypes(statusTypes)
11794

11895
if len(names) > 0 and len(statusTypes) > 0:
11996
combinations = [(a, b) for a in names for b in statusTypes]

src/DIRAC/ResourceStatusSystem/scripts/dirac_rss_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def initSEs():
124124
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import DMSHelpers
125125
from DIRAC.ResourceStatusSystem.Client import ResourceStatusClient
126126
from DIRAC.ResourceStatusSystem.PolicySystem import StateMachine
127-
from DIRAC.ResourceStatusSystem.Utilities import CSHelpers, RssConfiguration
127+
from DIRAC.ResourceStatusSystem.Utilities import CSHelpers
128128

129129
# WarmUp local copy
130130
CSHelpers.warmUp()
@@ -134,7 +134,7 @@ def initSEs():
134134
rssClient = ResourceStatusClient.ResourceStatusClient()
135135

136136
statuses = StateMachine.RSSMachine(None).getStates()
137-
statusTypes = RssConfiguration.RssConfiguration().getConfigStatusType("StorageElement")
137+
statusTypes = ["ReadAccess", "WriteAccess", "RemoveAccess", "CheckAccess"]
138138
reason = "dirac-rss-sync"
139139

140140
gLogger.debug(statuses)

tests/Jenkins/dirac-cfg-update-server.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
"""update local cfg"""
3+
34
import os
45
import sys
56

@@ -304,14 +305,6 @@
304305
# State = Active
305306
# FromAddress = [email protected]
306307
# notificationGroups = ShiftersGroup
307-
# StatusTypes
308-
# {
309-
# default = all
310-
# StorageElement = ReadAccess
311-
# StorageElement += WriteAccess
312-
# StorageElement += CheckAccess
313-
# StorageElement += RemoveAccess
314-
# }
315308
# }
316309
# Policies
317310
# {
@@ -361,15 +354,6 @@
361354
csAPI.setOption("Operations/Defaults/ResourceStatus/Config/Cache", "600")
362355
csAPI.setOption("Operations/Defaults/ResourceStatus/Config/FromAddress", "[email protected]")
363356
csAPI.setOption("Operations/Defaults/ResourceStatus/Config/notificationGroups", "ShiftersGroup")
364-
res = csAPI.createSection("Operations/Defaults/ResourceStatus/Config/StatusTypes")
365-
if not res["OK"]:
366-
print(res["Message"])
367-
sys.exit(1)
368-
csAPI.setOption("Operations/Defaults/ResourceStatus/Config/StatusTypes/default", "all")
369-
csAPI.setOption(
370-
"Operations/Defaults/ResourceStatus/Config/StatusTypes/StorageElement",
371-
"ReadAccess,WriteAccess,CheckAccess,RemoveAccess",
372-
)
373357

374358
res = csAPI.createSection("Operations/Defaults/ResourceStatus/Policies")
375359
if not res["OK"]:

0 commit comments

Comments
 (0)