Skip to content

Commit

Permalink
feat: add list of available checks in sanitycheck --help
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Dec 20, 2024
1 parent 6f7f52c commit 12b2a3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/pvecontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/pvecontrol/sanitycheck/sanitychecks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 12b2a3b

Please sign in to comment.