summaryrefslogtreecommitdiff
path: root/ironic/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-14 16:00:19 +0000
committerGerrit Code Review <review@openstack.org>2019-03-14 16:00:20 +0000
commitb2a48fab364f9cd2da2d3cd883f672917c86ee74 (patch)
tree1ad2104c8b49b0d0ad8240c5fbaa9bace8d2a815 /ironic/tests
parent89ac1d4ec007c15e870ff91aa3c2b4e0df025804 (diff)
parent80e762e18a33679470798836ba4cc6c14bf754f8 (diff)
downloadironic-b2a48fab364f9cd2da2d3cd883f672917c86ee74.tar.gz
Merge "Adding ansible python interpreter as driver_info"
Diffstat (limited to 'ironic/tests')
-rw-r--r--ironic/tests/unit/drivers/modules/ansible/test_deploy.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/ironic/tests/unit/drivers/modules/ansible/test_deploy.py b/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
index c9f0e455f..d4a8da617 100644
--- a/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
+++ b/ironic/tests/unit/drivers/modules/ansible/test_deploy.py
@@ -191,6 +191,35 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
"ironic": {"foo": "bar"}},
json.loads(all_vars))
+ @mock.patch.object(com_utils, 'execute', return_value=('out', 'err'),
+ autospec=True)
+ def test__run_playbook_ansible_interpreter_override(self, execute_mock):
+ self.config(group='ansible', playbooks_path='/path/to/playbooks')
+ self.config(group='ansible', config_file_path='/path/to/config')
+ self.config(group='ansible', verbosity=3)
+ self.config(group='ansible',
+ default_python_interpreter='/usr/bin/python3')
+ self.config(group='ansible', ansible_extra_args='--timeout=100')
+ self.node.driver_info['ansible_python_interpreter'] = (
+ '/usr/bin/python4')
+ extra_vars = {'foo': 'bar'}
+
+ ansible_deploy._run_playbook(self.node, 'deploy',
+ extra_vars, '/path/to/key',
+ tags=['spam'], notags=['ham'])
+
+ execute_mock.assert_called_once_with(
+ 'env', 'ANSIBLE_CONFIG=/path/to/config',
+ 'ansible-playbook', '/path/to/playbooks/deploy', '-i',
+ '/path/to/playbooks/inventory', '-e',
+ mock.ANY, '--tags=spam', '--skip-tags=ham',
+ '--private-key=/path/to/key', '-vvv', '--timeout=100')
+
+ all_vars = execute_mock.call_args[0][7]
+ self.assertEqual({"ansible_python_interpreter": "/usr/bin/python4",
+ "ironic": {"foo": "bar"}},
+ json.loads(all_vars))
+
@mock.patch.object(com_utils, 'execute',
side_effect=processutils.ProcessExecutionError(
description='VIKINGS!'),
@@ -286,6 +315,16 @@ class TestAnsibleMethods(AnsibleDeployTestCaseBase):
self.assertEqual(2, ansible_deploy._calculate_memory_req(task))
image_mock.assert_called_once_with(task.context, 'fake-image')
+ def test__get_python_interpreter(self):
+ self.config(group='ansible',
+ default_python_interpreter='/usr/bin/python3')
+ self.node.driver_info['ansible_python_interpreter'] = (
+ '/usr/bin/python4')
+
+ python_interpreter = ansible_deploy._get_python_interpreter(self.node)
+
+ self.assertEqual('/usr/bin/python4', python_interpreter)
+
def test__get_configdrive_path(self):
self.config(tempdir='/path/to/tmpdir')
self.assertEqual('/path/to/tmpdir/spam.cndrive',