Skip to content

Commit 1529eb0

Browse files
committed
feat: removed Catalogs from list of managed RSS resources
1 parent e4f27f3 commit 1529eb0

File tree

2 files changed

+9
-95
lines changed

2 files changed

+9
-95
lines changed

src/DIRAC/ResourceStatusSystem/Client/ResourceStatus.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" ResourceStatus
1+
"""ResourceStatus
22
33
Module that acts as a helper for knowing the status of a resource.
44
It takes care of switching between the CS and the RSS.
@@ -46,7 +46,7 @@ def getElementStatus(self, elementName, elementType, statusType=None, default=No
4646
4747
:param elementName: name of the element or list of element names
4848
:type elementName: str, list
49-
:param elementType: type of the element (StorageElement, ComputingElement, FTS, Catalog)
49+
:param elementType: type of the element (StorageElement, ComputingElement, FTS)
5050
:type elementType: str
5151
:param statusType: type of the status (meaningful only when elementType==StorageElement)
5252
:type statusType: None, str, list
@@ -65,8 +65,6 @@ def getElementStatus(self, elementName, elementType, statusType=None, default=No
6565
S_ERROR( xyz.. )
6666
>>> getElementStatus('ThisIsAWrongName', 'StorageElement', 'WriteAccess')
6767
S_ERROR( xyz.. )
68-
>>> getElementStatus('A_file_catalog', 'FileCatalog')
69-
S_OK( { 'A_file_catalog': { 'all': 'Active' } } } )
7068
>>> getElementStatus('SE1', 'StorageElement', ['ReadAccess', 'WriteAccess'])
7169
S_OK( { 'SE1': { 'ReadAccess': 'Banned' , 'WriteAccess': 'Active'} } } )
7270
>>> getElementStatus('SE1', 'StorageElement')
@@ -79,7 +77,7 @@ def getElementStatus(self, elementName, elementType, statusType=None, default=No
7977
'CE2': {'all': 'Probing'}}}
8078
"""
8179

82-
allowedParameters = ["StorageElement", "ComputingElement", "FTS", "Catalog"]
80+
allowedParameters = ["StorageElement", "ComputingElement", "FTS"]
8381

8482
if elementType not in allowedParameters:
8583
return S_ERROR(f"{elementType} in not in the list of the allowed parameters: {allowedParameters}")
@@ -92,8 +90,6 @@ def getElementStatus(self, elementName, elementType, statusType=None, default=No
9290
statusType = ["all"]
9391
elif elementType == "FTS":
9492
statusType = ["all"]
95-
elif elementType == "Catalog":
96-
statusType = ["all"]
9793

9894
return self.__getRSSElementStatus(elementName, elementType, statusType, vO)
9995

@@ -102,7 +98,7 @@ def setElementStatus(self, elementName, elementType, statusType, status, reason=
10298
10399
:param elementName: name of the element
104100
:type elementName: str
105-
:param elementType: type of the element (StorageElement, ComputingElement, FTS, Catalog)
101+
:param elementType: type of the element (StorageElement, ComputingElement, FTS)
106102
:type elementType: str
107103
:param statusType: type of the status (meaningful only when elementType==StorageElement)
108104
:type statusType: str
@@ -159,7 +155,7 @@ def __getRSSElementStatus(self, elementName, elementType, statusType, vO):
159155
160156
:param elementName: name of the element or list of element names
161157
:type elementName: str, list
162-
:param elementType: type of the element (StorageElement, ComputingElement, FTS, Catalog)
158+
:param elementType: type of the element (StorageElement, ComputingElement, FTS)
163159
:type elementType: str
164160
:param statusType: type of the status (meaningful only when elementType==StorageElement,
165161
otherwise it is 'all' or ['all'])
@@ -178,7 +174,7 @@ def __getCSElementStatus(self, elementName, elementType, statusType, default):
178174
179175
:param elementName: name of the element
180176
:type elementName: str
181-
:param elementType: type of the element (StorageElement, ComputingElement, FTS, Catalog)
177+
:param elementType: type of the element (StorageElement, ComputingElement, FTS)
182178
:type elementType: str
183179
:param statusType: type of the status (meaningful only when elementType==StorageElement)
184180
:type statusType: str, list
@@ -190,12 +186,9 @@ def __getCSElementStatus(self, elementName, elementType, statusType, default):
190186
if elementType in ("ComputingElement", "FTS"):
191187
return S_OK({elementName: {"all": "Active"}})
192188

193-
# If we are here it is because elementType is either 'StorageElement' or 'Catalog'
189+
# If we are here it is because elementType is 'StorageElement'
194190
if elementType == "StorageElement":
195191
cs_path = "/Resources/StorageElements"
196-
elif elementType == "Catalog":
197-
cs_path = "/Resources/FileCatalogs"
198-
statusType = ["Status"]
199192

200193
if not isinstance(elementName, list):
201194
elementName = [elementName]
@@ -263,19 +256,14 @@ def __setCSElementStatus(self, elementName, elementType, statusType, status):
263256
if elementType in ("ComputingElement", "FTS"):
264257
return S_OK()
265258

266-
# If we are here it is because elementType is either 'StorageElement' or 'Catalog'
259+
# If we are here it is because elementType is 'StorageElement'
267260
statuses = self.rssConfig.getConfigStatusType(elementType)
268261
if statusType not in statuses:
269262
gLogger.error(f"{statusType} is not a valid statusType")
270263
return S_ERROR(f"{statusType} is not a valid statusType: {statuses}")
271264

272265
if elementType == "StorageElement":
273266
cs_path = "/Resources/StorageElements"
274-
elif elementType == "Catalog":
275-
cs_path = "/Resources/FileCatalogs"
276-
# FIXME: This a probably outdated location (new one is in /Operations/[]/Services/Catalogs)
277-
# but needs to be VO-aware
278-
statusType = "Status"
279267

280268
csAPI = CSAPI()
281269
csAPI.setOption(f"{cs_path}/{elementName}/{elementType}/{statusType}", status)

src/DIRAC/ResourceStatusSystem/Utilities/Synchronizer.py

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _syncSites(self):
136136
def _syncResources(self):
137137
"""
138138
Sync resources: compares CS with DB and does the necessary modifications.
139-
( StorageElements, FTS, FileCatalogs and ComputingElements )
139+
(StorageElements, FTS and ComputingElements)
140140
"""
141141

142142
gLogger.info("-- Synchronizing Resources --")
@@ -151,11 +151,6 @@ def _syncResources(self):
151151
if not fts["OK"]:
152152
gLogger.error(fts["Message"])
153153

154-
gLogger.verbose("-> FileCatalogs")
155-
fileCatalogs = self.__syncFileCatalogs()
156-
if not fileCatalogs["OK"]:
157-
gLogger.error(fileCatalogs["Message"])
158-
159154
gLogger.verbose("-> ComputingElements")
160155
computingElements = self.__syncComputingElements()
161156
if not computingElements["OK"]:
@@ -278,75 +273,6 @@ def __syncComputingElements(self):
278273

279274
return S_OK()
280275

281-
def __syncFileCatalogs(self):
282-
"""
283-
Sync FileCatalogs: compares CS with DB and does the necessary modifications.
284-
"""
285-
286-
catalogsCS = CSHelpers.getFileCatalogs()
287-
if not catalogsCS["OK"]:
288-
return catalogsCS
289-
catalogsCS = catalogsCS["Value"]
290-
291-
gLogger.verbose(f"{len(catalogsCS)} File catalogs found in CS")
292-
293-
catalogsDB = self.rStatus.selectStatusElement(
294-
"Resource", "Status", elementType="Catalog", meta={"columns": ["Name"]}
295-
)
296-
if not catalogsDB["OK"]:
297-
return catalogsDB
298-
catalogsDB = [catalogDB[0] for catalogDB in catalogsDB["Value"]]
299-
300-
# StorageElements that are in DB but not in CS
301-
toBeDeleted = list(set(catalogsDB).difference(set(catalogsCS)))
302-
gLogger.verbose(f"{len(toBeDeleted)} File catalogs to be deleted")
303-
304-
# Delete storage elements
305-
for catalogName in toBeDeleted:
306-
deleteQuery = self.rStatus._extermineStatusElement("Resource", catalogName)
307-
308-
gLogger.verbose(f"... {catalogName}")
309-
if not deleteQuery["OK"]:
310-
return deleteQuery
311-
312-
# statusTypes = RssConfiguration.getValidStatusTypes()[ 'Resource' ]
313-
statusTypes = self.rssConfig.getConfigStatusType("Catalog")
314-
315-
result = self.rStatus.selectStatusElement(
316-
"Resource", "Status", elementType="Catalog", meta={"columns": ["Name", "StatusType"]}
317-
)
318-
if not result["OK"]:
319-
return result
320-
sesTuple = [(x[0], x[1]) for x in result["Value"]]
321-
322-
# For each ( se, statusType ) tuple not present in the DB, add it.
323-
catalogsStatusTuples = [(se, statusType) for se in catalogsCS for statusType in statusTypes]
324-
toBeAdded = list(set(catalogsStatusTuples).difference(set(sesTuple)))
325-
326-
gLogger.verbose(f"{len(toBeAdded)} File catalogs entries to be added")
327-
328-
for catalogTuple in toBeAdded:
329-
_name = catalogTuple[0]
330-
_statusType = catalogTuple[1]
331-
_status = self.defaultStatus
332-
_reason = "Synchronized"
333-
_elementType = "Catalog"
334-
335-
query = self.rStatus.addIfNotThereStatusElement(
336-
"Resource",
337-
"Status",
338-
name=_name,
339-
statusType=_statusType,
340-
status=_status,
341-
elementType=_elementType,
342-
tokenOwner=self.tokenOwner,
343-
reason=_reason,
344-
)
345-
if not query["OK"]:
346-
return query
347-
348-
return S_OK()
349-
350276
def __syncFTS(self):
351277
"""
352278
Sync FTS: compares CS with DB and does the necessary modifications.

0 commit comments

Comments
 (0)