From 5f3dbe5acdf11c6d064594f4b6a4def1f30d2c9b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 27 Dec 2020 22:29:15 +0800 Subject: [PATCH] mgr/dashboard: annotate command handler and use enum as the argument Signed-off-by: Kefu Chai --- src/pybind/mgr/dashboard/plugins/debug.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/dashboard/plugins/debug.py b/src/pybind/mgr/dashboard/plugins/debug.py index 6106143f5f890..8eb2bb1e6da08 100644 --- a/src/pybind/mgr/dashboard/plugins/debug.py +++ b/src/pybind/mgr/dashboard/plugins/debug.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + from __future__ import absolute_import import json @@ -55,14 +56,14 @@ class Debug(SP, I.CanCherrypy, I.ConfiguresCherryPy, # pylint: disable=too-many self._refresh_health_checks() @no_type_check - def handler(self, action): + def handler(self, action: Actions): ''' Control and report debug status in Ceph-Dashboard ''' ret = 0 msg = '' - if action in [Actions.ENABLE.value, Actions.DISABLE.value]: - self.set_option(self.NAME, action == Actions.ENABLE.value) + if action in [Actions.ENABLE, Actions.DISABLE]: + self.set_option(self.NAME, action == Actions.ENABLE) self.mgr.update_cherrypy_config({}) self._refresh_health_checks() else: @@ -73,8 +74,6 @@ class Debug(SP, I.CanCherrypy, I.ConfiguresCherryPy, # pylint: disable=too-many COMMANDS = [ SP.Command( prefix="dashboard {name}".format(name=NAME), - args="name=action,type=CephChoices,strings={states}".format( - states="|".join(a.value for a in Actions)), handler=handler ) ] -- 2.39.5