From: Yuri Weinstein Date: Wed, 2 Feb 2022 00:03:32 +0000 (-0800) Subject: Merge pull request #44205 from k0ste/wip-53488-pacific X-Git-Tag: v16.2.8~218 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d199a0048faed894b92ae5d9db4a8503ce0e2e9;p=ceph.git Merge pull request #44205 from k0ste/wip-53488-pacific pacific: mgr/prometheus: define module options for standby Reviewed-by: Adam King adking@redhat.com --- 1d199a0048faed894b92ae5d9db4a8503ce0e2e9 diff --cc src/pybind/mgr/prometheus/module.py index f8573b61cbaf,6e37037d5199..83fe551a5350 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@@ -1622,39 -1420,11 +1622,42 @@@ class Module(MgrModule) self.log.info('Stopping engine...') self.shutdown_event.set() + @CLIReadCommand('healthcheck history ls') + def _list_healthchecks(self, format: Format = Format.plain) -> HandleCommandResult: + """List all the healthchecks being tracked + + The format options are parsed in ceph_argparse, before they get evaluated here so + we can safely assume that what we have to process is valid. ceph_argparse will throw + a ValueError if the cast to our Format class fails. + + Args: + format (Format, optional): output format. Defaults to Format.plain. + + Returns: + HandleCommandResult: return code, stdout and stderr returned to the caller + """ + + out = "" + if format == Format.plain: + out = str(self.health_history) + elif format == Format.yaml: + out = self.health_history.as_yaml() + else: + out = self.health_history.as_json(format == Format.json_pretty) + + return HandleCommandResult(retval=0, stdout=out) + + @CLIWriteCommand('healthcheck history clear') + def _clear_healthchecks(self) -> HandleCommandResult: + """Clear the healthcheck history""" + self.health_history.reset() + return HandleCommandResult(retval=0, stdout="healthcheck history cleared") + class StandbyModule(MgrStandbyModule): + + MODULE_OPTIONS = Module.MODULE_OPTIONS + def __init__(self, *args: Any, **kwargs: Any) -> None: super(StandbyModule, self).__init__(*args, **kwargs) self.shutdown_event = threading.Event()