1010from datetime import datetime , timedelta
1111from time import sleep
1212
13- from DIRAC import S_ERROR , S_OK , gConfig , gLogger
14- from DIRAC .ConfigurationSystem .Client .CSAPI import CSAPI
15- from DIRAC .Core .Utilities import DErrno
13+ from DIRAC import S_ERROR , S_OK , gLogger
1614from DIRAC .Core .Utilities .DIRACSingleton import DIRACSingleton
1715from DIRAC .ResourceStatusSystem .Client .ResourceStatusClient import ResourceStatusClient
1816from DIRAC .ResourceStatusSystem .Utilities .InfoGetter import getPoliciesThatApply
@@ -36,13 +34,12 @@ def __init__(self):
3634
3735 cacheLifeTime = int (self .rssConfig .getConfigCache ())
3836
39- # RSSCache only affects the calls directed to RSS, if using the CS it is not used.
37+ # RSSCache only affects the calls directed to RSS
4038 self .rssCache = RSSCache (cacheLifeTime , self .__updateRssCache )
4139
4240 def getElementStatus (self , elementName , elementType , statusType = None , default = None , vO = None ):
4341 """
44- Helper function, tries to get information from the RSS for the given
45- Element, otherwise, it gets it from the CS.
42+ Helper function, tries to get information from the RSS for the given Element
4643
4744 :param elementName: name of the element or list of element names
4845 :type elementName: str, list
@@ -94,7 +91,7 @@ def getElementStatus(self, elementName, elementType, statusType=None, default=No
9491 return self .__getRSSElementStatus (elementName , elementType , statusType , vO )
9592
9693 def setElementStatus (self , elementName , elementType , statusType , status , reason = None , tokenOwner = None ):
97- """Tries set information in RSS and in CS.
94+ """Tries set information in RSS
9895
9996 :param elementName: name of the element
10097 :type elementName: str
@@ -169,50 +166,6 @@ def __getRSSElementStatus(self, elementName, elementType, statusType, vO):
169166
170167 return cacheMatch
171168
172- def __getCSElementStatus (self , elementName , elementType , statusType , default ):
173- """Gets from the CS the Element status
174-
175- :param elementName: name of the element
176- :type elementName: str
177- :param elementType: type of the element (StorageElement, ComputingElement, FTS)
178- :type elementType: str
179- :param statusType: type of the status (meaningful only when elementType==StorageElement)
180- :type statusType: str, list
181- :param default: defult value
182- :type default: None, str
183- """
184- cs_path = None
185- # DIRAC doesn't store the status of ComputingElements nor FTS in the CS, so here we can just return 'Active'
186- if elementType in ("ComputingElement" , "FTS" ):
187- return S_OK ({elementName : {"all" : "Active" }})
188-
189- # If we are here it is because elementType is 'StorageElement'
190- if elementType == "StorageElement" :
191- cs_path = "/Resources/StorageElements"
192-
193- if not isinstance (elementName , list ):
194- elementName = [elementName ]
195-
196- if not isinstance (statusType , list ):
197- statusType = [statusType ]
198-
199- result = {}
200- for element in elementName :
201- for sType in statusType :
202- # Look in standard location, 'Active' by default
203- res = gConfig .getValue (f"{ cs_path } /{ element } /{ sType } " , "Active" )
204- result .setdefault (element , {})[sType ] = res
205-
206- if result :
207- return S_OK (result )
208-
209- if default is not None :
210- defList = [[el , statusType , default ] for el in elementName ]
211- return S_OK (getDictFromList (defList ))
212-
213- _msg = "Element '%s', with statusType '%s' is unknown for CS."
214- return S_ERROR (DErrno .ERESUNK , _msg % (elementName , statusType ))
215-
216169 def __setRSSElementStatus (self , elementName , elementType , statusType , status , reason , tokenOwner ):
217170 """
218171 Sets on the RSS the Elements status
@@ -247,33 +200,6 @@ def __setRSSElementStatus(self, elementName, elementType, statusType, status, re
247200 # Release lock, no matter what.
248201 self .rssCache .releaseLock ()
249202
250- def __setCSElementStatus (self , elementName , elementType , statusType , status ):
251- """
252- Sets on the CS the Elements status
253- """
254- cs_path = None
255- # DIRAC doesn't store the status of ComputingElements nor FTS in the CS, so here we can just do nothing
256- if elementType in ("ComputingElement" , "FTS" ):
257- return S_OK ()
258-
259- # If we are here it is because elementType is 'StorageElement'
260- statuses = self .rssConfig .getConfigStatusType (elementType )
261- if statusType not in statuses :
262- gLogger .error (f"{ statusType } is not a valid statusType" )
263- return S_ERROR (f"{ statusType } is not a valid statusType: { statuses } " )
264-
265- if elementType == "StorageElement" :
266- cs_path = "/Resources/StorageElements"
267-
268- csAPI = CSAPI ()
269- csAPI .setOption (f"{ cs_path } /{ elementName } /{ elementType } /{ statusType } " , status )
270-
271- res = csAPI .commitChanges ()
272- if not res ["OK" ]:
273- gLogger .warn (f"CS: { res ['Message' ]} " )
274-
275- return res
276-
277203 def isStorageElementAlwaysBanned (self , seName , statusType ):
278204 """Checks if the AlwaysBanned policy is applied to the SE given as parameter
279205
0 commit comments