]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr/crash: define options using Option
authorKefu Chai <kchai@redhat.com>
Sun, 31 Jan 2021 10:33:43 +0000 (18:33 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Feb 2021 12:50:07 +0000 (20:50 +0800)
more type safe this way

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/crash/module.py

index e0235465848d0d72bf0298cdffec191d78227f5a..7f52f95e7113a83b050f1eb7bb39a68f6a27b67b 100644 (file)
@@ -1,5 +1,5 @@
 import hashlib
-from mgr_module import CLICommand, CLIReadCommand, CLIWriteCommand, MgrModule
+from mgr_module import CLICommand, CLIReadCommand, CLIWriteCommand, MgrModule, Option
 import datetime
 import errno
 import functools
@@ -27,27 +27,25 @@ def with_crashes(func: FuncT) -> FuncT:
         with self.crashes_lock:
             if not self.crashes:
                 self._load_crashes()
-            return func(*args, **kwargs)
+            return func(self, *args, **kwargs)
     wrapper.__signature__ = inspect.signature(func)  # type: ignore[attr-defined]
     return cast(FuncT, wrapper)
 
 
 class Module(MgrModule):
     MODULE_OPTIONS = [
-        {
-            'name': 'warn_recent_interval',
-            'type': 'secs',
-            'default': 60*60*24*14,
-            'desc': 'time interval in which to warn about recent crashes',
-            'runtime': True,
-        },
-        {
-            'name': 'retain_interval',
-            'type': 'secs',
-            'default': 60*60*24 * 365,
-            'desc': 'how long to retain crashes before pruning them',
-            'runtime': True,
-        },
+        Option(
+            name='warn_recent_interval',
+            type='secs',
+            default=60*60*24*14,
+            desc='time interval in which to warn about recent crashes',
+            runtime=True),
+        Option(
+            name='retain_interval',
+            type='secs',
+            default=60*60*24 * 365,
+            desc='how long to retain crashes before pruning them',
+            runtime=True),
     ]
 
     def __init__(self, *args, **kwargs):