From c6616f8d96013bd5f5ccfec54e3eb2b37fd7884b Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Wed, 6 Nov 2019 13:56:23 +0100 Subject: [PATCH] Drop Mistral support for the Validations CLI This patch removes the possibility to run the validations through the CLI with Mistral. Ansible is now the only way to run the validations. Change-Id: I8bd9f4c4512279a291963d0b6df62316e7410f2b Signed-off-by: Gael Chamoulaud --- ..._the_validations_CLI-081bc5cd6e7db056.yaml | 5 ++ .../v1/tripleo/test_tripleo_validator.py | 22 ------- .../tests/workflows/test_validations.py | 59 ------------------- tripleoclient/v1/tripleo_validator.py | 50 +--------------- tripleoclient/workflows/validations.py | 46 --------------- 5 files changed, 6 insertions(+), 176 deletions(-) create mode 100644 releasenotes/notes/drop_mistral_support_for_the_validations_CLI-081bc5cd6e7db056.yaml delete mode 100644 tripleoclient/tests/workflows/test_validations.py delete mode 100644 tripleoclient/workflows/validations.py diff --git a/releasenotes/notes/drop_mistral_support_for_the_validations_CLI-081bc5cd6e7db056.yaml b/releasenotes/notes/drop_mistral_support_for_the_validations_CLI-081bc5cd6e7db056.yaml new file mode 100644 index 000000000..fe7fe0757 --- /dev/null +++ b/releasenotes/notes/drop_mistral_support_for_the_validations_CLI-081bc5cd6e7db056.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + The TripleO Validator CLI doesn't support Mistral anymore for listing and + running the Validations. Ansible is now the way to run them. diff --git a/tripleoclient/tests/v1/tripleo/test_tripleo_validator.py b/tripleoclient/tests/v1/tripleo/test_tripleo_validator.py index 14f0e0261..7522a2afe 100644 --- a/tripleoclient/tests/v1/tripleo/test_tripleo_validator.py +++ b/tripleoclient/tests/v1/tripleo/test_tripleo_validator.py @@ -60,28 +60,6 @@ class TestValidatorRun(utils.TestCommand): # Get the command object to test self.cmd = tripleo_validator.TripleOValidatorRun(self.app, None) - self.app.client_manager.workflow_engine = mock.Mock() - self.workflow = self.app.client_manager.workflow_engine - - @mock.patch('tripleoclient.workflows.validations.run_validations', - autospec=True) - def test_validation_run_with_mistral(self, plan_mock): - arglist = [ - '--use-mistral', - '--validation-name', - 'check-ftype' - ] - verifylist = [] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - self.cmd.take_action(parsed_args) - plan_mock.assert_called_once_with( - mock.ANY, { - 'plan': 'overcloud', - 'validation_names': ['check-ftype'], - 'validation_inputs': {} - }) @mock.patch('sys.exit') @mock.patch('logging.getLogger') diff --git a/tripleoclient/tests/workflows/test_validations.py b/tripleoclient/tests/workflows/test_validations.py deleted file mode 100644 index 9bedaa2db..000000000 --- a/tripleoclient/tests/workflows/test_validations.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2017 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import mock - -from osc_lib.tests import utils -from tripleoclient.workflows import validations - - -class TestValidationsRun(utils.TestCommand): - - def setUp(self): - super(TestValidationsRun, self).setUp() - self.app.client_manager = mock.Mock() - self.app.client_manager.workflow_engine = self.workflow = mock.Mock() - self.tripleoclient = mock.Mock() - self.websocket = mock.Mock() - self.websocket.__enter__ = lambda s: self.websocket - self.websocket.__exit__ = lambda s, *exc: None - self.tripleoclient.messaging_websocket.return_value = self.websocket - self.app.client_manager.tripleoclient = self.tripleoclient - - @mock.patch('tripleoclient.workflows.base.wait_for_messages') - @mock.patch('tripleoclient.workflows.base.start_workflow') - def test_run_validations_group(self, start_wf_mock, messages_mock): - messages_mock.return_value = [] - fetch_name = 'tripleo.validations.v1.run_groups' - fetch_input = { - 'group_names': ['pre-deployment'] - } - validations.run_validations(self.app.client_manager, fetch_input) - start_wf_mock.assert_called_once_with(self.workflow, - fetch_name, - workflow_input=fetch_input) - - @mock.patch('tripleoclient.workflows.base.wait_for_messages') - @mock.patch('tripleoclient.workflows.base.start_workflow') - def test_run_validations(self, start_wf_mock, messages_mock): - messages_mock.return_value = [] - fetch_name = 'tripleo.validations.v1.run_validations' - fetch_input = { - 'validation_names': ['check-ftype'] - } - validations.run_validations(self.app.client_manager, fetch_input) - start_wf_mock.assert_called_once_with(self.workflow, - fetch_name, - workflow_input=fetch_input) diff --git a/tripleoclient/v1/tripleo_validator.py b/tripleoclient/v1/tripleo_validator.py index 5d7b6b8aa..931c03b2b 100644 --- a/tripleoclient/v1/tripleo_validator.py +++ b/tripleoclient/v1/tripleo_validator.py @@ -27,7 +27,6 @@ from osc_lib.i18n import _ from tripleoclient import constants from tripleoclient import utils as oooutils -from tripleoclient.workflows import validations LOG = logging.getLogger(__name__ + ".TripleoValidator") @@ -203,13 +202,6 @@ class TripleOValidatorRun(command.Command): help=_("Execute the validations using a custom plan name") ) - parser.add_argument( - '--use-mistral', - action='store_true', - default=False, - help=_("Execute the validations using Mistral") - ) - parser.add_argument( '--workers', '-w', metavar='N', @@ -273,43 +265,6 @@ class TripleOValidatorRun(command.Command): return parser - def _run_validation_run_with_mistral(self, parsed_args): - clients = self.app.client_manager - LOG = logging.getLogger(__name__ + ".ValidationsRunWithMistral") - extra_vars_input = {} - - if parsed_args.extra_vars: - extra_vars_input = parsed_args.extra_vars - - if parsed_args.extra_vars_file: - try: - with open(parsed_args.extra_vars_file, 'r') as vars_file: - extra_vars_input = json.load(vars_file) - except ValueError as e: - raise RuntimeError( - 'Error occured while decoding extra vars JSON file: %s' % - e) - - if not parsed_args.validation_name: - workflow_input = { - "plan": parsed_args.plan, - "group_names": parsed_args.group - } - else: - workflow_input = { - "plan": parsed_args.plan, - "validation_names": parsed_args.validation_name, - "validation_inputs": extra_vars_input - } - - LOG.debug(_('Running the validations with Mistral')) - output = validations.run_validations(clients, workflow_input) - for out in output: - print('[{}] - {}\n{}'.format( - out.get('status'), - out.get('validation_name'), - oooutils.indent(out.get('stdout')))) - def _run_ansible(self, logger, plan, workdir, log_path_dir, playbook, inventory, retries, output_callback, extra_vars, python_interpreter, gathering_policy): @@ -403,7 +358,4 @@ class TripleOValidatorRun(command.Command): sys.exit(0) def take_action(self, parsed_args): - if parsed_args.use_mistral: - self._run_validation_run_with_mistral(parsed_args) - else: - self._run_validator_run(parsed_args) + self._run_validator_run(parsed_args) diff --git a/tripleoclient/workflows/validations.py b/tripleoclient/workflows/validations.py deleted file mode 100644 index 476e344c1..000000000 --- a/tripleoclient/workflows/validations.py +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2019 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -from tripleoclient.workflows import base - - -def run_validations(clients, workflow_input): - - workflow_client = clients.workflow_engine - tripleoclients = clients.tripleoclient - results = [] - - with tripleoclients.messaging_websocket() as ws: - - if 'group_names' in workflow_input: - print('Running group validations') - execution = base.start_workflow( - workflow_client, - 'tripleo.validations.v1.run_groups', - workflow_input=workflow_input - ) - else: - print('Running single validations') - execution = base.start_workflow( - workflow_client, - 'tripleo.validations.v1.run_validations', - workflow_input=workflow_input - ) - - for payload in base.wait_for_messages(workflow_client, ws, execution): - if payload.get('message') is None: - if payload.get('status') in ['SUCCESS', 'FAILED']: - results.append(payload) - - return results