98 Commits

Author SHA1 Message Date
Zuul
c21673ae16 Merge "Removed unnecessary second check." 2021-02-24 13:39:06 +00:00
Zuul
c54307403a Merge "show command now properly uses list of validations" 2021-02-18 16:51:15 +00:00
Zuul
58c757cdee Merge "Add skip list option in order to provide a black list for validation" 2021-02-18 09:03:46 +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
Zuul
ee8e9ec7d9 Merge "One of the two nested calls of os.path.join was redundant." 2021-02-16 22:32:05 +00: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
Zuul
e4eaf3fda1 Merge "Add new test for the parse_all_validations_on_disk" 2021-02-03 12:59:31 +00:00
Zuul
f47226349a Merge "OrderedDict can be constructed directly from dict instance" 2021-02-02 23:40:25 +00:00
Zuul
448be63525 Merge "Secondary loop removed. params_only dict now uses update method." 2021-02-02 23:40:12 +00:00
Owen McGonagle
aa54ac2c6f Add new test for the parse_all_validations_on_disk
Add a new test to raise exeception if you have no groups in your playbook.

Co-authored-by: Daniel Bengtsson <dbengt@redhat.com>
Change-Id: I984304ec22511709370e36f4b4fb6a43100b043c
2021-02-02 11:44:01 -05:00
Owen McGonagle
e21f6f11f8 Add an error message when groups is not found in the playbook
If there are no groups in the playbook, we currently get a python error
when running command 'openstack tripleo validator group info'

Change-Id: Ice089c33d566e90bea55e18fe7f77f9d33fe81f3
2021-01-27 13:20:38 -05:00
Jiri Podivin
c29636eab5 One of the two nested calls of os.path.join was redundant.
os.path.join can accept arbitrary number of path likes,
nesting the calls is therefore unnecessary.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I19010de832b2dd0b7f1b4940c9f770929d041053
2021-01-27 17:38:56 +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
Jiri Podivin
4b9dff2671 OrderedDict can be constructed directly from dict instance
Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I7a49a8e4cc45076de090d979eabc4fef7fb0f043
2021-01-22 15:36:25 +01:00
Jiri Podivin
9dd1fcaff5 Removed unnecessary second check.
The condition checking existence ansible_artifact_path was redundant.
Similar, but more comprehensive, check is performed previously in the method,
along with missing path resolution.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Icf5de856ddbc877dfdd19354b102197fefe40eec
2021-01-19 16:55:26 +01: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
Gael Chamoulaud (Strider)
276c20d88c
Fix typo in validations_libs/ansible.py
s/validagions-libs-ansible/validations-libs-ansible/

Change-Id: Id8f9b8f85a7bed0f39c81650eceea0334dc5d816
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2021-01-04 09:19:51 +01:00
Mathieu Bultel
87e4917f1b Move ansible-runner version to 1.4.0
Upstream requirements in stable/train is under ansible-runner 1.4.0.
This patch move the version to 1.4.0 according to openstack/requirements.
It changes the backward compat version according to this version in
validations_libs/ansible.py

Change-Id: I311d077c13a7d95314eb83072f5652646fef1bf8
2020-12-17 10:52:18 +01:00
Zuul
e9fe6b5b1b Merge "Bump pre-commit-hooks to v3.3.0" 2020-12-16 19:13:35 +00: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)
99071ee1c8
Bump pre-commit-hooks to v3.3.0
This patch also uses pycqa/flake8 instead of the default one proposed by
pre-commit and which is deprecated.

Change-Id: Iba243abc1ec01912edb4b3645f8ccce95e0f2e88
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-26 12:42:21 +01:00
Mathieu Bultel
0641b17a5a Handle unreachable case in the log statistics
The unreachable status is a fail state that should be treat.

Change-Id: Ia610448421196572909567deb144d9a490be27a0
2020-11-26 10:43:27 +01:00
Gael Chamoulaud (Strider)
be5a95d4e0
Add Docstrings to validations_libs/ansible.py file
Change-Id: I97ed9705ba4e8678609af661c704e957aa907872
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-18 12:24:25 +01:00
Gael Chamoulaud (Strider)
9f644f0dd7
Add Docstrings to validations_libs/validations_logs.py file
This patch also adds new unittests.

Change-Id: I6f299db1b22d98fdabc148e297098e023cf863bd
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-18 12:24:06 +01: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)
10e9a19f22
Add Docstrings to validations_libs/group.py file
Change-Id: I857a54eb2b42acbcad19f3b16b1aa9e6922dc1b9
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-18 12:21:28 +01:00
Gael Chamoulaud (Strider)
eb62054a33
Enforce the way we encapsulate a Validation
This patch ensures that the playbook is respecting the minimal structure
of a validation. This patch also adds DocStrings to the Validation class
and new unittests according to the enforcement changes.

Change-Id: I0809163cbd661cbd24705ed348281c7818a944b4
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-13 09:35:50 +01:00
Gael Chamoulaud (Strider)
a6271afa38
Add docstrings to utils.py
This patch also adds new unittests for the following functions:
- from validations_libs.utils import get_validations_data
  > test_get_validations_data_wrong_type(..)
- from validations_libs.utils import get_validations_details
  > test_get_validations_details_wrong_type(..)

Change-Id: Iac9ba971a73ed09b26d3e41efb38ad72dd942bbc
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
2020-11-09 15:03:08 +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
Zuul
96cf2f27c2 Merge "Fix show validation stats with correct number" 2020-10-19 13:03:44 +00:00
Mathieu Bultel
cba2ce087d Add parameters values to the validation show command
The parameters was missing to the validation show output.

Change-Id: I1d2ebeb3fbe8a1438e8acec77d3a15b2816f786f
2020-10-14 07:47:09 +02:00
Mathieu Bultel
0e46a5b710 Fix show validation stats with correct number
Change-Id: I48a09cac03bd5dea69e216babc7f4332ad47f52b
2020-10-13 16:05:55 +02:00
Zuul
20b0b65c6d Merge "Update validation path with the share/ansible one" 2020-09-08 09:21:22 +00: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
f22d380319 Update validation path with the share/ansible one
Depends-On: https://review.opendev.org/#/c/747761/
Change-Id: Ib612436e6c934fecee58137ed660a43dc5656ced
2020-08-25 10:33:02 +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
Zuul
34b562cde1 Merge "Remove playbook param from run_validation" 2020-07-01 11:10:21 +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
a842d333fc Add base_dir param to override the constants value easily
In order to override the constants base dir value easily
for ansible, the base_dir param can be passed to the run
function

Change-Id: I8727ac442cd1bb08b1c8587e3e9e8d9be1def358
2020-06-16 23:52:25 +02:00
Zuul
e1caff945f Merge "Filter get_all_log_file by extension" 2020-06-15 20:16:02 +00: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