Allow running validations by group using Ansible by default

This patch allows the operator to run all the validations belonging to
a group using ansible-playbook instead of Mistral.

Change-Id: I8c833819c88f1822bf605df0c997ab5d651e7620
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2019-07-03 11:52:33 +02:00
parent 27e1e4f833
commit f10fa0b3c5
2 changed files with 29 additions and 4 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
The validations can now be performed by calling Mistral or by calling
``ansible-playbook``. By default, the latter is used. The new ``--use-mistral``
option allows to execute either groups or a set of specific validations by
calling Mistral instead of using the default mechanism, ie. ``ansible-playbook``.

View File

@ -168,8 +168,9 @@ class TripleOValidatorRun(command.Command):
def _run_validator_run(self, parsed_args):
clients = self.app.client_manager
LOG = logging.getLogger(__name__ + ".ValidationsRun")
playbooks = []
if parsed_args.use_mistral or parsed_args.group:
if parsed_args.use_mistral:
if not parsed_args.validation_name:
workflow_input = {
"plan": parsed_args.plan,
@ -189,9 +190,25 @@ class TripleOValidatorRun(command.Command):
out.get('validation_name'),
oooutils.indent(out.get('stdout'))))
else:
playbooks = []
for pb in parsed_args.validation_name:
playbooks.append(pb + '.yaml')
if parsed_args.group:
workflow_input = {
"group_names": parsed_args.group
}
LOG.debug(_('Getting the validations list by group'))
try:
output = validations.list_validations(
clients, workflow_input)
for val in output:
playbooks.append(val.get('id') + '.yaml')
except Exception as e:
print(
_("Validations listing by group finished with errors"))
print('Output: {}'.format(e))
else:
for pb in parsed_args.validation_name:
playbooks.append(pb + '.yaml')
python_interpreter = \
"/usr/bin/python{}".format(sys.version_info[0])