From f10fa0b3c5f1d5e1b7282c0c29175138eaabe126 Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Wed, 3 Jul 2019 11:52:33 +0200 Subject: [PATCH] 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 --- ...g-Ansible-by-default-2dac0dfd9c7a4690.yaml | 8 ++++++ tripleoclient/v1/tripleo_validator.py | 25 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/Allow-running-validations-by-name-using-Ansible-by-default-2dac0dfd9c7a4690.yaml 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])