]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/mgr_module: add poll param to CLICommand
authorKefu Chai <kchai@redhat.com>
Sat, 16 Jan 2021 14:54:51 +0000 (22:54 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 24 Jan 2021 14:16:36 +0000 (22:16 +0800)
and add it to the output of dump_cmd() call, if "poll" is missing
in the output of dump_cmd() call, ceph CLI consider the it as False.

but it'd be better to be explicit. so this field is always set.

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

index 33eed68474171814710f3e4214d46a4f11c1baf3..93da6045c8e1bdef0d39783c8aded5a495a9d2c0 100644 (file)
@@ -300,9 +300,10 @@ class CRUSHMap(ceph_module.BasePyCRUSH):
 class CLICommand(object):
     COMMANDS = {}  # type: Dict[str, CLICommand]
 
-    def __init__(self, prefix, perm="rw"):
+    def __init__(self, prefix, perm="rw", poll=False):
         self.prefix = prefix
         self.perm = perm
+        self.poll = poll
         self.func = None  # type: Optional[Callable]
         self.arg_spec = {}    # type: Dict[str, Any]
         self.first_default = -1
@@ -383,7 +384,8 @@ class CLICommand(object):
         return {
             'cmd': '{} {}'.format(self.prefix, self.args),
             'desc': self.desc,
-            'perm': self.perm
+            'perm': self.perm,
+            'poll': self.poll,
         }
 
     @classmethod
@@ -391,12 +393,12 @@ class CLICommand(object):
         return [cmd.dump_cmd() for cmd in cls.COMMANDS.values()]
 
 
-def CLIReadCommand(prefix):
-    return CLICommand(prefix, "r")
+def CLIReadCommand(prefix, poll=False):
+    return CLICommand(prefix, "r", poll)
 
 
-def CLIWriteCommand(prefix):
-    return CLICommand(prefix, "w")
+def CLIWriteCommand(prefix, poll=False):
+    return CLICommand(prefix, "w", poll)
 
 
 def CLICheckNonemptyFileInput(func):