]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: annotate command handler
authorKefu Chai <kchai@redhat.com>
Sun, 27 Dec 2020 14:29:15 +0000 (22:29 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 15 Jan 2021 01:50:53 +0000 (09:50 +0800)
and use enum as the argument

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/dashboard/plugins/debug.py

index 6106143f5f89068b1ee15b9b820f6b2ce8c8753f..8eb2bb1e6da08c0dd419dda4a0fa234ce7182061 100644 (file)
@@ -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
         )
     ]