Skip to content

Commit

Permalink
Merge pull request #11025 from todor-ivanov/feature_MSUnmerged_RseAll…
Browse files Browse the repository at this point in the history
…DocsApi_fix_10995

Add rse=ALL_DOCS to the MSUnmerged info REST API.
  • Loading branch information
amaltaro authored Mar 7, 2022
2 parents 6a78d41 + d7e4714 commit 1592300
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions src/python/WMCore/MicroService/MSUnmerged/MSUnmerged.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,21 +822,38 @@ def getStatsFromMongoDB(self, detail=False, **kwargs):
data = {}
if kwargs.get('rse'):
data["query"] = 'rse=%s&detail=%s' % (kwargs['rse'], detail)
mongoProjection = {"_id": False,
"name": True,
"pfnPrefix": True,
"rucioConMonStatus": True,
"isClean": True,
"timestamps": True,
"counters": True}
if detail:
mongoProjection["dirs"] = True

rseList = kwargs['rse'] if isinstance(kwargs['rse'], list) else [kwargs['rse']]
data["rseData"] = []
for rseName in rseList:
mongoFilter = {'name': rseName}
data["rseData"].append(self.msUnmergedColl.find_one(mongoFilter, projection=mongoProjection))
allDocs = (kwargs['rse'].lower() == "all_docs") if isinstance(kwargs['rse'], str) else False

if allDocs:
mongoProjection = {
"_id": False,
"name": True,
"isClean": True,
"rucioConMonStatus": True,
"counters": {
"gfalErrors": True,
"dirsToDelete": True,
"dirsDeletedSuccess": True,
"dirsDeletedFail": True}}
mongoFilter = {}
data["rseData"] = list(self.msUnmergedColl.find(mongoFilter, projection=mongoProjection))
else:
mongoProjection = {
"_id": False,
"name": True,
"isClean": True,
"pfnPrefix": True,
"rucioConMonStatus": True,
"timestamps": True,
"counters": True}
if detail:
mongoProjection["dirs"] = True

rseList = kwargs['rse'] if isinstance(kwargs['rse'], list) else [kwargs['rse']]
data["rseData"] = []
for rseName in rseList:
mongoFilter = {'name': rseName}
data["rseData"].append(self.msUnmergedColl.find_one(mongoFilter, projection=mongoProjection))
return data

# @profile
Expand Down

0 comments on commit 1592300

Please sign in to comment.