openvstorage / openvstorage-health-check

The health check is classified as a monitoring and detection tool for Open vStorage.
3 stars 7 forks source link

Allow CLI argument defaults to be pulled from Configuration #450

Closed JeffreyDevloo closed 6 years ago

JeffreyDevloo commented 6 years ago

Feature description

Since the addition of expose to cli since #447, test parameters can be tweaked. For further automation, the parameters should be retrievable through Configuration

The healthcheck stamp an example Configuration based on the current parameters and then just load in the file for every group. Click documentation: http://click.pocoo.org/5/commands/#overriding-defaults

wimpers commented 6 years ago

Set to Roadmap. If required by @openvstorage/operations please leave a remark.

JeffreyDevloo commented 6 years ago

Pushing it back to M on request of Ops

JeffreyDevloo commented 6 years ago

Fixed by https://github.com/openvstorage/openvstorage-health-check/pull/471 Packaged in

Usage

The key to provide the defaults under: /ovs/healthcheck/default_arguments

Configs are to be set under MODULE : TEST: PARAM NAME PYTHONIFIED Example:

{
    "alba": {
        "disk-safety-test": {
            "include_errored_as_dead": false, 
            "skip_backend": [], 
            "backend": []
        }
}

The possible value is dependent on the type of argument to be set. When an option can be specified multiple times: the argument has to be a list. For other types (text and numeric values) just follow your intuition

A complete dict of all possible options and their current value can be generated:

from ovs.extensions.healthcheck.expose_to_cli import HealthCheckCLIRunner
HealthCheckCLIRunner.generate_configuration_options?
Type:        instancemethod
String form: <bound method type.generate_configuration_options of <class 'ovs.extensions.healthcheck.expose_to_cli.HealthCheckCLIRunner'>>
File:        /opt/OpenvStorage/ovs/extensions/healthcheck/expose_to_cli.py
Definition:  HealthCheckCLIRunner.generate_configuration_options(cls, re_use_current_settings=False)
Docstring:
Generate a complete structure indicating where tweaking is possible together with the default values
:param re_use_current_settings: Re-use the settings currently set. Defaults to False
It will regenerate a complete structure and apply the already set values if set to True
:return: All options available to the healthcheck
:rtype: dict

Setting all possible options first before tweaking them:

from ovs.extensions.generic.configuration import Configuration
from ovs.extensions.healthcheck.expose_to_cli import HealthCheckShared, HealthCheckCLIRunner
Configuration.set(HealthCheckShared.CONTEXT_SETTINGS_KEY, HealthCheckCLIRunner.generate_configuration_options())
JeffreyDevloo commented 6 years ago

Released in https://github.com/openvstorage/openvstorage-health-check/releases/tag/3.8.0 and https://github.com/openvstorage/openvstorage-health-check/releases/tag/3.4.9