Expose callback_whitelist option to Run action
The callback_whitelist is not usable via the Run action for now. The patch allow users to pass a list of callbacks to whitelist during the validation run. Altered docstrings to include changed type spec. Change-Id: I37eb369701ccbd1d3fd4a7601a5e626d5867381d Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Signed-off-by: Mathieu Bultel <mat.bultel@gmail.com>
This commit is contained in:
parent
0131dcc00d
commit
6a2008950f
|
@ -339,7 +339,7 @@ class Ansible(object):
|
|||
:param callback_whitelist: Comma separated list of callback plugins.
|
||||
Custom output_callback is also whitelisted.
|
||||
(Defaults to ``None``)
|
||||
:type callback_whitelist: ``string``
|
||||
:type callback_whitelist: ``list`` or ``string``
|
||||
:param ansible_cfg: Path to an ansible configuration file. One will be
|
||||
generated in the artifact path if this option is None.
|
||||
:type ansible_cfg: ``string``
|
||||
|
@ -389,6 +389,9 @@ class Ansible(object):
|
|||
env = {}
|
||||
env = os.environ.copy()
|
||||
extravars = self._get_extra_vars(extra_vars)
|
||||
|
||||
if isinstance(callback_whitelist, list):
|
||||
callback_whitelist = ','.join(callback_whitelist)
|
||||
callback_whitelist, output_callback = self._callbacks(
|
||||
callback_whitelist,
|
||||
output_callback,
|
||||
|
|
|
@ -45,9 +45,11 @@ class TestValidationActions(TestCase):
|
|||
'My Validation Two Name',
|
||||
['prep', 'pre-introspection'])]))
|
||||
|
||||
@mock.patch('validations_libs.utils.create_artifacts_dir',
|
||||
return_value=('1234', '/tmp/'))
|
||||
@mock.patch('validations_libs.utils.get_validations_playbook',
|
||||
return_value=['/tmp/foo/fake.yaml'])
|
||||
def test_validation_skip_validation(self, mock_validation_play):
|
||||
def test_validation_skip_validation(self, mock_validation_play, mock_tmp):
|
||||
|
||||
playbook = ['fake.yaml']
|
||||
inventory = 'tmp/inventory.yaml'
|
||||
|
@ -80,6 +82,7 @@ class TestValidationActions(TestCase):
|
|||
'parallel_run': True,
|
||||
'inventory': 'tmp/inventory.yaml',
|
||||
'output_callback': 'validation_stdout',
|
||||
'callback_whitelist': None,
|
||||
'quiet': True,
|
||||
'extra_vars': None,
|
||||
'limit_hosts': '!cloud1',
|
||||
|
@ -104,7 +107,8 @@ class TestValidationActions(TestCase):
|
|||
run_return = run.run_validations(playbook, inventory,
|
||||
validations_dir='/tmp/foo',
|
||||
skip_list=skip_list,
|
||||
limit_hosts=None)
|
||||
limit_hosts='!cloud1',
|
||||
)
|
||||
mock_ansible_run.assert_called_with(**run_called_args)
|
||||
|
||||
@mock.patch('validations_libs.utils.get_validations_playbook',
|
||||
|
@ -123,13 +127,14 @@ class TestValidationActions(TestCase):
|
|||
'parallel_run': True,
|
||||
'inventory': 'tmp/inventory.yaml',
|
||||
'output_callback': 'validation_stdout',
|
||||
'callback_whitelist': None,
|
||||
'quiet': True,
|
||||
'extra_vars': None,
|
||||
'limit_hosts': '!cloud1,cloud,!cloud2',
|
||||
'ansible_artifact_path': '/tmp/',
|
||||
'extra_env_variables': None,
|
||||
'ansible_cfg': None,
|
||||
'gathering_policy': 'explicit',
|
||||
'ansible_artifact_path': '/tmp/',
|
||||
'log_path': None,
|
||||
'run_async': False,
|
||||
'python_interpreter': None
|
||||
|
|
|
@ -210,8 +210,9 @@ class ValidationActions(object):
|
|||
workdir=None, limit_hosts=None, run_async=False,
|
||||
base_dir=constants.DEFAULT_VALIDATIONS_BASEDIR,
|
||||
log_path=None, python_interpreter=None,
|
||||
output_callback='validation_stdout',
|
||||
skip_list=None):
|
||||
skip_list=None,
|
||||
callback_whitelist=None,
|
||||
output_callback='validation_stdout'):
|
||||
"""Run one or multiple validations by name(s) or by group(s)
|
||||
|
||||
:param validation_name: A list of validation names
|
||||
|
@ -254,6 +255,10 @@ class ValidationActions(object):
|
|||
``auto_silent`` or the default one
|
||||
``auto_legacy``)
|
||||
:type python_interpreter: ``string``
|
||||
:param callback_whitelist: Comma separated list of callback plugins.
|
||||
Custom output_callback is also whitelisted.
|
||||
(Defaults to ``None``)
|
||||
:type callback_whitelist: ``list`` or ``string``
|
||||
:param output_callback: The Callback plugin to use.
|
||||
(Defaults to 'validation_stdout')
|
||||
:type output_callback: ``string``
|
||||
|
@ -346,6 +351,7 @@ class ValidationActions(object):
|
|||
parallel_run=True,
|
||||
inventory=inventory,
|
||||
output_callback=output_callback,
|
||||
callback_whitelist=callback_whitelist,
|
||||
quiet=quiet,
|
||||
extra_vars=extra_vars,
|
||||
limit_hosts=_hosts,
|
||||
|
|
Loading…
Reference in New Issue