Remove mistral from the bios_configuration workflows

This change removes all of mistral from the reset_bios_configuration and
apply_bios_settings workflows by calling the new raid playbooks.

Story: 2007212
Task: 38455
Task: 38456
Task: 38453
Task: 38454

Depends-On: I444ead2df7621fd11e336306e817dc1d28a04e72
Change-Id: I454c5330722f79075a3d9cf5fdf8bff80f7cc5ad
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2020-02-25 17:02:34 -06:00 committed by Kevin Carter (cloudnull)
parent 6d56817524
commit 4e5a4af642
2 changed files with 60 additions and 179 deletions

View File

@ -11,6 +11,7 @@
# under the License.
import json
import mock
import tempfile
from osc_lib.tests import utils as test_utils
@ -30,6 +31,7 @@ class Base(fakes.TestBaremetal):
]
}
tripleoclient = self.app.client_manager.tripleoclient
self.app.client_manager.baremetal.node.list.return_value = []
self.websocket = tripleoclient.messaging_websocket()
self.websocket.wait_for_messages.return_value = iter([{
'status': "SUCCESS",
@ -47,6 +49,12 @@ class TestConfigureBIOS(Base):
def setUp(self):
super(TestConfigureBIOS, self).setUp()
self.cmd = overcloud_bios.ConfigureBIOS(self.app, None)
playbook_runner = mock.patch(
'tripleoclient.utils.run_ansible_playbook',
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)
def test_configure_specified_nodes_ok(self):
conf = json.dumps(self.conf)
@ -59,14 +67,6 @@ class TestConfigureBIOS(Base):
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.apply_bios_settings',
workflow_input={
'node_uuids': ['node_uuid1', 'node_uuid2'],
'configuration': self.conf,
}
)
def test_configure_specified_nodes_and_configuration_from_file(self):
with tempfile.NamedTemporaryFile('w+t') as fp:
json.dump(self.conf, fp)
@ -80,23 +80,6 @@ class TestConfigureBIOS(Base):
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.apply_bios_settings',
workflow_input={
'node_uuids': ['node_uuid1', 'node_uuid2'],
'configuration': self.conf,
}
)
def test_configure_no_nodes(self):
arglist = ['--configuration', '{}']
verifylist = [
('configuration', '{}')
]
self.assertRaises(test_utils.ParserException, self.check_parser,
self.cmd, arglist, verifylist)
self.assertFalse(self.workflow.executions.create.called)
def test_configure_specified_nodes_and_configuration_not_yaml(self):
arglist = ['--configuration', ':', 'node_uuid1', 'node_uuid2']
verifylist = [
@ -156,38 +139,18 @@ class TestConfigureBIOS(Base):
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.apply_bios_settings_on_manageable_nodes',
workflow_input={'configuration': self.conf})
def test_configure_all_manageable_nodes_fail(self):
conf = json.dumps(self.conf)
arglist = ['--configuration', conf, '--all-manageable']
verifylist = [
('all_manageable', True),
('configuration', conf)
]
self.websocket.wait_for_messages.return_value = iter([{
"status": "FAILED",
"message": "Test failure.",
'execution_id': 'fake id',
'root_execution_id': 'fake id',
}])
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaisesRegex(RuntimeError, 'Failed to apply BIOS settings',
self.cmd.take_action, parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.apply_bios_settings_on_manageable_nodes',
workflow_input={'configuration': self.conf})
class TestResetBIOS(Base):
def setUp(self):
super(TestResetBIOS, self).setUp()
self.cmd = overcloud_bios.ResetBIOS(self.app, None)
playbook_runner = mock.patch(
'tripleoclient.utils.run_ansible_playbook',
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)
def test_reset_specified_nodes_ok(self):
arglist = ['node_uuid1', 'node_uuid2']
@ -196,28 +159,6 @@ class TestResetBIOS(Base):
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.reset_bios_settings',
workflow_input={'node_uuids': ['node_uuid1', 'node_uuid2']})
def test_reset_specified_nodes_fail(self):
arglist = ['node_uuid1', 'node_uuid2']
verifylist = [('node_uuids', ['node_uuid1', 'node_uuid2'])]
self.websocket.wait_for_messages.return_value = iter([{
"status": "FAILED",
"message": "Test failure.",
'execution_id': 'fake id',
'root_execution_id': 'fake id',
}])
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaisesRegex(RuntimeError, 'Failed to reset BIOS settings',
self.cmd.take_action, parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.reset_bios_settings',
workflow_input={'node_uuids': ['node_uuid1', 'node_uuid2']})
def test_reset_all_manageable_nodes_ok(self):
arglist = ['--all-manageable']
verifylist = [('all_manageable', True)]
@ -225,28 +166,6 @@ class TestResetBIOS(Base):
self.cmd.take_action(parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes',
workflow_input={})
def test_reset_all_manageable_nodes_fail(self):
arglist = ['--all-manageable']
verifylist = [('all_manageable', True)]
self.websocket.wait_for_messages.return_value = iter([{
"status": "FAILED",
"message": "Test failure.",
'execution_id': 'fake id',
'root_execution_id': 'fake id',
}])
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaisesRegex(RuntimeError, 'Failed to reset BIOS settings',
self.cmd.take_action, parsed_args)
self.workflow.executions.create.assert_called_once_with(
'tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes',
workflow_input={})
def test_reset_no_nodes(self):
arglist = []
verifylist = []

View File

@ -447,122 +447,84 @@ def clean_manageable_nodes(clients, **workflow_input):
print('Cleaned %d node(s)' % len(payload['cleaned_nodes']))
def apply_bios_configuration(clients, **workflow_input):
def apply_bios_configuration(clients, node_uuids, configuration):
"""Apply BIOS settings on nodes.
Run the tripleo.baremetal.v1.apply_bios_settings Mistral workflow.
"""
workflow_client = clients.workflow_engine
ooo_client = clients.tripleoclient
print('Applying BIOS settings for given nodes, this may take time')
with ooo_client.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.apply_bios_settings',
workflow_input=workflow_input
with utils.TempDirs() as tmp:
utils.run_ansible_playbook(
playbook='cli-baremetal-bios.yaml',
inventory='localhost,',
workdir=tmp,
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
extra_vars={
'node_uuids': node_uuids,
'bios_configuration': configuration
}
)
for payload in base.wait_for_messages(workflow_client, ws, execution):
if payload.get('message'):
print(payload['message'])
if payload['status'] == 'SUCCESS':
print('Success')
else:
raise RuntimeError(
'Failed to apply BIOS settings: {}'.format(payload['message']))
print('Successfully applied the BIOS for nodes: {}'.format(node_uuids))
def apply_bios_configuration_on_manageable_nodes(clients, **workflow_input):
def apply_bios_configuration_on_manageable_nodes(clients, configuration):
"""Apply BIOS settings on manageable nodes.
Run the tripleo.baremetal.v1.apply_bios_settings_on_manageable_nodes
Mistral workflow.
"""
workflow_client = clients.workflow_engine
ooo_client = clients.tripleoclient
print('Applying BIOS settings for manageable nodes, this may take time')
with ooo_client.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.apply_bios_settings_on_manageable_nodes',
workflow_input=workflow_input
)
for payload in base.wait_for_messages(workflow_client, ws, execution):
if payload.get('message'):
print(payload['message'])
if payload['status'] == 'SUCCESS':
print('Success')
else:
raise RuntimeError(
'Failed to apply BIOS settings: {}'.format(payload['message']))
apply_bios_configuration(
clients=clients,
node_uuids=[
i.uuid for i in clients.baremetal.node.list()
if i.provision_state == "manageable" and not i.maintenance
],
configuration=configuration
)
def reset_bios_configuration(clients, **workflow_input):
def reset_bios_configuration(clients, node_uuids):
"""Reset BIOS settings on nodes.
Run the tripleo.baremetal.v1.reset_bios_settings 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
ooo_client = clients.tripleoclient
print('Reset BIOS settings on given nodes, this may take time')
with ooo_client.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.reset_bios_settings',
workflow_input=workflow_input
with utils.TempDirs() as tmp:
utils.run_ansible_playbook(
playbook='cli-baremetal-bios-reset.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 payload.get('message'):
print(payload['message'])
if payload['status'] == 'SUCCESS':
print('Success')
else:
raise RuntimeError(
'Failed to reset BIOS settings: {}'.format(payload['message']))
print('Successfully reset the BIOS for nodes: {}'.format(node_uuids))
def reset_bios_configuration_on_manageable_nodes(clients, **workflow_input):
"""Reset BIOS settings on manageable nodes.
Run the tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes
Mistral workflow.
:param clients: application client object.
:type clients: Object
"""
workflow_client = clients.workflow_engine
ooo_client = clients.tripleoclient
print('Reset BIOS settings on manageable nodes, this may take time')
with ooo_client.messaging_websocket() as ws:
execution = base.start_workflow(
workflow_client,
'tripleo.baremetal.v1.reset_bios_settings_on_manageable_nodes',
workflow_input=workflow_input
)
for payload in base.wait_for_messages(workflow_client, ws, execution):
if payload.get('message'):
print(payload['message'])
if payload['status'] == 'SUCCESS':
print('Success')
else:
raise RuntimeError(
'Failed to reset BIOS settings: {}'.format(payload['message']))
reset_bios_configuration(
clients=clients,
node_uuids=[
i.uuid for i in clients.baremetal.node.list()
if i.provision_state == "manageable" and not i.maintenance
],
)
def deploy_roles(clients, **workflow_input):