From 12b2a3b100f8036d010fd41acbd92726920566e5 Mon Sep 17 00:00:00 2001 From: Paul Laffitte Date: Fri, 20 Dec 2024 13:16:34 +0100 Subject: [PATCH] feat: add list of available checks in sanitycheck --help --- src/pvecontrol/__init__.py | 5 ++++- src/pvecontrol/sanitycheck/sanitychecks.py | 8 -------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index cd0a013..5815397 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -10,6 +10,7 @@ from pvecontrol import actions, node, vm, task, storage from pvecontrol.cluster import PVECluster from pvecontrol.config import set_config +from pvecontrol.sanitycheck.tests import DEFAULT_CHECK_IDS def action_test(proxmox, _args): @@ -140,7 +141,9 @@ def _parser(): # sanitycheck parser parser_sanitycheck = subparsers.add_parser("sanitycheck", help="Run Sanity checks on the cluster") - parser_sanitycheck.add_argument("--check", action="append", required=False, help="Check to run", default=[]) + parser_sanitycheck.add_argument( + "--check", action="append", required=False, help="Check to run", default=[], choices=DEFAULT_CHECK_IDS + ) parser_sanitycheck.set_defaults(func=actions.cluster.action_sanitycheck) # _test parser, hidden from help diff --git a/src/pvecontrol/sanitycheck/sanitychecks.py b/src/pvecontrol/sanitycheck/sanitychecks.py index 2cef602..d9ce6c8 100644 --- a/src/pvecontrol/sanitycheck/sanitychecks.py +++ b/src/pvecontrol/sanitycheck/sanitychecks.py @@ -13,14 +13,6 @@ def run(self, checks): if not checks: checks = DEFAULT_CHECK_IDS - for check in checks: - if not check in DEFAULT_CHECK_IDS: - print( - f"Sanity check '{check}' doesn't exists.\n" - f"Here available values are:\n{', '.join(DEFAULT_CHECK_IDS)}" - ) - return 1 - for key in checks: check = DEFAULT_CHECKS[key](self._proxmox) check.run()