54 Commits

Author SHA1 Message Date
Jiri Podivin
f1cd8eebc1 Validations show group filtering
The 'ValidationActions.group_information' method was refactored
to reflect new signature of the 'utils.parse_all_validations_on_disk' function.

Tests were adjusted accordingly.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Ic2ca556441169594792d7d5835ea057e9256a7a9
2021-08-09 16:06:12 +02:00
Gael Chamoulaud (Strider)
c46c90394c Add Products metadata key management
This patch adds the management of the new `products` metadata key in the
validation playbooks. We can now filter the validations by their groups,
by their categories or by their products while listing or running them.

The `list` sub command has now a new --product argument. When filtering
by groups, by categories or by products (see the example below), the
`list` sub command will return all the validation playbooks belonging to
the 'prep' group OR all the validation playbooks belonging to the 'os'
and/or 'system' categories OR all the validation playbooks to the
'tripleo' product:

$ validation list -h
$ validation list --group prep --category os,system --product tripleo

The `run` sub command has also its new --product argument. Note that
this new argument is mutually exclusive with the --validation, --group
and --category arguments:

$ validation run -h
$ validation run --product tripleo --inventory /etc/ansible/hosts

The `show parameter` sub command has the same new argument which is also
mutually exclusive with the --validation, --group and the --category
arguments:

$ validation show parameter -h
$ validation show parameter --product tripleo

Change-Id: Ief13e506c2bee18da47b31f1c2d5c0dbb1ad1ecf
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-07-27 07:01:05 +00:00
Gael Chamoulaud (Strider)
3928305329 Add Categories metadata key management
This patch adds the management of the new `categories` metadata key in
the validation playbooks. We can now filter the validations by their
groups and/or by their categories while listing or running them.

The `list` sub command has now a new --category argument. When filtering
by groups and by categories (see the example below), the `list` sub
command will return all the validation playbooks belonging to the prep
group OR all the validation playbooks belonging to the os and/or system
categories:

$ validation list -h
$ validation list --group prep --category os,system

The `run` sub command has also its new --category argument. Note that
this new argument is mutually exclusive with the --validation and
--group arguments:

$ validation run -h
$ validation run --category networking --inventory /etc/ansible/hosts

The `show parameter` sub command has the same new argument which is also
mutually exclusive with the --validation and --group arguments:

$ validation show parameter -h
$ validation show parameter --category os,system,hardware,ram

Change-Id: I4297f83355bdd209d21518fbadb17d1343fd4680
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-07-27 07:00:47 +00:00
Zuul
9a594f70c9 Merge "Remove convert_data function" 2021-07-16 03:27:39 +00:00
Gael Chamoulaud (Strider)
2f3b09d41e
Remove convert_data function
This patch removes the convert_data function which has been introduced
with the first one and deprecated Command Line Interface. The
--validation and --group arguments were sending comma-separated strings
instead of list. The new Command Line Interface is now enforcing this by
using its own CommaList Parser Action and only accepting List of groups
or validation names.

This function is now useless and can be removed safely. Tests and usages
have been modified accordingly.

Change-Id: Ief9459e914ea73fbd59a85c07a55c26078e0126a
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-07-13 22:14:19 +02:00
David J Peacock
e11b458946 add spinner to highlight progress
Implementing a Spinner class and utilizing it around a run action.  This
will add a moving icon that animates in place until output is reached,
letting the operator know that things are happening.

The interactive TTY test is included to ensure that during some unknown
usage such as logging to disk this feature doesn't spew unnecessary
clutter.

Change-Id: Ieef256a5c12b238008e9250c0ee182d80a2b6dfb
2021-07-13 11:14:41 -04:00
Zuul
84fe505f26 Merge "Expansion of logging for the list action" 2021-06-07 13:44:57 +00:00
Jiri Podivin
f2830c5244 Improved log path handling
Validations logging now has several documented fallbacks.
constants.py now includes constant default path,
in order to improve readability and provide reference.

Tests are included.

Complementary patch for validations_commons callbacks
is optional, as the behavior should stay largely the same.

Co-Authored-By: mbu <mat.bultel@gmail.com>
Change-Id: Iab5f246f22fa6998ea6cec578eec6ebb5de13ad4
2021-06-04 14:01:51 +02:00
Jiri Podivin
91c17107c5 Expansion of logging for the list action
Two new logging calls for the list action on the
info and debbug level.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I56044c93b03531159953c323f8e530d833819a5f
2021-06-03 08:39:23 +02:00
Zuul
eaf304f62e Merge "Refactoring of the cli show module" 2021-06-02 13:31:52 +00:00
Jiri Podivin
254d4472f0 Refactoring of the cli lister module
Removed unused imports.
Fixed up typos in help strings.
Replaced loop with list comprehesion in the `list_validations`
method of the `ValidationActions`.

Docstrings ammended to reflect actual state of the code.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Ie8deccf4c9c60872418a9c29da39f0d5baaad0bf
2021-06-01 17:04:44 +02:00
Jiri Podivin
b2e87ca49a Refactoring of the cli show module
New logging statements for the action and related
method call of 'ValidationActions' class.

Expanded exception handling for the 'show_validations_parameters'
method of the 'ValidationActions' class.

Removal of superfluous imports.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I2ad5a212dcd4cdb40ca04f7cce3d18c7527f63b2
2021-05-31 05:09:04 +00:00
Jiri Podivin
6bfdb04137 Retrieve n latest validation results
New optional parameter for the CLI limiting
number of validation results returned by history subcommand.

Resolves: rhbz#1944872

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Ie79062e85351ed545c33001866773bf38fdf8517
2021-05-07 12:37:55 +02:00
matbu
5fad1a4d18 Create dedicated CLI for the Validation Framework
This review adds a CLI for the Validation Framework which will become
the only entry point to run the Validation Framework.

It will deprecate the tripleo_validatior.py CLI and the
validation.py script.

This patch uses python cliff library to provide nice helpers, shell
and output formats.

Change-Id: I66800ad51cc50f4eb37efabe85fb553dce008101
2021-04-20 11:52:35 +02:00
matbu
d83be8b169 Expose ansible ssh_user variable to the run action
Change-Id: I6ae1f55ea261064b418e25cd4cf255f386a20fb3
2021-04-15 15:56:48 +02:00
Mathieu Bultel
6a2008950f Expose callback_whitelist option to Run action
The callback_whitelist is not usable via the Run action for now.
The patch allow users to pass  a list of callbacks to whitelist
during the validation run.

Altered docstrings to include changed type spec.

Change-Id: I37eb369701ccbd1d3fd4a7601a5e626d5867381d
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Signed-off-by: Mathieu Bultel <mat.bultel@gmail.com>
2021-03-21 12:30:47 +00:00
Zuul
c54307403a Merge "show command now properly uses list of validations" 2021-02-18 16:51:15 +00:00
Mathieu Bultel
618cde0569 Add skip list option in order to provide a black list for validation
Should be formed as:
{'xyz':
  {'hosts': 'ALL',
   'reason': None,
   'lp': None}
}

Change-Id: I030344ad3ec117548b78284cb4f12265a0719c3a
2021-02-17 16:36:41 +01:00
Jiri Podivin
f60caf8e66 show command now properly uses list of validations
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Iced465a7380acc2bd7065c1fc2dc34e6ddcd9b15
2021-02-15 14:03:55 +01:00
Jiri Podivin
45b8600a1a Secondary loop removed. params_only dict now uses update method.
Performance improvement is purely hypothetical.
However, the altered code is more readable.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Iaa85213a439ee4222c3d7fa6fc513458095b8ac3
2021-01-25 17:52:44 +01:00
Zuul
528c44b4e7 Merge "Local vars were redefining builtins" 2021-01-22 17:12:53 +00:00
Mathieu Bultel
a0db6e4892 Allow to provide different stdout callback to the libs
This patch depends on the callback modifcation which
allow to give other custom or default/standard callback
for the stdout from the user.

With the current situation, when passing another callback
than validation_json it breaks the VF logging.
We need to separate logging and stdout.

Change-Id: I1566d9763212f9538fea1c0885208db6b949023f
2021-01-18 07:53:19 +01:00
Jiri Podivin
8dc1549ddd Local vars were redefining builtins
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Iecdcae0be0d8363668f77f9de4f8a431a8162f5e
2021-01-14 12:54:39 +01:00
Mathieu Bultel
fd226ce290 Handle dynamically the ansible artifacts dir path
Change-Id: Ic28afceca1decc6f5bf3bdd5a2630c1a44138e5a
2020-12-11 13:13:19 +00:00
Gael Chamoulaud (Strider)
c1115710c7
Add Docstrings to validations_libs/validation_action.py file
Change-Id: I69fc8bc37ff0009e9bbc4d0fe32ea444174ca9e7
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-18 12:23:39 +01:00
Gael Chamoulaud (Strider)
484d7a9a78
Remove output format test in utils.get_validations_parameters
This is now done in validation_actions.show_validations_parameters(..)
[1].

[1] https://opendev.org/openstack/validations-libs/src/branch/master/validations_libs/validation_actions.py#L206-L209

Change-Id: I9f90ba97758422a35280b91e6d3edae624564728
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-09 14:11:12 +01:00
Gael Chamoulaud (Strider)
63e30c744c
Add better conversion of string parameters into a list
The current conversion works pretty well when passing a simple string
of validation or group names. But don't work when passing multiple
validation or group name.

```
>>> groups = "check-cpu"
>>> groups = [groups]
>>> print(groups)
['check-cpu']

>>> groups = "check-cpu,check-ram"
>>> groups = [groups]
>>> print(groups)
['check-cpu,check-ram']
```

This patch brings a better conversion when multiple validations or
groups are sent through a string.

Change-Id: Iba023a704dd873ea2df75c8cc6d78f929ef45bc2
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-04 14:05:11 +01:00
Gael Chamoulaud (Strider)
9192d5826c
Don't rely on parameter file extension for downloading
This patch also adds unittests and docstrings for the
show_validations_parameters method.

Change-Id: I7da1ef5607f6a7b164f87dace3a49a14e6cbf06f
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-04 09:48:08 +01:00
Cédric Jeanneret
6d0d1ce06d Ensure we're using proper types for validation_name and _id
In some case we might get string instead of list - instead of failing,
just do a simple convertion and go on.

We also support both notation, either playbook name (foo.yaml) and
validation name (foo) in the search of valid content.

Co-Authored-By: Gael Chamoulaud (Strider) <gchamoul@redhat.com>

Change-Id: I8d0288dae3cab131a8bc65e3d0b986dc6b9aec67
Closes-Bug: #1901676
2020-10-27 15:12:40 +01:00
Zuul
0c7eda82d3 Merge "Fix parameters management" 2020-10-26 12:46:02 +00:00
Gael Chamoulaud (Strider)
d79245eb82
Fix parameters management
This patch fixes multiple things:

* from validations_libs.validation_actions import show_validations_parameters

The generated file was containing the validations names and their
existing parameters as returned by the get_validations_parameters
method. But the file should only contains the parameters.

* from validations_libs.utils import get_validations_playbook

This method was supposed to get a list of validations playbooks
abs. path either by their names or their groups. This method was working
only when giving validation names but not with groups.

This patch fixes all the problems above and make the parameters
management work again.

Change-Id: Iec30cccade1234a127ef406ed13604cce45a72fd
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-10-22 17:26:40 +02:00
Gael Chamoulaud (Strider)
87114686ae
[Validator Run] Detect unknown validations from the command-line
When executing multiple validations with at least one unknown
validation, the CLI was executing only the existing ones but was not
informing the user that he/she typed one or more wrong validations.

This patch fixes that issue by detecting which validations are wrong and
inform the user.

Depends-On: https://review.opendev.org/758821

Change-Id: I4910043df07f32539793a2bc464377603fe2b02f
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-10-21 12:29:01 +02:00
Mathieu Bultel
0e46a5b710 Fix show validation stats with correct number
Change-Id: I48a09cac03bd5dea69e216babc7f4332ad47f52b
2020-10-13 16:05:55 +02:00
Mathieu Bultel
1ac91f1f31 Allow to set python interper for ansible execution
Some environment still use python2.7 and so /usr/bin/python
interpreter for ansible.
In that case, Ansible will fail to execute.
This option allow the user to pass a specific python interpeter
for the remote.
In None python_interpreter, and connection local is set we use
the local sys.executable, if both are None we use the default.

Change-Id: I4bd25ed50091a963d0b1e5e3a727ece19b90747e
2020-09-03 11:08:01 +02:00
Mathieu Bultel
15e74046c1 Add a way to override the default validation log path
Export a log path passed by the user in order to override the default
value from the callback

Change-Id: I736c527254cf17d25eeda0a4007102838280609c
2020-07-24 15:05:28 +02:00
Mathieu Bultel
21a722adac Show history by play and add get status action
Show history filtered by plays to get a better view
if a log file contains a lot of playbooks.

Add get_status action in order to get debug information
of a given validation failure

Change-Id: I29ab90647d9ef9c86546065ca16a62c401be1969
2020-07-06 15:10:37 +00:00
Mathieu Bultel
de03576eeb Remove playbook param from run_validation
Removing playbook parameters from run_validation function
since its overlap validation_name functionality and make it
confusing.

Change-Id: Ifff9bdb327b38db07df6cac328cbd387f2bc46f1
2020-06-17 11:56:04 +02:00
Mathieu Bultel
c1d9cb9b92 Filter get_all_log_file by extension
Since the user can provide a path to a directory which can
be polute by undesirable files, filter by extension can avoid
parsing wrong files

Change-Id: I378b32d58cd1ec3a5688bba0831716bf94f18f05
2020-06-12 09:19:41 +02:00
Mathieu Bultel
b5cc8dff75 Handle multiple validation logs results
Change-Id: I49d284edc2e1c54fb8c365e52146c656440b5db2
2020-05-18 14:53:52 +02:00
Zuul
6b2105c32d Merge "Add asynchronous option to validation libs" 2020-05-14 11:01:48 +00:00
Mathieu Bultel
ade5d57a3e Raise exception if no validation is found
In addition, I have to fix pep8 issue, due to new version

Change-Id: I04728bfdb6473c47c248a4a56bb8df647c51f5ef
2020-05-13 13:50:36 +02:00
Mathieu Bultel
6e1ab6f893 Add asynchronous option to validation libs
In order to run ansible on its own and get validations
progress and result with the CLI, the review adds an
option to run ansible asynchronously

Change-Id: Id884c9fd606ba03cb7d7fb02491582f1f88c3857
2020-05-05 16:24:34 +02:00
Mathieu Bultel
c0de9faa41 Format output in json or yaml for validations show param
Change-Id: I93b35cd1619e2c2b4a3b1294171dddf56033e94f
2020-04-16 08:26:04 +00:00
Mathieu Bultel
f85ec24e9c Use validation_path attribut instead of variables
Globalize usage of the validation_path attribut set by
the __init__ instead of playing with variables which
introduce bugs and wrong usage

Change-Id: Ie61b380762c911d120076d50551b4661f1ef1526
2020-04-16 10:24:02 +02:00
Zuul
7e27a0595e Merge "Declare playbooks for groups execution" 2020-04-16 07:32:05 +00:00
Mathieu Bultel
f3c29b6e56 Declare playbooks for groups execution
When running group validation, the playbooks list
is not set before so we need to fix that.

Change-Id: I964508a955783b5600618d4854efe67ff06298cb
2020-04-09 16:15:42 +02:00
Mathieu Bultel
88e0b0a212 Expose limit hosts option to the validation run actions
Change-Id: Ib8fdcb2d224dca0b07d87c41b4998cd9159778af
2020-04-09 10:03:44 +02:00
Mathieu Bultel
c940a0c30d Add unit tests coverage for validation, group and logs classes
Increase the unit tests coverage for recent code:
validation, group and logs classes.
(Increase of 54 unit tests)

Move per action files into one test file:
test_validation_actions

Change-Id: I7a1a8b0681c13ebd758a5686b2398a0a9e87a4eb
2020-04-02 09:41:30 +00:00
Mathieu Bultel
1daa430f9a Fix behavior for Show command to stick to tripleoclient
The behavior of the Show command wasn't exactly as tripleoclient
This review aims to fix it

Change-Id: I4e1af84675bfe722e232217f15c29fbc3d006333
2020-03-26 14:58:34 +01:00
Mathieu Bultel
c98ea9195a Add get validation playbook function and cleanup
Remove unsed function and add get validation playbook function

Change-Id: I5fbcbab7a402dd1149fa6df718f530a3ee5c6af2
2020-03-24 00:01:22 +01:00