Remove the mistral from the clean_.*_nodes workflow
This change removes all of mistral from the clean_nodes and clean_manageable_nodes workflows by calling the new cleaning playbook. Story: 2007212 Task: 38451 Task: 38452 Depends-On: I0e3f50ff2bdc16b6a148977b39a12023d5b30b3e Change-Id: I0b1981a82b1ae5d2b52a74250b623218a0cb6c0d Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
bb639bc65c
commit
7e677b0c35
@ -13,6 +13,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
from tripleoclient.tests import fakes
|
from tripleoclient.tests import fakes
|
||||||
|
|
||||||
|
|
||||||
@ -26,3 +28,10 @@ class TestOvercloudNode(fakes.FakePlaybookExecution):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestOvercloudNode, self).setUp()
|
super(TestOvercloudNode, self).setUp()
|
||||||
|
|
||||||
|
self.mock_playbook = mock.patch(
|
||||||
|
'tripleoclient.utils.run_ansible_playbook',
|
||||||
|
autospec=True
|
||||||
|
)
|
||||||
|
self.mock_playbook.start()
|
||||||
|
self.addCleanup(self.mock_playbook.stop)
|
||||||
|
@ -874,13 +874,6 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
|||||||
|
|
||||||
self.http_boot = '/var/lib/ironic/httpboot'
|
self.http_boot = '/var/lib/ironic/httpboot'
|
||||||
|
|
||||||
self.mock_playbook = mock.patch(
|
|
||||||
'tripleoclient.utils.run_ansible_playbook',
|
|
||||||
autospec=True
|
|
||||||
)
|
|
||||||
self.mock_playbook.start()
|
|
||||||
self.addCleanup(self.mock_playbook.stop)
|
|
||||||
|
|
||||||
def test_with_ip_range(self):
|
def test_with_ip_range(self):
|
||||||
argslist = ['--range', '10.0.0.0/24',
|
argslist = ['--range', '10.0.0.0/24',
|
||||||
'--credentials', 'admin:password']
|
'--credentials', 'admin:password']
|
||||||
|
@ -141,61 +141,9 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
|
|||||||
baremetal.configure_manageable_nodes(self.app.client_manager)
|
baremetal.configure_manageable_nodes(self.app.client_manager)
|
||||||
|
|
||||||
def test_clean_nodes_success(self):
|
def test_clean_nodes_success(self):
|
||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = self.message_success
|
|
||||||
|
|
||||||
baremetal.clean_nodes(self.app.client_manager, node_uuids=[])
|
baremetal.clean_nodes(self.app.client_manager, node_uuids=[])
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.clean_nodes',
|
|
||||||
workflow_input={
|
|
||||||
'node_uuids': [],
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_clean_nodes_error(self):
|
|
||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = self.message_failed
|
|
||||||
|
|
||||||
self.assertRaises(
|
|
||||||
exceptions.NodeConfigurationError,
|
|
||||||
baremetal.clean_nodes,
|
|
||||||
self.app.client_manager,
|
|
||||||
node_uuids=[]
|
|
||||||
)
|
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.clean_nodes',
|
|
||||||
workflow_input={
|
|
||||||
'node_uuids': [],
|
|
||||||
})
|
|
||||||
|
|
||||||
def test_clean_manageable_nodes_success(self):
|
def test_clean_manageable_nodes_success(self):
|
||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = iter([{
|
|
||||||
"execution_id": "IDID",
|
|
||||||
"status": "SUCCESS",
|
|
||||||
"cleaned_nodes": [],
|
|
||||||
}])
|
|
||||||
|
|
||||||
baremetal.clean_manageable_nodes(
|
baremetal.clean_manageable_nodes(
|
||||||
self.app.client_manager
|
self.app.client_manager
|
||||||
)
|
)
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.clean_manageable_nodes',
|
|
||||||
workflow_input={}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_clean_manageable_nodes_error(self):
|
|
||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = self.message_failed
|
|
||||||
|
|
||||||
self.assertRaises(
|
|
||||||
exceptions.NodeConfigurationError,
|
|
||||||
baremetal.clean_manageable_nodes,
|
|
||||||
self.app.client_manager)
|
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.clean_manageable_nodes',
|
|
||||||
workflow_input={}
|
|
||||||
)
|
|
||||||
|
@ -404,59 +404,44 @@ def discover_and_enroll(clients, ip_addresses, credentials, kernel_name,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def clean_nodes(clients, **workflow_input):
|
def clean_nodes(clients, node_uuids):
|
||||||
"""Clean Baremetal Nodes
|
"""Clean Baremetal Nodes
|
||||||
|
|
||||||
Run the tripleo.baremetal.v1.clean_nodes 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
|
with utils.TempDirs() as tmp:
|
||||||
tripleoclients = clients.tripleoclient
|
utils.run_ansible_playbook(
|
||||||
|
playbook='cli-baremetal-clean.yaml',
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
inventory='localhost,',
|
||||||
execution = base.start_workflow(
|
workdir=tmp,
|
||||||
workflow_client,
|
playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
|
||||||
'tripleo.baremetal.v1.clean_nodes',
|
extra_vars={
|
||||||
workflow_input={'node_uuids': workflow_input['node_uuids']}
|
'node_uuids': node_uuids
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
print('Successfully cleaned nodes: {}'.format(node_uuids))
|
||||||
if payload.get('message'):
|
|
||||||
print(payload['message'])
|
|
||||||
|
|
||||||
if payload['status'] != 'SUCCESS':
|
|
||||||
message = _format_errors(payload)
|
|
||||||
raise exceptions.NodeConfigurationError(
|
|
||||||
'Error(s) cleaning nodes:\n{}'.format(message))
|
|
||||||
|
|
||||||
print('Successfully cleaned nodes')
|
|
||||||
|
|
||||||
|
|
||||||
def clean_manageable_nodes(clients, **workflow_input):
|
def clean_manageable_nodes(clients):
|
||||||
"""Clean all manageable Nodes
|
"""Clean all manageable Nodes
|
||||||
|
|
||||||
Run the tripleo.baremetal.v1.clean_manageable_nodes Mistral workflow.
|
:param clients: application client object.
|
||||||
|
:type clients: Object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
workflow_client = clients.workflow_engine
|
clean_nodes(
|
||||||
tripleoclients = clients.tripleoclient
|
clients=clients,
|
||||||
|
node_uuids=[
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
i.uuid for i in clients.baremetal.node.list()
|
||||||
execution = base.start_workflow(
|
if i.provision_state == "manageable" and not i.maintenance
|
||||||
workflow_client,
|
]
|
||||||
'tripleo.baremetal.v1.clean_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':
|
|
||||||
raise exceptions.NodeConfigurationError(
|
|
||||||
'Error cleaning nodes: {}'.format(payload['message']))
|
|
||||||
|
|
||||||
print('Cleaned %d node(s)' % len(payload['cleaned_nodes']))
|
|
||||||
|
|
||||||
|
|
||||||
def apply_bios_configuration(clients, node_uuids, configuration):
|
def apply_bios_configuration(clients, node_uuids, configuration):
|
||||||
|
Loading…
Reference in New Issue
Block a user