2016-05-29 22:09:17 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2016-07-12 07:36:15 +01:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-04-27 14:53:56 +02:00
|
|
|
import six
|
|
|
|
|
2016-05-29 22:09:17 -04:00
|
|
|
from tripleoclient import exceptions
|
2016-07-12 07:36:15 +01:00
|
|
|
from tripleoclient.workflows import base
|
2016-05-29 22:09:17 -04:00
|
|
|
|
|
|
|
|
2017-12-18 12:22:24 +11:00
|
|
|
def validate_nodes(clients, **workflow_input):
|
|
|
|
"""Node Registration or Update
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.validate_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.validate_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':
|
|
|
|
print('Successfully validated environment file')
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
raise exceptions.RegisterOrUpdateError(
|
|
|
|
'Exception validating environment file: {}'.format(
|
|
|
|
payload['message'])
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-05-29 22:09:17 -04:00
|
|
|
def register_or_update(clients, **workflow_input):
|
|
|
|
"""Node Registration or Update
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.register_or_update Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.register_or_update',
|
|
|
|
workflow_input=workflow_input
|
|
|
|
)
|
|
|
|
|
2017-03-15 15:39:09 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-05-29 22:09:17 -04:00
|
|
|
|
|
|
|
if payload['status'] == 'SUCCESS':
|
|
|
|
registered_nodes = payload['registered_nodes']
|
|
|
|
for nd in registered_nodes:
|
|
|
|
print('Successfully registered node UUID %s' % nd['uuid'])
|
|
|
|
return registered_nodes
|
|
|
|
else:
|
|
|
|
raise exceptions.RegisterOrUpdateError(
|
|
|
|
'Exception registering nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
|
2018-04-27 14:53:56 +02:00
|
|
|
def _format_errors(payload):
|
2016-09-08 17:18:53 +01:00
|
|
|
errors = []
|
|
|
|
messages = payload.get('message', [])
|
|
|
|
for msg in messages:
|
2018-04-27 14:53:56 +02:00
|
|
|
# Adapt for different formats
|
|
|
|
if isinstance(msg, six.string_types):
|
|
|
|
text = msg
|
|
|
|
else:
|
|
|
|
text = msg.get('result') or msg.get('message', '')
|
2016-09-08 17:18:53 +01:00
|
|
|
try:
|
|
|
|
# With multiple workflows, the error message can become
|
|
|
|
# quite large and unreadable as it gets passed from task to
|
|
|
|
# task. This attempts to keep only the last, and hopefully
|
|
|
|
# useful part.
|
2018-04-27 14:53:56 +02:00
|
|
|
errors.append(text.rstrip('\n').split('\n')[-1])
|
2016-09-08 17:18:53 +01:00
|
|
|
except Exception:
|
2018-04-27 14:53:56 +02:00
|
|
|
errors.append(text)
|
2016-09-08 17:18:53 +01:00
|
|
|
return '\n'.join(errors)
|
|
|
|
|
|
|
|
|
2016-05-29 22:09:17 -04:00
|
|
|
def provide(clients, **workflow_input):
|
|
|
|
"""Provide Baremetal Nodes
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.provide Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.provide',
|
2017-10-05 16:48:39 -04:00
|
|
|
workflow_input={'node_uuids': workflow_input['node_uuids']}
|
2017-03-29 22:25:34 -04:00
|
|
|
)
|
|
|
|
|
2017-03-15 15:39:09 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-05-29 22:09:17 -04:00
|
|
|
|
2017-03-15 15:39:09 +00:00
|
|
|
if payload['status'] != 'SUCCESS':
|
2016-09-08 17:18:53 +01:00
|
|
|
try:
|
2018-04-27 14:53:56 +02:00
|
|
|
message = _format_errors(payload)
|
2016-09-08 17:18:53 +01:00
|
|
|
except Exception:
|
|
|
|
message = 'Failed.'
|
|
|
|
raise exceptions.NodeProvideError(
|
|
|
|
'Failed to set nodes to available state: {}'.format(message))
|
2016-06-09 16:41:16 +01:00
|
|
|
|
|
|
|
|
2016-07-01 15:07:26 +01:00
|
|
|
def introspect(clients, **workflow_input):
|
|
|
|
"""Introspect Baremetal Nodes
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.introspect Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
|
|
|
print("Waiting for introspection to finish...")
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.introspect',
|
|
|
|
workflow_input={
|
|
|
|
'node_uuids': workflow_input['node_uuids'],
|
2019-07-24 01:12:29 +00:00
|
|
|
'run_validations': workflow_input['run_validations'],
|
|
|
|
'concurrency': workflow_input.get('concurrency', 20)
|
|
|
|
}
|
2017-03-29 22:25:34 -04:00
|
|
|
)
|
|
|
|
|
2017-03-15 16:25:20 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-07-01 15:07:26 +01:00
|
|
|
|
2017-09-13 08:48:27 +01:00
|
|
|
if payload['status'] != 'SUCCESS':
|
2016-07-01 15:07:26 +01:00
|
|
|
raise exceptions.IntrospectionError(
|
Fix overcloud node instrospect exception output
Currently when something fails when introspecting we get this:
(undercloud) [stack@undercloud-0 ~]$ openstack overcloud node introspect --provide 1b646cb5-39e3-4ef9-a440-9a7c4ee0c6e1
Waiting for introspection to finish...
Waiting for messages on queue 'tripleo' with no timeout.
Retrying 1 nodes that failed introspection. Attempt 1 of 3
Retrying 1 nodes that failed introspection. Attempt 2 of 3
Retrying 1 nodes that failed introspection. Attempt 3 of 3
Retry limit reached with 1 nodes still failing introspection
Exception occured while running the command
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 30, in run
super(Command, self).run(parsed_args)
File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
return super(Command, self).run(parsed_args)
File "/usr/lib/python3.6/site-packages/cliff/command.py", line 184, in run
return_code = self.take_action(parsed_args) or 0
File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_node.py", line 208, in take_action
run_validations=parsed_args.run_validations
File "/usr/lib/python3.6/site-packages/tripleoclient/workflows/baremetal.py", line 159, in introspect
.join(msg for msg in payload['message'] if msg))
tripleoclient.exceptions.IntrospectionError: Introspection completed with errors:
R
e
t
r
y
l
i
m
i
t
.....
With this fix we correctly get a sane output:
(undercloud) [stack@undercloud-0 ~]$ openstack overcloud node introspect --provide 1b646cb5-39e3-4ef9-a440-9a7c4ee0c6e1
Waiting for introspection to finish...
Waiting for messages on queue 'tripleo' with no timeout.
Retrying 1 nodes that failed introspection. Attempt 1 of 3
Retrying 1 nodes that failed introspection. Attempt 2 of 3
Retrying 1 nodes that failed introspection. Attempt 3 of 3
Retry limit reached with 1 nodes still failing introspection
Exception occured while running the command
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/tripleoclient/command.py", line 30, in run
super(Command, self).run(parsed_args)
File "/usr/lib/python3.6/site-packages/osc_lib/command/command.py", line 41, in run
return super(Command, self).run(parsed_args)
File "/usr/lib/python3.6/site-packages/cliff/command.py", line 184, in run
return_code = self.take_action(parsed_args) or 0
File "/usr/lib/python3.6/site-packages/tripleoclient/v1/overcloud_node.py", line 208, in take_action
run_validations=parsed_args.run_validations
File "/usr/lib/python3.6/site-packages/tripleoclient/workflows/baremetal.py", line 159, in introspect
.format(payload['message']))
tripleoclient.exceptions.IntrospectionError: Introspection completed with errors: Retry limit reached with 1 nodes still failing introspection
Introspection completed with errors: Retry limit reached with 1 nodes still failing introspection
Change-Id: I0f5bd1a2eb511041e6b93eacc71c964648bdf7ef
2019-04-29 17:24:26 +02:00
|
|
|
"Introspection completed with errors: {}"
|
|
|
|
.format(payload['message']))
|
2016-07-01 15:07:26 +01:00
|
|
|
|
|
|
|
|
2016-06-09 16:41:16 +01:00
|
|
|
def introspect_manageable_nodes(clients, **workflow_input):
|
|
|
|
"""Introspect all manageable nodes
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.introspect_manageable_nodes Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
|
|
|
print("Waiting for introspection to finish...")
|
|
|
|
|
|
|
|
errors = []
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.introspect_manageable_nodes',
|
|
|
|
workflow_input={
|
2019-07-24 01:12:29 +00:00
|
|
|
'run_validations': workflow_input['run_validations'],
|
|
|
|
'concurrency': workflow_input.get('concurrency', 20)
|
|
|
|
}
|
2017-03-29 22:25:34 -04:00
|
|
|
)
|
|
|
|
|
2017-03-15 16:52:07 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-06-09 16:41:16 +01:00
|
|
|
|
|
|
|
if payload['status'] == 'SUCCESS':
|
2016-07-19 14:51:17 +03:00
|
|
|
introspected_nodes = payload['introspected_nodes'] or {}
|
2016-06-09 16:41:16 +01:00
|
|
|
for node_uuid, status in introspected_nodes.items():
|
2017-08-16 16:55:24 +01:00
|
|
|
if status['error'] is not None:
|
2016-06-09 16:41:16 +01:00
|
|
|
errors.append("%s: %s" % (node_uuid, status['error']))
|
|
|
|
else:
|
|
|
|
raise exceptions.IntrospectionError(
|
|
|
|
'Exception introspecting nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
if errors:
|
|
|
|
raise exceptions.IntrospectionError(
|
|
|
|
"Introspection completed with errors:\n%s" % '\n'
|
|
|
|
.join(errors))
|
|
|
|
|
|
|
|
print("Introspection completed.")
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.provide_manageable_nodes',
|
2017-10-05 16:48:39 -04:00
|
|
|
workflow_input=workflow_input
|
2017-03-29 22:25:34 -04:00
|
|
|
)
|
|
|
|
|
2017-03-15 17:08:14 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-06-09 16:41:16 +01:00
|
|
|
|
|
|
|
if payload['status'] != 'SUCCESS':
|
|
|
|
raise exceptions.NodeProvideError(
|
|
|
|
'Exception providing nodes:{}'.format(payload['message']))
|
|
|
|
|
|
|
|
print(payload['message'])
|
2016-07-20 14:13:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
def configure(clients, **workflow_input):
|
|
|
|
"""Configure Node boot options.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.configure Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
ooo_client = clients.tripleoclient
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with ooo_client.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.configure',
|
|
|
|
workflow_input=workflow_input
|
|
|
|
)
|
|
|
|
|
2017-03-16 07:48:27 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-07-20 14:13:58 +00:00
|
|
|
|
2016-09-06 11:26:27 +01:00
|
|
|
if payload['status'] != 'SUCCESS':
|
2016-07-20 14:13:58 +00:00
|
|
|
raise exceptions.NodeConfigurationError(
|
|
|
|
'Failed to configure nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
|
|
|
|
def configure_manageable_nodes(clients, **workflow_input):
|
|
|
|
"""Configure all manageable Nodes.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.configure_manageable_nodes Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
ooo_client = clients.tripleoclient
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with ooo_client.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.configure_manageable_nodes',
|
|
|
|
workflow_input=workflow_input
|
|
|
|
)
|
|
|
|
|
2017-03-16 08:00:04 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2016-07-20 14:13:58 +00:00
|
|
|
|
|
|
|
if payload['status'] != 'SUCCESS':
|
|
|
|
raise exceptions.NodeConfigurationError(
|
|
|
|
'Exception configuring nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
print(payload['message'])
|
2017-01-17 13:20:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
def create_raid_configuration(clients, **workflow_input):
|
|
|
|
"""Create RAID configuration on nodes.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.create_raid_configuration Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
ooo_client = clients.tripleoclient
|
|
|
|
|
|
|
|
print('Creating RAID configuration for given nodes, this may take time')
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with ooo_client.messaging_websocket() as ws:
|
2017-03-29 22:25:34 -04:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.create_raid_configuration',
|
|
|
|
workflow_input=workflow_input
|
|
|
|
)
|
|
|
|
|
2017-03-16 08:02:35 +00:00
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
if 'message' in payload:
|
|
|
|
print(payload['message'])
|
2017-01-17 13:20:22 +01:00
|
|
|
|
|
|
|
if payload['status'] == 'SUCCESS':
|
|
|
|
print('Success')
|
|
|
|
else:
|
|
|
|
raise RuntimeError(
|
|
|
|
'Failed to create RAID: {}'.format(payload['message']))
|
2017-06-07 15:13:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
def discover_and_enroll(clients, **workflow_input):
|
|
|
|
"""Discover nodes.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.discover_and_enroll_nodes Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
2017-10-05 16:48:39 -04:00
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
2017-06-07 15:13:09 +02:00
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal.v1.discover_and_enroll_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':
|
|
|
|
registered_nodes = payload['registered_nodes']
|
|
|
|
for nd in registered_nodes:
|
|
|
|
print('Successfully registered node UUID %s' % nd['uuid'])
|
|
|
|
return registered_nodes
|
|
|
|
else:
|
|
|
|
raise exceptions.RegisterOrUpdateError(
|
|
|
|
'Exception discovering nodes: {}'.format(payload['message']))
|
2018-04-27 14:53:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
def clean_nodes(clients, **workflow_input):
|
|
|
|
"""Clean Baremetal Nodes
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.clean_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.clean_nodes',
|
|
|
|
workflow_input={'node_uuids': workflow_input['node_uuids']}
|
|
|
|
)
|
|
|
|
|
|
|
|
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
|
|
|
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):
|
|
|
|
"""Clean all manageable Nodes
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.clean_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.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']))
|
2018-06-19 18:03:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
def apply_bios_configuration(clients, **workflow_input):
|
|
|
|
"""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
|
|
|
|
)
|
|
|
|
|
|
|
|
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']))
|
|
|
|
|
|
|
|
|
|
|
|
def apply_bios_configuration_on_manageable_nodes(clients, **workflow_input):
|
|
|
|
"""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']))
|
|
|
|
|
|
|
|
|
|
|
|
def reset_bios_configuration(clients, **workflow_input):
|
|
|
|
"""Reset BIOS settings on nodes.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal.v1.reset_bios_settings Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
|
|
|
|
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']))
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
|
|
|
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']))
|
2019-02-22 16:07:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
def deploy_roles(clients, **workflow_input):
|
|
|
|
"""Deploy provided roles using Ironic.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal_deploy.v1.deploy_roles Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal_deploy.v1.deploy_roles',
|
|
|
|
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 deploying nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
return payload
|
2019-07-26 03:03:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
def undeploy_roles(clients, **workflow_input):
|
|
|
|
"""Undeploy provided roles using Ironic.
|
|
|
|
|
|
|
|
Run the tripleo.baremetal_deploy.v1.undeploy_roles Mistral workflow.
|
|
|
|
"""
|
|
|
|
|
|
|
|
workflow_client = clients.workflow_engine
|
|
|
|
tripleoclients = clients.tripleoclient
|
|
|
|
|
|
|
|
with tripleoclients.messaging_websocket() as ws:
|
|
|
|
execution = base.start_workflow(
|
|
|
|
workflow_client,
|
|
|
|
'tripleo.baremetal_deploy.v1.undeploy_roles',
|
|
|
|
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 undeploying nodes: {}'.format(payload['message']))
|
|
|
|
|
|
|
|
return payload
|