diff --git a/src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py b/src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py index 45029674ce2..8cc43e64ea7 100644 --- a/src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py +++ b/src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py @@ -724,13 +724,11 @@ def addOrModifyPolicyResult( # SpaceTokenOccupancyCache Methods ........................................... def selectSpaceTokenOccupancyCache( - self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None + self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None ): """ Gets from SpaceTokenOccupancyCache all rows that match the parameters given. - :param endpoint: endpoint - :type endpoint: string, list :param token: name of the token :type token: string, list :param total: total terabytes @@ -745,19 +743,15 @@ def selectSpaceTokenOccupancyCache( For example: meta={'columns': ['Name']} will return only the 'Name' column. :return: S_OK() || S_ERROR() """ - columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"] - columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime, meta] + columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"] + columnValues = [token, total, guaranteed, free, lastCheckTime, meta] return self._getRPC().select("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues)) - def deleteSpaceTokenOccupancyCache( - self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None - ): + def deleteSpaceTokenOccupancyCache(self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None): """ Deletes from SpaceTokenOccupancyCache all rows that match the parameters given. - :param endpoint: endpoint - :type endpoint: string, list :param token: name of the token :type token: string, list :param total: total terabytes @@ -770,20 +764,18 @@ def deleteSpaceTokenOccupancyCache( :type lastCheckTime: datetime, list :return: S_OK() || S_ERROR() """ - columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"] - columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime] + columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"] + columnValues = [token, total, guaranteed, free, lastCheckTime] return self._getRPC().delete("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues)) def addOrModifySpaceTokenOccupancyCache( - self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None + self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None ): """ Adds or updates-if-duplicated to SpaceTokenOccupancyCache. Using `site` and `token` to query the database, decides whether to insert or update the table. - :param endpoint: endpoint - :type endpoint: string, list :param str token: name of the token :param int total: total terabytes :param int guaranteed: guaranteed terabytes @@ -791,8 +783,8 @@ def addOrModifySpaceTokenOccupancyCache( :param datetime lastCheckTime: time-stamp from which the result is effective :return: S_OK() || S_ERROR() """ - columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"] - columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime] + columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"] + columnValues = [token, total, guaranteed, free, lastCheckTime] return self._getRPC().addOrModify("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues)) diff --git a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py index 572853b4b3d..595830555b0 100644 --- a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py +++ b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py @@ -79,7 +79,7 @@ def doNew(self, masterParams=None): free = occupancy["Free"] total = occupancy["Total"] - results = {"Endpoint": "Deprecated", "Free": free, "Total": total, "ElementName": elementName} + results = {"Free": free, "Total": total, "ElementName": elementName} result = self._storeCommand(results) if not result["OK"]: return result @@ -92,7 +92,6 @@ def _storeCommand(self, results): and adds records to the StorageOccupancy accounting. :param dict results: something like {'ElementName': 'CERN-HIST-EOS', - 'Endpoint': 'httpg://srm-eoslhcb-bis.cern.ch:8443/srm/v2/server', 'Free': 3264963586.10073, 'Total': 8000000000.0} :returns: S_OK/S_ERROR dict @@ -100,7 +99,6 @@ def _storeCommand(self, results): # Stores in cache res = self.rmClient.addOrModifySpaceTokenOccupancyCache( - endpoint=results["Endpoint"], lastCheckTime=datetime.utcnow(), free=results["Free"], total=results["Total"], @@ -116,8 +114,6 @@ def _storeCommand(self, results): return siteRes accountingDict = { - "StorageElement": results["ElementName"], - "Endpoint": results["Endpoint"], "Site": siteRes["Value"] if siteRes["Value"] else "unassigned", } @@ -189,10 +185,9 @@ def doMaster(self): return self._cleanCommand() def _cleanCommand(self, toDelete=None): - """Clean the spaceTokenOccupancy table from old endpoints + """Clean the spaceTokenOccupancy table from old SEs - :param tuple toDelete: endpoint to remove (endpoint, storage_element_name), - e.g. ('httpg://srm-lhcb.cern.ch:8443/srm/managerv2', CERN-RAW) + :param tuple toDelete: storage_element_name """ if not toDelete: toDelete = [] @@ -220,7 +215,7 @@ def _cleanCommand(self, toDelete=None): toDelete = [toDelete] for ep in toDelete: - res = self.rmClient.deleteSpaceTokenOccupancyCache(ep[0], ep[1]) + res = self.rmClient.deleteSpaceTokenOccupancyCache(ep) if not res["OK"]: self.log.warn("Could not delete entry from SpaceTokenOccupancyCache", res["Message"]) diff --git a/src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py b/src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py index 36f2034e6f6..221338be3f1 100644 --- a/src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py +++ b/src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py @@ -322,7 +322,6 @@ class SpaceTokenOccupancyCache(rmsBase): __tablename__ = "SpaceTokenOccupancyCache" __table_args__ = {"mysql_engine": "InnoDB", "mysql_charset": "utf8mb4"} - endpoint = Column("Endpoint", String(128), nullable=False, primary_key=True) token = Column("Token", String(64), nullable=False, primary_key=True) guaranteed = Column("Guaranteed", Float(asdecimal=False), nullable=False, server_default="0") free = Column("Free", Float(asdecimal=False), nullable=False, server_default="0") @@ -337,7 +336,6 @@ def fromDict(self, dictionary): :type arguments: dict """ - self.endpoint = dictionary.get("Endpoint", self.endpoint) self.token = dictionary.get("Token", self.token) self.guaranteed = dictionary.get("Guaranteed", self.guaranteed) self.free = dictionary.get("Free", self.free) @@ -351,7 +349,7 @@ def fromDict(self, dictionary): def toList(self): """Simply returns a list of column values""" - return [self.endpoint, self.token, self.guaranteed, self.free, self.total, self.lastchecktime] + return [self.token, self.guaranteed, self.free, self.total, self.lastchecktime] class TransferCache(rmsBase): diff --git a/tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py b/tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py index 761a57e049c..7b6ab0edd4a 100644 --- a/tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py +++ b/tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py @@ -266,33 +266,31 @@ def test_SpaceTokenOccupancy(rmClient): SpaceTokenOccupancy table """ - res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token") # just making sure it's not there (yet) + res = rmClient.deleteSpaceTokenOccupancyCache("token") # just making sure it's not there (yet) assert res["OK"] is True, res["Message"] # TEST addOrModifySpaceTokenOccupancy - res = rmClient.addOrModifySpaceTokenOccupancyCache( - "endpoint", "token", 500.0, 1000.0, 200.0, datetime.datetime.now() - ) + res = rmClient.addOrModifySpaceTokenOccupancyCache("token", 500.0, 1000.0, 200.0, datetime.datetime.now()) assert res["OK"] is True, res["Message"] - res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token") + res = rmClient.selectSpaceTokenOccupancyCache("token") assert res["OK"] is True, res["Message"] # check if the name that we got is equal to the previously added 'token' - assert res["Value"][0][1] == "token" + assert res["Value"][0][0] == "token" - res = rmClient.addOrModifySpaceTokenOccupancyCache("endpoint", "token", free=100.0) + res = rmClient.addOrModifySpaceTokenOccupancyCache("token", free=100.0) assert res["OK"] is True, res["Message"] - res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token") + res = rmClient.selectSpaceTokenOccupancyCache("token") # check if the result has changed - assert res["Value"][0][3] == 100.0 + assert res["Value"][0][2] == 100.0 # TEST deleteSpaceTokenOccupancy # ............................................................................... - res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token") + res = rmClient.deleteSpaceTokenOccupancyCache("token") assert res["OK"] is True, res["Message"] - res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token") + res = rmClient.selectSpaceTokenOccupancyCache("token") assert res["OK"] is True, res["Message"] assert not res["Value"], res["Value"]