29 Commits

Author SHA1 Message Date
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
Mathieu Bultel
e367d62445 Implement validation show history command
Implement validation show history command in validation_actions

Change-Id: I97c9df5e08c2358612704fcdb78cf24cd6f8e421
2020-03-23 22:16:07 +00:00
Mathieu Bultel
bcd72301f6 Add validation log object representation
Create two classes for Log and Logs in order to get
a simpler representation of the validation Log and
provide easy way to manage the log data informations

Change-Id: I743355cef943e43492264d4c4700bebbeab9a37d
2020-03-23 21:54:21 +00:00
Mathieu Bultel
fd95a175b7 Implement Validation Show Parameters
Change-Id: Ie3366f4f32dd87871315cc9f95f7c2335df25e4b
2020-03-20 13:45:12 +00:00
Mathieu Bultel
491a27b53c Add validation_actions class and group info implementation
Move all validation actions into a ValidationActions class
in order to have one object with several validations actions

Add group info implementation
And add group object like validation object to have
a simpler representation of the validation group.

Change-Id: Idc7a55e26de20968f0a6a90f2a005d21a30c9e70
2020-03-20 13:44:53 +00:00