diff --git a/releasenotes/notes/Allow-running-validations-by-name-using-Ansible-by-default-2dac0dfd9c7a4690.yaml b/releasenotes/notes/Allow-running-validations-by-name-using-Ansible-by-default-2dac0dfd9c7a4690.yaml new file mode 100644 index 000000000..9c2b6328d --- /dev/null +++ b/releasenotes/notes/Allow-running-validations-by-name-using-Ansible-by-default-2dac0dfd9c7a4690.yaml @@ -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``. + diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index ef589babd..de79ed717 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -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])