Remove mistral when running the provide workflows

This change removes all of mistral from the provide workflows
by calling the new provide playbook.

Story: 2007212
Task: 38443
Task: 38446

Depends-On: Ic1cf39a29826b3828967e23a056884d867431062
Change-Id: If0184d3db5e49f6c3d302674ce7587ba27050a91
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-02-27 10:17:04 -06:00 committed by Steve Baker
parent 7e677b0c35
commit 026e98012a
6 changed files with 50 additions and 257 deletions

View File

@ -108,3 +108,9 @@ class TestDeployOvercloud(fakes.FakePlaybookExecution):
def setUp(self):
super(TestDeployOvercloud, self).setUp(ansible_mock=False)
self.rc_action_patcher = mock.patch(
'tripleo_common.actions.deployment.OvercloudRcAction',
autospec=True)
self.mock_rc_action = self.rc_action_patcher.start()
self.addCleanup(self.rc_action_patcher.stop)

View File

@ -145,11 +145,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
)
flatten.start()
self.addCleanup(flatten.stop)
self.rc_action_patcher = mock.patch(
'tripleo_common.actions.deployment.OvercloudRcAction',
autospec=True)
self.mock_rc_action = self.rc_action_patcher.start()
self.addCleanup(self.rc_action_patcher.stop)
# Mock playbook runner
playbook_runner = mock.patch(

View File

@ -26,7 +26,6 @@ from osc_lib import exceptions as oscexc
from osc_lib.tests import utils as test_utils
import yaml
from tripleoclient import constants
from tripleoclient import exceptions
from tripleoclient import plugin
from tripleoclient.tests import fakes as ooofakes
@ -370,22 +369,9 @@ class TestProvideNode(fakes.TestOvercloudNode):
def setUp(self):
super(TestProvideNode, self).setUp()
self.workflow = self.app.client_manager.workflow_engine
execution = mock.Mock()
execution.id = "IDID"
self.workflow.executions.create.return_value = execution
client = self.app.client_manager.tripleoclient
self.websocket = client.messaging_websocket()
# Get the command object to test
self.cmd = overcloud_node.ProvideNode(self.app, None)
self.websocket.wait_for_messages.return_value = iter([{
"status": "SUCCESS",
"message": "Success",
"execution_id": "IDID"
}])
def test_provide_all_manageable_nodes(self):
parsed_args = self.check_parser(self.cmd,
@ -393,11 +379,6 @@ class TestProvideNode(fakes.TestOvercloudNode):
[('all_manageable', True)])
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide_manageable_nodes',
workflow_input={}
)
def test_provide_one_node(self):
node_id = 'node_uuid1'
@ -406,11 +387,6 @@ class TestProvideNode(fakes.TestOvercloudNode):
[('node_uuids', [node_id])])
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide',
workflow_input={'node_uuids': [node_id]}
)
def test_provide_multiple_nodes(self):
node_id1 = 'node_uuid1'
node_id2 = 'node_uuid2'
@ -421,25 +397,6 @@ class TestProvideNode(fakes.TestOvercloudNode):
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide', workflow_input={
'node_uuids': [node_id1, node_id2]
}
)
def test_provide_no_node_or_flag_specified(self):
self.assertRaises(test_utils.ParserException,
self.check_parser,
self.cmd, [], [])
def test_provide_uuids_and_all_both_specified(self):
argslist = ['node_id1', 'node_id2', '--all-manageable']
verifylist = [('node_uuids', ['node_id1', 'node_id2']),
('all_manageable', True)]
self.assertRaises(test_utils.ParserException,
self.check_parser,
self.cmd, argslist, verifylist)
class TestCleanNode(fakes.TestOvercloudNode):
@ -457,44 +414,11 @@ class TestCleanNode(fakes.TestOvercloudNode):
self.cmd = overcloud_node.CleanNode(self.app, None)
def _check_clean_all_manageable(self, parsed_args, provide=False):
self.websocket.wait_for_messages.return_value = iter([{
"status": "SUCCESS",
"message": "Success",
"cleaned_nodes": {},
"execution_id": "IDID"
}] * 2)
self.cmd.take_action(parsed_args)
call_list = []
if provide:
call_list.append(mock.call(
'tripleo.baremetal.v1.provide_manageable_nodes',
workflow_input={}
))
self.workflow.executions.create.assert_has_calls(call_list)
def _check_clean_nodes(self, parsed_args, nodes, provide=False):
self.websocket.wait_for_messages.return_value = [{
"status": "SUCCESS",
"message": "Success",
"execution_id": "IDID"
}]
self.cmd.take_action(parsed_args)
call_list = []
if provide:
call_list.append(mock.call(
'tripleo.baremetal.v1.provide', workflow_input={
'node_uuids': nodes}
))
self.workflow.executions.create.assert_has_calls(call_list)
def test_clean_all_manageable_nodes_without_provide(self):
parsed_args = self.check_parser(self.cmd,
['--all-manageable'],
@ -638,32 +562,16 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
nodes_list[2]['ramdisk_id'] = (
'file://%s/SNB-x86_64/agent.ramdisk' % self.http_boot)
call_count = 0
call_list = []
if introspect:
self.mock_run_ansible_playbook.assert_called_with(
extra_vars={
'node_uuids': ['MOCK_NODE_UUID'],
'run_validations': False, 'concurrency': 20},
'node_uuids': ['MOCK_NODE_UUID']},
inventory='localhost,',
playbook='cli-baremetal-introspect.yaml',
playbook='cli-overcloud-node-provide.yaml',
playbook_dir='/usr/share/ansible/tripleo-playbooks',
workdir=mock.ANY,
)
if provide:
call_count += 1
call_list.append(mock.call(
'tripleo.baremetal.v1.provide', workflow_input={
'node_uuids': ['MOCK_NODE_UUID']
}
))
self.workflow.executions.create.assert_has_calls(call_list)
self.assertEqual(self.workflow.executions.create.call_count,
call_count)
def test_import_only(self):
argslist = [self.json_file.name]
verifylist = [('introspect', False),
@ -672,53 +580,6 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode):
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self._check_workflow_call(parsed_args)
def test_import_and_introspect(self):
parsed_args = self.check_parser(self.cmd,
[self.json_file.name,
'--introspect'],
[('introspect', True),
('provide', False)])
self.cmd.take_action(parsed_args)
self.mock_run_ansible_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': ['MOCK_NODE_UUID'],
'run_validations': False,
'concurrency': 20
}
)
def test_import_and_provide(self):
argslist = [self.json_file.name, '--provide']
verifylist = [('introspect', False),
('provide', True)]
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self._check_workflow_call(parsed_args, provide=True)
def test_import_and_introspect_and_provide(self):
parsed_args = self.check_parser(self.cmd,
[self.json_file.name,
'--introspect',
'--provide'],
[('introspect', True),
('provide', True)])
self.cmd.take_action(parsed_args)
self.mock_run_ansible_playbook.assert_called_once_with(
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': ['MOCK_NODE_UUID'],
'run_validations': False,
'concurrency': 20
}
)
def test_import_with_netboot(self):
arglist = [self.json_file.name, '--instance-boot-option', 'netboot']
verifylist = [('instance_boot_option', 'netboot')]

View File

@ -140,15 +140,13 @@ class TestImportNode(fakes.TestOvercloudNode):
[('introspect', True),
('provide', True)])
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
mock_playbook.assert_called_with(
workdir=mock.ANY,
playbook=mock.ANY,
inventory=mock.ANY,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': ['MOCK_NODE_UUID'],
'run_validations': False,
'concurrency': 20
'node_uuids': ['MOCK_NODE_UUID']
}
)
@ -223,15 +221,13 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
[('all_manageable', True),
('provide', True)])
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
mock_playbook.assert_called_with(
workdir=mock.ANY,
playbook='cli-baremetal-introspect.yaml',
playbook='cli-overcloud-node-provide.yaml',
inventory=mock.ANY,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': [],
'run_validations': False,
'concurrency': 20
'node_uuids': []
}
)
@ -265,15 +261,13 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
[('node_uuids', nodes),
('provide', True)])
self.cmd.take_action(parsed_args)
mock_playbook.assert_called_once_with(
mock_playbook.assert_called_with(
workdir=mock.ANY,
playbook='cli-baremetal-introspect.yaml',
playbook='cli-overcloud-node-provide.yaml',
inventory=mock.ANY,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': nodes,
'run_validations': False,
'concurrency': 20
'node_uuids': nodes
}
)

View File

@ -14,7 +14,6 @@
import mock
from tripleoclient import exceptions
from tripleoclient.tests import fakes
from tripleoclient.workflows import baremetal
@ -62,34 +61,8 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
), [mock.ANY])
def test_provide_success(self):
self.websocket.wait_for_messages.return_value = self.message_success
baremetal.provide(self.app.client_manager, node_uuids=[])
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide',
workflow_input={
'node_uuids': [],
})
def test_provide_error(self):
self.websocket.wait_for_messages.return_value = self.message_failed
self.assertRaises(
exceptions.NodeProvideError,
baremetal.provide,
self.app.client_manager,
node_uuids=[]
)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide',
workflow_input={
'node_uuids': [],
})
def test_format_errors(self):
payload = {'message': [{'result': 'Error1a\nError1b'},
{'result': 'Error2a\nError2b\n'}]}
@ -97,21 +70,6 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
error_string = baremetal._format_errors(payload)
self.assertEqual(error_string, "Error1b\nError2b")
def test_provide_error_with_format_message(self):
self.websocket.wait_for_messages.return_value = iter([{
"execution_id": "IDID",
"status": "FAIL",
"message": ['Error1', 'Error2']
}])
self.assertRaises(
exceptions.NodeProvideError,
baremetal.provide,
self.app.client_manager,
node_uuids=[]
)
def test_introspect_success(self):
baremetal.introspect(self.app.client_manager, node_uuids=[],
run_validations=True, concurrency=20)
@ -122,18 +80,10 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
)
def test_provide_manageable_nodes_success(self):
self.websocket.wait_for_messages.return_value = self.message_success
baremetal.provide_manageable_nodes(
self.app.client_manager
)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.provide_manageable_nodes',
workflow_input={}
)
def test_configure_success(self):
baremetal.configure(self.app.client_manager, node_uuids=[])

View File

@ -115,33 +115,47 @@ def _format_errors(payload):
return '\n'.join(errors)
def provide(clients, **workflow_input):
def provide(clients, node_uuids):
"""Provide Baremetal Nodes
Run the tripleo.baremetal.v1.provide Mistral workflow.
:param clients: Application client object.
:type clients: Object
:param node_uuids: List of instance UUID(s).
:type node_uuids: List
"""
workflow_client = clients.workflow_engine
tripleoclients = clients.tripleoclient
with tripleoclients.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.provide',
workflow_input={'node_uuids': workflow_input['node_uuids']}
with utils.TempDirs() as tmp:
utils.run_ansible_playbook(
playbook='cli-overcloud-node-provide.yaml',
inventory='localhost,',
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': node_uuids
}
)
for payload in base.wait_for_messages(workflow_client, ws, execution):
if 'message' in payload:
print(payload['message'])
print('Successfully provided nodes: {}'.format(node_uuids))
if payload['status'] != 'SUCCESS':
try:
message = _format_errors(payload)
except Exception:
message = 'Failed.'
raise exceptions.NodeProvideError(
'Failed to set nodes to available state: {}'.format(message))
def provide_manageable_nodes(clients):
"""Provide all manageable Nodes
:param clients: Application client object.
:type clients: Object
:param node_uuids: List of instance UUID(s).
:type node_uuids: List
"""
provide(
clients,
node_uuids=[
i.uuid for i in clients.baremetal.node.list()
if i.provision_state == "manageable" and not i.maintenance
]
)
def introspect(clients, node_uuids, run_validations, concurrency):
@ -183,33 +197,6 @@ def introspect_manageable_nodes(clients, run_validations, concurrency):
)
def provide_manageable_nodes(clients, **workflow_input):
"""Provide all manageable Nodes
Run the tripleo.baremetal.v1.provide_manageable_nodes Mistral workflow.
"""
workflow_client = clients.workflow_engine
tripleoclients = clients.tripleoclient
with tripleoclients.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.provide_manageable_nodes',
workflow_input=workflow_input
)
for payload in base.wait_for_messages(workflow_client, ws, execution):
if 'message' in payload:
print(payload['message'])
if payload['status'] != 'SUCCESS':
raise exceptions.NodeProvideError(
'Exception providing nodes:{}'.format(payload['message']))
print(payload['message'])
def configure(clients, node_uuids, kernel_name='bm-deploy-kernel',
ramdisk_name='bm-deploy-ramdisk', instance_boot_option=None,
root_device=None, root_device_minimum_size=4,