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 <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2019-11-06 13:56:23 +01:00
parent db6aa7b4f3
commit c6616f8d96
No known key found for this signature in database
GPG Key ID: 00776A4BA7F4B301
5 changed files with 6 additions and 176 deletions

View File

@ -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.

View File

@ -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')

View File

@ -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)

View File

@ -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)

View File

@ -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