]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/status: add typing annotations
authorKefu Chai <kchai@redhat.com>
Fri, 29 Jan 2021 03:26:15 +0000 (11:26 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 29 Jan 2021 11:42:32 +0000 (19:42 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mypy.ini
src/pybind/mgr/status/module.py
src/pybind/mgr/tox.ini

index 9aa575ef79502a3076fc5cec06c798d7635b490d..5ad34b0f7cb9a2aaf766767c288af215fb68c70b 100755 (executable)
@@ -33,6 +33,9 @@ disallow_untyped_defs = True
 [mypy-orchestrator.*]
 disallow_untyped_defs = True
 
+[mypy-status.*]
+disallow_untyped_defs = True
+
 [mypy-zabbix.*]
 disallow_untyped_defs = True
 
index e9f14c5f883b5d0403aa6da4b5daefebf4b6e65a..c932bbb8ea9dab7473177b1afc638ea8c62965d7 100644 (file)
@@ -5,7 +5,7 @@ High level status display commands
 
 from collections import defaultdict
 from prettytable import PrettyTable
-from typing import Optional
+from typing import Dict, List, Optional, Tuple, Union
 import errno
 import fnmatch
 import mgr_util
@@ -16,7 +16,7 @@ from mgr_module import CLIReadCommand, MgrModule, HandleCommandResult
 
 
 class Module(MgrModule):
-    def get_latest(self, daemon_type, daemon_name, stat):
+    def get_latest(self, daemon_type: str, daemon_name: str, stat: str) -> int:
         data = self.get_counter(daemon_type, daemon_name, stat)[stat]
         #self.log.error("get_latest {0} data={1}".format(stat, data))
         if data:
@@ -24,9 +24,8 @@ class Module(MgrModule):
         else:
             return 0
 
-    def get_rate(self, daemon_type, daemon_name, stat):
+    def get_rate(self, daemon_type: str, daemon_name: str, stat: str) -> int:
         data = self.get_counter(daemon_type, daemon_name, stat)[stat]
-
         #self.log.error("get_latest {0} data={1}".format(stat, data))
         if data and len(data) > 1 and data[-1][0] != data[-2][0]:
             return (data[-1][1] - data[-2][1]) // int(data[-1][0] - data[-2][0])
@@ -34,12 +33,16 @@ class Module(MgrModule):
             return 0
 
     @CLIReadCommand("fs status")
-    def handle_fs_status(self, fs: Optional[str] = None, format: str = 'plain'):
+    def handle_fs_status(self, fs: Optional[str] = None, format: str = 'plain') -> Tuple[int, str, str]:
         """
         Show the status of a CephFS filesystem
         """
         output = ""
-        json_output = defaultdict(list)
+        json_output: Dict[str, List[Dict[str, Union[int, str, List[str]]]]] = \
+            dict(mdsmap=[],
+                 pools=[],
+                 clients=[],
+                 mds_version=[])
         output_format = format
 
         fs_filter = fs
@@ -275,7 +278,7 @@ class Module(MgrModule):
             return HandleCommandResult(stdout=output)
 
     @CLIReadCommand("osd status")
-    def handle_osd_status(self, bucket: Optional[str] = None):
+    def handle_osd_status(self, bucket: Optional[str] = None) -> Tuple[int, str, str]:
         """
         Show the status of OSDs within a bucket, or all
         """
index f9562a0c42f21fedda76e7e230ea26ba3b7a6a9c..484d182b7d3b224961b48467745f9e14f5fcdb76 100644 (file)
@@ -69,6 +69,7 @@ commands =
            -m rook \
            -m snap_schedule \
            -m stats \
+           -m status \
            -m test_orchestrator \
            -m volumes \
            -m zabbix