pybind/mgr/mgr_module: add poll param to CLICommand

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>
This commit is contained in:
Kefu Chai 2021-01-16 22:54:51 +08:00
parent 1453f0ff1f
commit 7a2e460d34

View 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):