Skip to content

Commit b46bc92

Browse files
committed
fix: removed endpoint from SpaceTokenOccupancyCache
1 parent fddfcf9 commit b46bc92

File tree

4 files changed

+19
-33
lines changed

4 files changed

+19
-33
lines changed

src/DIRAC/ResourceStatusSystem/Client/ResourceManagementClient.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -724,13 +724,11 @@ def addOrModifyPolicyResult(
724724
# SpaceTokenOccupancyCache Methods ...........................................
725725

726726
def selectSpaceTokenOccupancyCache(
727-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None
727+
self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None, meta=None
728728
):
729729
"""
730730
Gets from SpaceTokenOccupancyCache all rows that match the parameters given.
731731
732-
:param endpoint: endpoint
733-
:type endpoint: string, list
734732
:param token: name of the token
735733
:type token: string, list
736734
:param total: total terabytes
@@ -745,19 +743,15 @@ def selectSpaceTokenOccupancyCache(
745743
For example: meta={'columns': ['Name']} will return only the 'Name' column.
746744
:return: S_OK() || S_ERROR()
747745
"""
748-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"]
749-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime, meta]
746+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime", "Meta"]
747+
columnValues = [token, total, guaranteed, free, lastCheckTime, meta]
750748

751749
return self._getRPC().select("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
752750

753-
def deleteSpaceTokenOccupancyCache(
754-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
755-
):
751+
def deleteSpaceTokenOccupancyCache(self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None):
756752
"""
757753
Deletes from SpaceTokenOccupancyCache all rows that match the parameters given.
758754
759-
:param endpoint: endpoint
760-
:type endpoint: string, list
761755
:param token: name of the token
762756
:type token: string, list
763757
:param total: total terabytes
@@ -770,13 +764,13 @@ def deleteSpaceTokenOccupancyCache(
770764
:type lastCheckTime: datetime, list
771765
:return: S_OK() || S_ERROR()
772766
"""
773-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
774-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime]
767+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
768+
columnValues = [token, total, guaranteed, free, lastCheckTime]
775769

776770
return self._getRPC().delete("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
777771

778772
def addOrModifySpaceTokenOccupancyCache(
779-
self, endpoint=None, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
773+
self, token=None, total=None, guaranteed=None, free=None, lastCheckTime=None
780774
):
781775
"""
782776
Adds or updates-if-duplicated to SpaceTokenOccupancyCache. Using `site` and `token`
@@ -791,8 +785,8 @@ def addOrModifySpaceTokenOccupancyCache(
791785
:param datetime lastCheckTime: time-stamp from which the result is effective
792786
:return: S_OK() || S_ERROR()
793787
"""
794-
columnNames = ["Endpoint", "Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
795-
columnValues = [endpoint, token, total, guaranteed, free, lastCheckTime]
788+
columnNames = ["Token", "Total", "Guaranteed", "Free", "LastCheckTime"]
789+
columnValues = [token, total, guaranteed, free, lastCheckTime]
796790

797791
return self._getRPC().addOrModify("SpaceTokenOccupancyCache", prepareDict(columnNames, columnValues))
798792

src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def doNew(self, masterParams=None):
7979
free = occupancy["Free"]
8080
total = occupancy["Total"]
8181

82-
results = {"Endpoint": "Deprecated", "Free": free, "Total": total, "ElementName": elementName}
82+
results = {"Free": free, "Total": total, "ElementName": elementName}
8383
result = self._storeCommand(results)
8484
if not result["OK"]:
8585
return result
@@ -92,15 +92,13 @@ def _storeCommand(self, results):
9292
and adds records to the StorageOccupancy accounting.
9393
9494
:param dict results: something like {'ElementName': 'CERN-HIST-EOS',
95-
'Endpoint': 'httpg://srm-eoslhcb-bis.cern.ch:8443/srm/v2/server',
9695
'Free': 3264963586.10073,
9796
'Total': 8000000000.0}
9897
:returns: S_OK/S_ERROR dict
9998
"""
10099

101100
# Stores in cache
102101
res = self.rmClient.addOrModifySpaceTokenOccupancyCache(
103-
endpoint=results["Endpoint"],
104102
lastCheckTime=datetime.utcnow(),
105103
free=results["Free"],
106104
total=results["Total"],
@@ -116,8 +114,6 @@ def _storeCommand(self, results):
116114
return siteRes
117115

118116
accountingDict = {
119-
"StorageElement": results["ElementName"],
120-
"Endpoint": results["Endpoint"],
121117
"Site": siteRes["Value"] if siteRes["Value"] else "unassigned",
122118
}
123119

src/DIRAC/ResourceStatusSystem/DB/ResourceManagementDB.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ class SpaceTokenOccupancyCache(rmsBase):
322322
__tablename__ = "SpaceTokenOccupancyCache"
323323
__table_args__ = {"mysql_engine": "InnoDB", "mysql_charset": "utf8mb4"}
324324

325-
endpoint = Column("Endpoint", String(128), nullable=False, primary_key=True)
326325
token = Column("Token", String(64), nullable=False, primary_key=True)
327326
guaranteed = Column("Guaranteed", Float(asdecimal=False), nullable=False, server_default="0")
328327
free = Column("Free", Float(asdecimal=False), nullable=False, server_default="0")
@@ -337,7 +336,6 @@ def fromDict(self, dictionary):
337336
:type arguments: dict
338337
"""
339338

340-
self.endpoint = dictionary.get("Endpoint", self.endpoint)
341339
self.token = dictionary.get("Token", self.token)
342340
self.guaranteed = dictionary.get("Guaranteed", self.guaranteed)
343341
self.free = dictionary.get("Free", self.free)
@@ -351,7 +349,7 @@ def fromDict(self, dictionary):
351349

352350
def toList(self):
353351
"""Simply returns a list of column values"""
354-
return [self.endpoint, self.token, self.guaranteed, self.free, self.total, self.lastchecktime]
352+
return [self.token, self.guaranteed, self.free, self.total, self.lastchecktime]
355353

356354

357355
class TransferCache(rmsBase):

tests/Integration/ResourceStatusSystem/Test_ResourceManagement.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,31 @@ def test_SpaceTokenOccupancy(rmClient):
266266
SpaceTokenOccupancy table
267267
"""
268268

269-
res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token") # just making sure it's not there (yet)
269+
res = rmClient.deleteSpaceTokenOccupancyCache("token") # just making sure it's not there (yet)
270270
assert res["OK"] is True, res["Message"]
271271

272272
# TEST addOrModifySpaceTokenOccupancy
273-
res = rmClient.addOrModifySpaceTokenOccupancyCache(
274-
"endpoint", "token", 500.0, 1000.0, 200.0, datetime.datetime.now()
275-
)
273+
res = rmClient.addOrModifySpaceTokenOccupancyCache("token", 500.0, 1000.0, 200.0, datetime.datetime.now())
276274
assert res["OK"] is True, res["Message"]
277275

278-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
276+
res = rmClient.selectSpaceTokenOccupancyCache("token")
279277
assert res["OK"] is True, res["Message"]
280278
# check if the name that we got is equal to the previously added 'token'
281279
assert res["Value"][0][1] == "token"
282280

283-
res = rmClient.addOrModifySpaceTokenOccupancyCache("endpoint", "token", free=100.0)
281+
res = rmClient.addOrModifySpaceTokenOccupancyCache("token", free=100.0)
284282
assert res["OK"] is True, res["Message"]
285283

286-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
284+
res = rmClient.selectSpaceTokenOccupancyCache("token")
287285
# check if the result has changed
288-
assert res["Value"][0][3] == 100.0
286+
assert res["Value"][0][2] == 100.0
289287

290288
# TEST deleteSpaceTokenOccupancy
291289
# ...............................................................................
292-
res = rmClient.deleteSpaceTokenOccupancyCache("endpoint", "token")
290+
res = rmClient.deleteSpaceTokenOccupancyCache("token")
293291
assert res["OK"] is True, res["Message"]
294292

295-
res = rmClient.selectSpaceTokenOccupancyCache("endpoint", "token")
293+
res = rmClient.selectSpaceTokenOccupancyCache("token")
296294
assert res["OK"] is True, res["Message"]
297295
assert not res["Value"], res["Value"]
298296

0 commit comments

Comments
 (0)