From 8169d60efdcbb85bbd457efe865a7e3d8ca16c93 Mon Sep 17 00:00:00 2001 From: Andrii Lytovchenko Date: Tue, 21 Jun 2022 11:19:24 +0300 Subject: [PATCH] refactor: (SiteSummary/ResourceSummary) use BaseRequestHandler --- .../WebApp/handler/ResourceSummaryHandler.py | 301 ++++++------------ .../WebApp/handler/SiteSummaryHandler.py | 172 ++++------ .../ResourceSummary/classes/OverviewPanel.js | 52 +-- .../classes/ResourceSummary.js | 22 +- .../SiteSummary/classes/OverviewPanel.js | 22 +- .../DIRAC/SiteSummary/classes/SiteSummary.js | 20 +- 6 files changed, 216 insertions(+), 373 deletions(-) diff --git a/src/WebAppDIRAC/WebApp/handler/ResourceSummaryHandler.py b/src/WebAppDIRAC/WebApp/handler/ResourceSummaryHandler.py index 87d7e9c24..8de635528 100644 --- a/src/WebAppDIRAC/WebApp/handler/ResourceSummaryHandler.py +++ b/src/WebAppDIRAC/WebApp/handler/ResourceSummaryHandler.py @@ -6,20 +6,20 @@ from DIRAC.ResourceStatusSystem.Client.PublisherClient import PublisherClient from DIRAC.ResourceStatusSystem.PolicySystem.StateMachine import RSSMachine -from WebAppDIRAC.Lib.WebHandler import WebHandler, asyncGen +from WebAppDIRAC.Lib.WebHandler import _WebHandler as WebHandler class SummaryHandlerMix(WebHandler): - AUTH_PROPS = "all" + DEFAULT_AUTHORIZATION = "all" ELEMENT_TYPE = None - def _getSelectionData(self) -> dict: + def _getSelectionData(self, **kwargs) -> dict: """It returns the possible selection data""" callback = {"name": set(), "elementType": set(), "status": set(), "statusType": set(), "tokenOwner": set()} pub = PublisherClient() - gLogger.info("Arguments to web_getSelectionData", repr(self.request.arguments)) + gLogger.info("Arguments to web_getSelectionData", repr(kwargs)) elementStatuses = pub.getElementStatuses(self.ELEMENT_TYPE, None, None, None, None, None) if elementStatuses["OK"]: @@ -62,19 +62,6 @@ def combine(self, elementValues: list) -> dict: status = "Banned" reason = "Not usable" - # if set( [ 'Unknown','Active', 'Degraded' ] ) & set( statusSet ): - # for upStatus in [ 'Active', 'Degraded' ]: - # if upStatus in statusSet: - # status = upStatus - # reason = '%d %s' % ( statuses.count( upStatus ), upStatus ) - # break - # else: - # for downStatus in [ 'Unknown','Probing','Banned','Error' ]: - # if downStatus in statusSet: - # status = downStatus - # reason = '%d %s' % ( statuses.count( downStatus ), downStatus ) - # break - # Make a copy combined = {} combined.update(elementValues[0]) @@ -88,15 +75,12 @@ def combine(self, elementValues: list) -> dict: return combined - def _expand(self) -> dict: + def _expand(self, name) -> dict: """This method handles the POST requests""" + if name: + name = list(json.loads(name)) - requestParams = self._requestParams() - gLogger.info(requestParams) - - pub = PublisherClient() - - elements = pub.getElementStatuses(self.ELEMENT_TYPE, requestParams["name"], None, None, None, None) + elements = PublisherClient().getElementStatuses(self.ELEMENT_TYPE, name, None, None, None, None) if not elements["OK"]: return {"success": "false", "error": elements["Message"]} @@ -108,79 +92,65 @@ def _expand(self) -> dict: return {"success": "true", "result": elementList, "total": len(elementList)} - def _action(self) -> dict: + def _action(self, action, **kwargs) -> dict: """Do action requested from the web portal.""" - requestParams = self._requestParams() - if not requestParams.get("action"): + if not (methodName := action): return {"success": "false", "error": "Missing action"} - # pylint does not understand the action entry is not None any more - actionName = requestParams["action"][0] # pylint: disable=unsubscriptable-object - - methodName = actionName - if not actionName.startswith("set"): - methodName = f"_get{actionName}" + if not action.startswith("set"): + methodName = f"_get{action}" - try: - return getattr(self, methodName)(requestParams) - except AttributeError: - return {"success": "false", "error": f"bad action {actionName}"} + if not hasattr(self, methodName): + return {"success": "false", "error": f"bad action {action}"} + return getattr(self, methodName)(kwargs) def __checkAuth(self, username: str): """Check user permissions - :param username: user name - :return: None if all OK else error message """ - if username == "anonymous": + if username.lower() == "anonymous": return "Cannot perform this operation as anonymous" if "SiteManager" not in self.getProperties(): return "Not authorized" def setToken(self, requestParams: dict) -> dict: - """Set token - - :param requestParams: request parameters - """ + """Set token""" if error := self.__checkAuth(username := self.getUserName()): return {"success": "false", "error": error} - res = PublisherClient().setToken( + result = PublisherClient().setToken( self.ELEMENT_TYPE, - str(requestParams["name"][0]), - str(requestParams["statusType"][0]), - str(requestParams["status"][0]), - str(requestParams["elementType"][0]), + requestParams["name"], + requestParams["statusType"], + requestParams["status"], + requestParams["elementType"], username, - str(requestParams["lastCheckTime"][0]), + requestParams["lastCheckTime"], ) - if not res["OK"]: - return {"success": "false", "error": res["Message"]} - return {"success": "true", "result": res["Value"]} + if not result["OK"]: + return {"success": "false", "error": result["Message"]} + return {"success": "true", "result": result["Value"]} def setStatus(self, requestParams: dict) -> dict: - """Set token - - :param requestParams: request parameters - """ + """Set token""" if error := self.__checkAuth(username := self.getUserName()): return {"success": "false", "error": error} - res = PublisherClient().setStatus( + result = PublisherClient().setStatus( self.ELEMENT_TYPE, - str(requestParams["name"][0]), - str(requestParams["statusType"][0]), - str(requestParams["status"][0]), - str(requestParams["elementType"][0]), + requestParams["name"], + requestParams["statusType"], + requestParams["status"], + requestParams["elementType"], username, - str(requestParams["lastCheckTime"][0]), + requestParams["lastCheckTime"], ) - if not res["OK"]: - return {"success": "false", "error": res["Message"]} - return {"success": "true", "result": res["Value"]} + if not result["OK"]: + return {"success": "false", "error": result["Message"]} + return {"success": "true", "result": result["Value"]} def _checkParameters(self, requestParams: dict, parametersToCheck: list): """Check incoming parameters @@ -195,91 +165,74 @@ def _checkParameters(self, requestParams: dict, parametersToCheck: list): return f"Missing {fieldName}" def _getHistory(self, requestParams: dict) -> dict: - """Get history - - :param requestParams: request parameters - """ + """Get history""" if error := self._checkParameters(requestParams, ["name", "elementType", "statusType"]): return {"success": "false", "error": error} - res = PublisherClient().getElementHistory( - self.ELEMENT_TYPE, - requestParams["name"], - requestParams["elementType"], - requestParams["statusType"], + result = PublisherClient().getElementHistory( + self.ELEMENT_TYPE, requestParams["name"], requestParams["elementType"], requestParams["statusType"] ) - - if not res["OK"]: - gLogger.error(res["Message"]) + if not result["OK"]: + gLogger.error(result["Message"]) return {"success": "false", "error": "error getting history"} - history = [[r[0], str(r[1]), r[2]] for r in res["Value"]] + history = [[r[0], str(r[1]), r[2]] for r in result["Value"]] return {"success": "true", "result": history, "total": len(history)} def _getPolicies(self, requestParams: dict) -> dict: - """Get policies - - :param requestParams: request parameters - """ + """Get policies""" if error := self._checkParameters(requestParams, ["name", "statusType"]): return {"success": "false", "error": error} - res = PublisherClient().getElementPolicies( + result = PublisherClient().getElementPolicies( self.ELEMENT_TYPE, requestParams["name"], requestParams["statusType"] ) - - if not res["OK"]: - gLogger.error(res["Message"]) + if not result["OK"]: + gLogger.error(result["Message"]) return {"success": "false", "error": "error getting policies"} - policies = [[r[0], r[1], str(r[2]), str(r[3]), r[4]] for r in res["Value"]] + policies = [[r[0], r[1], str(r[2]), str(r[3]), r[4]] for r in result["Value"]] return {"success": "true", "result": policies, "total": len(policies)} def _getDowntime(self, requestParams: dict) -> dict: - """Get downtime - - :param requestParams: request parameters - """ + """Get downtime""" if error := self._checkParameters(requestParams, ["name", "element", "elementType", "statusType"]): return {"success": "false", "error": error} - res = PublisherClient().getDowntimes( - str(requestParams["element"][-1]), - str(requestParams["elementType"][-1]), - str(requestParams["name"][-1]), + result = PublisherClient().getDowntimes( + requestParams["element"], + requestParams["elementType"], + requestParams["name"], ) - if not res["OK"]: - gLogger.error(res["Message"]) + if not result["OK"]: + gLogger.error(result["Message"]) return {"success": "false", "error": "error getting downtimes"} - downtimes = [[str(dt[0]), str(dt[1]), dt[2], dt[3], dt[4]] for dt in res["Value"]] + downtimes = [[str(dt[0]), str(dt[1]), dt[2], dt[3], dt[4]] for dt in result["Value"]] return {"success": "true", "result": downtimes, "total": len(downtimes)} def _getTimeline(self, requestParams: dict) -> dict: - """Get timeline - - :param requestParams: request parameters - """ + """Get timeline""" if error := self._checkParameters(requestParams, ["name", "elementType", "statusType"]): return {"success": "false", "error": error} - res = PublisherClient().getElementHistory( + result = PublisherClient().getElementHistory( self.ELEMENT_TYPE, - str(requestParams["name"][-1]), - str(requestParams["elementType"][-1]), - str(requestParams["statusType"][-1]), + requestParams["name"], + requestParams["elementType"], + requestParams["statusType"], ) - if not res["OK"]: - gLogger.error(res["Message"]) + if not result["OK"]: + gLogger.error(result["Message"]) return {"success": "false", "error": "error getting history"} history = [] - for status, dateEffective, reason in res["Value"]: + for status, dateEffective, reason in result["Value"]: # history.append( [ history[ -1 ][ 0 ], str( dateEffective - timedelta( seconds = 1 ) ), '' ] ) @@ -288,34 +241,30 @@ def _getTimeline(self, requestParams: dict) -> dict: return {"success": "true", "result": history, "total": len(history)} def _getTree(self, requestParams: dict) -> dict: - """Get timeline - - :param requestParams: request parameters - """ + """Get timeline""" if error := self._checkParameters(requestParams, ["name", "elementType", "statusType"]): return {"success": "false", "error": error} - pub = PublisherClient() - res = PublisherClient().getTree(str(requestParams["elementType"][-1]), str(requestParams["name"][-1])) - if not res["OK"]: - gLogger.error(res["Message"]) + result = PublisherClient().getTree(requestParams["elementType"], requestParams["name"]) + if not result["OK"]: + gLogger.error(result["Message"]) return {"success": "false", "error": "error getting tree"} - res = res["Value"] + data = result["Value"] - siteName = list(res)[0] + siteName = list(data)[0] tree = [[siteName, None, None, None]] - for k, v in res[siteName]["statusTypes"].items(): + for k, v in data[siteName]["statusTypes"].items(): tree.append([None, k, v, siteName]) tree.append(["ces", None, None, siteName]) - for ce, ceDict in res[siteName]["ces"].items(): + for ce, ceDict in data[siteName]["ces"].items(): tree.append([ce, None, None, "ces"]) for k, v in ceDict.items(): tree.append([None, k, v, ce]) tree.append(["ses", None, None, siteName]) - for se, seDict in res[siteName]["ses"].items(): + for se, seDict in data[siteName]["ses"].items(): tree.append([se, None, None, "ses"]) for k, v in seDict.items(): tree.append([None, k, v, se]) @@ -323,102 +272,59 @@ def _getTree(self, requestParams: dict) -> dict: return {"success": "true", "result": tree, "total": len(tree)} def _getInfo(self, requestParams: dict) -> dict: - """Get timeline - - :param requestParams: request parameters - """ + """Get timeline""" if error := self._checkParameters(requestParams, ["name", "element", "elementType", "statusType"]): return {"success": "false", "error": error} - res = PublisherClient().getElementStatuses( - str(requestParams["element"][-1]), - str(requestParams["name"][-1]), - str(requestParams["elementType"][-1]), - str(requestParams["statusType"][-1]), + result = PublisherClient().getElementStatuses( + requestParams["element"], + requestParams["name"], + requestParams["elementType"], + requestParams["statusType"], None, None, ) - if not res["OK"]: - return {"success": "false", "error": res["Message"]} - if not res["Value"]: + if not result["OK"]: + return {"success": "false", "error": result["Message"]} + if not result["Value"]: return {"success": "false", "error": "Nothing found."} - columns = res["Columns"] - - res = dict(zip(columns, res["Value"][0])) - res["DateEffective"] = str(res["DateEffective"]) - res["LastCheckTime"] = str(res["LastCheckTime"]) - res["TokenExpiration"] = str(res["TokenExpiration"]) - - return {"success": "true", "result": res, "total": len(res)} + columns = result["Columns"] - def _requestParams(self) -> dict: - """ - We receive the request and we parse it, in this case, we are doing nothing, - but it can be certainly more complex. - """ - gLogger.always("!!! PARAMS: ", repr(self.request.arguments)) + data = dict(zip(columns, result["Value"][0])) + data["DateEffective"] = str(data["DateEffective"]) + data["LastCheckTime"] = str(data["LastCheckTime"]) + data["TokenExpiration"] = str(data["TokenExpiration"]) - responseParams = { - "element": None, - "name": None, - "elementType": None, - "statusType": None, - "status": None, - "tokenOwner": None, - "lastCheckTime": None, - "action": None, - } - - for key in responseParams: - value = self.get_argument(key, "") - if value: - responseParams[key] = list(json.loads(value)) - - return responseParams + return {"success": "true", "result": data, "total": len(data)} class ResourceSummaryHandler(SummaryHandlerMix): ELEMENT_TYPE = "Resource" - @asyncGen def web_getSelectionData(self): - callback = yield self.threadTask(self._getSelectionData) - self.finish(callback) + return self._getSelectionData() - @asyncGen - def web_expand(self): - callback = yield self.threadTask(self._expand) - self.finish(callback) + def web_expand(self, name=None): + return self._expand(name) - @asyncGen - def web_action(self): - callback = yield self.threadTask(self._action) - self.finish(callback) + def web_action(self, action=None, **kwargs): + return self._action(action, **kwargs) - @asyncGen - def web_getResourceSummaryData(self): + def web_getResourceSummaryData(self, name=None, status=None, elementType=None, statusType=None, tokenOwner=None): """This method returns the data required to fill the grid.""" - - requestParams = self._requestParams() - gLogger.info(requestParams) - - pub = PublisherClient() - - elementStatuses = yield self.threadTask( - pub.getElementStatuses, + elementStatuses = PublisherClient().getElementStatuses( self.ELEMENT_TYPE, - requestParams["name"], - requestParams["elementType"], - requestParams["statusType"], - requestParams["status"], - requestParams["tokenOwner"], + name, + elementType, + statusType, + status, + tokenOwner, ) if not elementStatuses["OK"]: - self.finish({"success": "false", "error": elementStatuses["Message"]}) - return + return {"success": "false", "error": elementStatuses["Message"]} elementTree = collections.defaultdict(list) @@ -439,13 +345,10 @@ def web_getResourceSummaryData(self): if len(elementValues) == 1: elementList.append(elementValues[0]) else: - elementList.append(self.combine(elementValues)) - rssMachine = RSSMachine(None) - - yield self.threadTask(rssMachine.orderPolicyResults, elementList) + RSSMachine(None).orderPolicyResults(elementList) timestamp = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M [UTC]") - self.finish({"success": "true", "result": elementList, "total": len(elementList), "date": timestamp}) + return {"success": "true", "result": elementList, "total": len(elementList), "date": timestamp} diff --git a/src/WebAppDIRAC/WebApp/handler/SiteSummaryHandler.py b/src/WebAppDIRAC/WebApp/handler/SiteSummaryHandler.py index cf479498c..a35a19e5d 100644 --- a/src/WebAppDIRAC/WebApp/handler/SiteSummaryHandler.py +++ b/src/WebAppDIRAC/WebApp/handler/SiteSummaryHandler.py @@ -9,7 +9,6 @@ from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSiteCEMapping, getGOCSiteName, getDIRACSiteName from DIRAC.ResourceStatusSystem.Client.PublisherClient import PublisherClient -from WebAppDIRAC.Lib.WebHandler import asyncGen from WebAppDIRAC.WebApp.handler.ResourceSummaryHandler import SummaryHandlerMix @@ -17,97 +16,79 @@ class SiteSummaryHandler(SummaryHandlerMix): ELEMENT_TYPE = "Site" - @asyncGen - def web_getSelectionData(self): - callback = yield self.threadTask(self._getSelectionData) - self.finish(callback) + def web_getSelectionData(self, **kwargs): + return self._getSelectionData(**kwargs) - @asyncGen - def web_expand(self): - callback = yield self.threadTask(self._expand) - self.finish(callback) + def web_expand(self, name=None): + return self._expand(name) - @asyncGen - def web_action(self): - callback = yield self.threadTask(self._action) - self.finish(callback) + def web_action(self, action=None, **kwargs): + return self._action(action, **kwargs) - @asyncGen - def web_getSiteSummaryData(self): + def web_getSiteSummaryData( + self, name=None, status=None, action=None, elementType=None, statusType=None, tokenOwner=None + ): """This method returns the data required to fill the grid.""" - requestParams = self.__requestParams() - gLogger.info(requestParams) - - elementStatuses = yield self.threadTask( - PublisherClient().getElementStatuses, - "Site", - requestParams["name"], - requestParams["elementType"], - requestParams["statusType"], - requestParams["status"], - requestParams["tokenOwner"], + if name: + name = list(json.loads(name)) + if status: + status = list(json.loads(status)) + if action: + action = list(json.loads(action)) + if elementType: + elementType = list(json.loads(elementType)) + if statusType: + statusType = list(json.loads(statusType)) + if tokenOwner: + tokenOwner = list(json.loads(tokenOwner)) + + elementStatuses = PublisherClient().getElementStatuses( + "Site", name, elementType, statusType, status, tokenOwner ) if not elementStatuses["OK"]: - self.finish({"success": "false", "error": elementStatuses["Message"]}) - return + return {"success": "false", "error": elementStatuses["Message"]} elementList = [dict(zip(elementStatuses["Columns"], site)) for site in elementStatuses["Value"]] for elementStatus in elementList: - elementStatus["Country"] = elementStatus["Name"][-2:] elementStatus["DateEffective"] = str(elementStatus["DateEffective"]) elementStatus["LastCheckTime"] = str(elementStatus["LastCheckTime"]) elementStatus["TokenExpiration"] = str(elementStatus["TokenExpiration"]) - result = {"success": "true", "result": elementList, "total": len(elementList)} - - self.finish(result) + return {"success": "true", "result": elementList, "total": len(elementList)} def _getInfo(self, requestParams: dict) -> dict: - """Get site info - - :param requestParams: request parameters - """ - - gLogger.info(requestParams) - - if not requestParams["name"]: + """Get site info""" + if not (name := requestParams.get("name")): gLogger.warn("No name given") return {"success": "false", "error": "We need a Site Name to generate an Overview"} - elementName = requestParams["name"][0] - - elementStatuses = PublisherClient().getElementStatuses("Site", str(elementName), None, "all", None, None) + elementStatuses = PublisherClient().getElementStatuses("Site", name, None, "all", None, None) if not elementStatuses["OK"]: gLogger.error(elementStatuses["Message"]) return {"success": "false", "error": "Error getting ElementStatus information"} if not elementStatuses["Value"]: - gLogger.error('element "%s" not found' % elementName) - return {"success": "false", "error": 'element "%s" not found' % elementName} + gLogger.error(f'element "{name}" not found') + return {"success": "false", "error": f'element "{name}" not found'} elementStatus = [dict(zip(elementStatuses["Columns"], element)) for element in elementStatuses["Value"]][0] elementStatus["DateEffective"] = str(elementStatus["DateEffective"]) elementStatus["LastCheckTime"] = str(elementStatus["LastCheckTime"]) elementStatus["TokenExpiration"] = str(elementStatus["TokenExpiration"]) - gocdb_name = getGOCSiteName(elementName) - if not gocdb_name["OK"]: + if not (gocdb_name := getGOCSiteName(name))["OK"]: gLogger.error(gocdb_name["Message"]) elementStatus["GOCDB"] = "" gocdb_name = "" else: gocdb_name = gocdb_name["Value"] elementStatus["GOCDB"] = '{gocdb_name}' - dirac_names = getDIRACSiteName(gocdb_name) - if not dirac_names["OK"]: + if not (dirac_names := getDIRACSiteName(gocdb_name))["OK"]: gLogger.error(dirac_names["Message"]) dirac_names = [] else: @@ -155,75 +136,58 @@ def _getInfo(self, requestParams: dict) -> dict: return {"success": "true", "result": elementStatus, "total": len(elementStatus)} def _getStorages(self, requestParams: dict) -> dict: - """Get storages - - :param requestParams: request parameters - """ - if not requestParams["name"]: + """Get storages""" + if not (name := requestParams.get("name")): gLogger.warn("No name given") return {"success": "false", "error": "We need a Site Name to generate an Overview"} - elementName = requestParams["name"][0] - retVal = getSEsForSite(elementName) - if not retVal["OK"]: - return {"success": "false", "error": retVal["Message"]} - storageElements = retVal["Value"] + if not (result := getSEsForSite(name))["OK"]: + return {"success": "false", "error": result["Message"]} + storageElements = result["Value"] storageElementsStatus = [] - gLogger.info("storageElements = " + str(storageElements)) + gLogger.info(f"storageElements = {storageElements}") # FIXME: use properly RSS for se in storageElements: - sestatuses = PublisherClient().getElementStatuses("Resource", se, None, None, None, None) - - for sestatus in sestatuses["Value"]: + result = PublisherClient().getElementStatuses("Resource", se, None, None, None, None) + for sestatus in result["Value"]: storageElementsStatus.append([sestatus[0], sestatus[1], sestatus[2], sestatus[6]]) return {"success": "true", "result": storageElementsStatus, "total": len(storageElementsStatus)} def _getComputingElements(self, requestParams: dict) -> dict: - """Get computing elements - - :param requestParams: request parameters - """ - if not requestParams["name"]: + """Get computing elements""" + if not (name := requestParams.get("name")): gLogger.warn("No name given") return {"success": "false", "error": "We need a Site Name to generate an Overview"} - elementName = requestParams["name"][0] - - res = getSiteCEMapping() - if not res["OK"]: - return {"success": "false", "error": res["Message"]} - computing_elements = res["Value"][elementName] + if not (result := getSiteCEMapping())["OK"]: + return {"success": "false", "error": result["Message"]} + computing_elements = result["Value"][name] computing_elements_status = [] - gLogger.info("computing_elements = " + str(computing_elements)) + gLogger.info(f"computing_elements = {computing_elements}") for ce in computing_elements: - cestatuses = PublisherClient().getElementStatuses("Resource", ce, None, "all", None, None) - gLogger.info("cestatus = " + str(cestatuses)) + result = PublisherClient().getElementStatuses("Resource", ce, None, "all", None, None) + gLogger.info(f"cestatus = {result}") - for cestatus in cestatuses["Value"]: + for cestatus in result["Value"]: computing_elements_status.append([cestatus[0], cestatus[1], cestatus[2], cestatus[6]]) return {"success": "true", "result": computing_elements_status, "total": len(computing_elements_status)} def _getImages(self, requestParams: dict) -> dict: - """Get images - - :param requestParams: request parameters - """ - if not requestParams["name"]: + """Get images""" + if not (name := requestParams.get("name")): gLogger.warn("No name given") return {"success": "false", "error": "We need a Site Name to generate an Overview"} - elementName = requestParams["name"][0] - - elementStatuses = PublisherClient().getElementStatuses("Site", str(elementName), None, "all", None, None) + elementStatuses = PublisherClient().getElementStatuses("Site", name, None, "all", None, None) if not elementStatuses["Value"]: - gLogger.error('element "%s" not found' % elementName) - return {"success": "false", "error": 'element "%s" not found' % elementName} + gLogger.error(f'element "{name}" not found') + return {"success": "false", "error": f'element "{name}" not found'} elementStatus = [dict(zip(elementStatuses["Columns"], element)) for element in elementStatuses["Value"]][0] @@ -296,27 +260,3 @@ def getPlotDict( plotDict["condDict"]["Status"] = [status] return plotDict - - def __requestParams(self) -> dict: - """ - We receive the request and we parse it, in this case, we are doing nothing, - but it can be certainly more complex. - """ - - gLogger.always("!!! PARAMS: ", repr(self.request.arguments)) - - responseParams = { - "name": None, - "elementType": None, - "statusType": None, - "status": None, - "action": None, - "tokenOwner": None, - } - - for key in responseParams: - value = self.get_argument(key, None) - if value: - responseParams[key] = list(json.loads(value)) - - return responseParams diff --git a/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/OverviewPanel.js b/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/OverviewPanel.js index c0abb651f..f95c8b428 100644 --- a/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/OverviewPanel.js +++ b/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/OverviewPanel.js @@ -352,11 +352,11 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Info"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), - element: selection.element ? Ext.JSON.encode([selection.element]) : Ext.JSON.encode(["Resource"]), + action: "Info", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, + element: selection.element ? selection.element : "Resource", }, scope: me, failure: function (response) { @@ -381,10 +381,10 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["History"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), + action: "History", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, }, scope: me, failure: function (response) { @@ -408,11 +408,11 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Downtime"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - element: Ext.JSON.encode(["Resource"]), - statusType: Ext.JSON.encode([selection.statusType]), + action: "Downtime", + name: selection.name, + elementType: selection.elementType, + element: "Resource", + statusType: selection.statusType, }, scope: me, failure: function (response) { @@ -436,10 +436,10 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Policies"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), + action: "Policies", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, }, scope: me, failure: function (response) { @@ -463,10 +463,10 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Timeline"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), + action: "Timeline", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, }, scope: me, failure: function (response) { @@ -531,10 +531,10 @@ Ext.define("DIRAC.ResourceSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Tree"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), + action: "Tree", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, }, scope: me, failure: function (response) { diff --git a/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/ResourceSummary.js b/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/ResourceSummary.js index b812592f0..6276d43f5 100644 --- a/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/ResourceSummary.js +++ b/src/WebAppDIRAC/WebApp/static/DIRAC/ResourceSummary/classes/ResourceSummary.js @@ -332,7 +332,7 @@ Ext.define("DIRAC.ResourceSummary.classes.ResourceSummary", { if (Ext.getCmp(targetId + "_grid") == null) { var params = { - name: Ext.JSON.encode([record.data.Name]), + name: record.data.Name, }; var oProxy = Ext.create("Ext.dirac.utils.DiracAjaxProxy", { url: GLOBAL.BASE_URL + "ResourceSummary/expand", @@ -463,10 +463,10 @@ Ext.define("DIRAC.ResourceSummary.classes.ResourceSummary", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode([action]), - name: Ext.JSON.encode([selectedValues.name]), - elementType: Ext.JSON.encode([selectedValues.elementType]), - statusType: Ext.JSON.encode([selectedValues.statusType]), + action: action, + name: selectedValues.name, + elementType: selectedValues.elementType, + statusType: selectedValues.statusType, }, scope: me, failure: function (response) { @@ -583,12 +583,12 @@ Ext.define("DIRAC.ResourceSummary.classes.ResourceSummary", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode([action]), - name: Ext.JSON.encode([selectedValues.name]), - elementType: Ext.JSON.encode([selectedValues.elementType]), - statusType: Ext.JSON.encode([selectedValues.statusType]), - status: Ext.JSON.encode([newStatus]), - lastCheckTime: Ext.JSON.encode([selectedValues.lastCheckTime]), + action: action, + name: selectedValues.name, + elementType: selectedValues.elementType, + statusType: selectedValues.statusType, + status: newStatus, + lastCheckTime: selectedValues.lastCheckTime, }, scope: me, failure: function (response) { diff --git a/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/OverviewPanel.js b/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/OverviewPanel.js index 57b6f833b..980ea4150 100644 --- a/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/OverviewPanel.js +++ b/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/OverviewPanel.js @@ -474,11 +474,11 @@ Ext.define("DIRAC.SiteSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Info"]), - name: Ext.JSON.encode([selection.name]), - elementType: Ext.JSON.encode([selection.elementType]), - statusType: Ext.JSON.encode([selection.statusType]), - element: selection.element ? Ext.JSON.encode([selection.element]) : Ext.JSON.encode(["Resource"]), + action: "Info", + name: selection.name, + elementType: selection.elementType, + statusType: selection.statusType, + element: selection.element ? selection.element : "Resource", }, scope: me, failure: function (response) { @@ -503,8 +503,8 @@ Ext.define("DIRAC.SiteSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["ComputingElements"]), - name: Ext.JSON.encode([selection.name]), + action: "ComputingElements", + name: selection.name, }, scope: me, failure: function (response) { @@ -528,8 +528,8 @@ Ext.define("DIRAC.SiteSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Storages"]), - name: Ext.JSON.encode([selection.name]), + action: "Storages", + name: selection.name, }, scope: me, failure: function (response) { @@ -552,8 +552,8 @@ Ext.define("DIRAC.SiteSummary.classes.OverviewPanel", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode(["Images"]), - name: Ext.JSON.encode([selection.name]), + action: "Images", + name: selection.name, }, scope: me, failure: function (response) { diff --git a/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/SiteSummary.js b/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/SiteSummary.js index afb5df6e9..3b22115ba 100644 --- a/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/SiteSummary.js +++ b/src/WebAppDIRAC/WebApp/static/DIRAC/SiteSummary/classes/SiteSummary.js @@ -360,10 +360,10 @@ Ext.define("DIRAC.SiteSummary.classes.SiteSummary", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode([action]), - name: Ext.JSON.encode([selectedValues.name]), - elementType: Ext.JSON.encode([selectedValues.elementType]), - statusType: Ext.JSON.encode([selectedValues.statusType]), + action: action, + name: selectedValues.name, + elementType: selectedValues.elementType, + statusType: selectedValues.statusType, }, scope: me, failure: function (response) { @@ -480,12 +480,12 @@ Ext.define("DIRAC.SiteSummary.classes.SiteSummary", { url: GLOBAL.BASE_URL + me.applicationName + "/action", method: "POST", params: { - action: Ext.JSON.encode([action]), - name: Ext.JSON.encode([selectedValues.name]), - elementType: Ext.JSON.encode([selectedValues.elementType]), - statusType: Ext.JSON.encode([selectedValues.statusType]), - status: Ext.JSON.encode([newStatus]), - lastCheckTime: Ext.JSON.encode([selectedValues.lastCheckTime]), + action: action, + name: selectedValues.name, + elementType: selectedValues.elementType, + statusType: selectedValues.statusType, + status: newStatus, + lastCheckTime: selectedValues.lastCheckTime, }, scope: me, failure: function (response) {