Workflow to select nodes matching a profile/role
As a first step to enabling parameter calculation based on introspection data, we'll need to find the available nodes matching a particular role (which is associated with a flavor, which matches a specific profile in ironic). The next step is to retrieve the introspection data for each node output from this workflow, then define another workflow that does the transformation between introspection data and parameters. Partially-Implements: blueprint tripleo-derive-parameters Change-Id: I4b13f2923caa055be979eda57f9d5009960d61ef
This commit is contained in:
parent
ad64dc1f2d
commit
e38bcc9f09
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- Added a new workflow to fetch all the matching nodes with the given
|
||||
profile. To support it, a new action to fetch the node's capabilities
|
||||
has been added too.
|
@ -63,6 +63,7 @@ output_file = tripleo_common/locale/tripleo-common.pot
|
||||
mistral.actions =
|
||||
tripleo.baremetal.configure_boot = tripleo_common.actions.baremetal:ConfigureBootAction
|
||||
tripleo.baremetal.configure_root_device = tripleo_common.actions.baremetal:ConfigureRootDeviceAction
|
||||
tripleo.baremetal.get_profile = tripleo_common.actions.baremetal:GetProfileAction
|
||||
tripleo.baremetal.register_or_update_nodes = tripleo_common.actions.baremetal:RegisterOrUpdateNodes
|
||||
tripleo.baremetal.update_node_capability = tripleo_common.actions.baremetal:UpdateNodeCapability
|
||||
tripleo.baremetal.cell_v2_discover_hosts = tripleo_common.actions.baremetal:CellV2DiscoverHostsAction
|
||||
|
@ -310,3 +310,17 @@ class CellV2DiscoverHostsAction(base.TripleOAction):
|
||||
return mistral_workflow_utils.Result(
|
||||
error="%s: %s" % (type(err).__name__, str(err))
|
||||
)
|
||||
|
||||
|
||||
class GetProfileAction(base.TripleOAction):
|
||||
"""Return the profile associated with the given node """
|
||||
|
||||
def __init__(self, node):
|
||||
super(GetProfileAction, self).__init__()
|
||||
self.node = node
|
||||
|
||||
def run(self):
|
||||
result = {}
|
||||
result['profile'] = nodes.get_node_profile(self.node)
|
||||
result['uuid'] = self.node.get('uuid')
|
||||
return result
|
||||
|
@ -353,3 +353,21 @@ class TestCellV2DiscoverHostsAction(base.TestCase):
|
||||
result = action.run()
|
||||
self.assertTrue(result.is_error())
|
||||
mock_command.assert_called_once()
|
||||
|
||||
|
||||
class TestGetProfileAction(base.TestCase):
|
||||
|
||||
def test_run(self):
|
||||
node = {
|
||||
'uuid': 'abcd1',
|
||||
'properties': {
|
||||
'capabilities': 'profile:compute'
|
||||
}
|
||||
}
|
||||
action = baremetal.GetProfileAction(node=node)
|
||||
result = action.run()
|
||||
expected_result = {
|
||||
'uuid': 'abcd1',
|
||||
'profile': 'compute'
|
||||
}
|
||||
self.assertEqual(result, expected_result)
|
||||
|
@ -454,3 +454,15 @@ def run_nova_cell_v2_discovery():
|
||||
'discover_hosts',
|
||||
'--verbose'
|
||||
)
|
||||
|
||||
|
||||
def get_node_profile(node):
|
||||
"""Return the profile assosicated with the node """
|
||||
|
||||
capabilities = node.get('properties').get('capabilities')
|
||||
capabilities_dict = capabilities_to_dict(capabilities)
|
||||
|
||||
if 'profile' in capabilities_dict:
|
||||
return capabilities_dict['profile']
|
||||
|
||||
return None
|
||||
|
@ -687,6 +687,54 @@ workflows:
|
||||
on-success:
|
||||
- fail: <% $.get('status') = "FAILED" %>
|
||||
|
||||
nodes_with_profile:
|
||||
description: Find nodes with a specific profile
|
||||
input:
|
||||
- profile
|
||||
- queue_name: tripleo
|
||||
|
||||
tasks:
|
||||
get_available_nodes:
|
||||
action: ironic.node_list maintenance=false provision_state='available' detail=true
|
||||
on-success: get_matching_nodes
|
||||
on-error: set_status_failed_get_available_nodes
|
||||
|
||||
get_matching_nodes:
|
||||
with-items: node in <% task(get_available_nodes).result %>
|
||||
action: tripleo.baremetal.get_profile node=<% $.node %>
|
||||
on-success: send_message
|
||||
on-error: set_status_failed_get_matching_nodes
|
||||
publish:
|
||||
matching_nodes: <% let(input_profile_name => $.profile) -> task(get_matching_nodes).result.where($.profile = $input_profile_name).uuid %>
|
||||
|
||||
set_status_failed_get_available_nodes:
|
||||
on-success: send_message
|
||||
publish:
|
||||
status: FAILED
|
||||
message: <% task(get_available_nodes).result %>
|
||||
|
||||
set_status_failed_get_matching_nodes:
|
||||
on-success: send_message
|
||||
publish:
|
||||
status: FAILED
|
||||
message: <% task(get_matching_nodes).result %>
|
||||
|
||||
send_message:
|
||||
action: zaqar.queue_post
|
||||
retry: count=5 delay=1
|
||||
input:
|
||||
queue_name: <% $.queue_name %>
|
||||
messages:
|
||||
body:
|
||||
type: tripleo.baremetal.v1.nodes_with_profile
|
||||
payload:
|
||||
status: <% $.get('status', 'SUCCESS') %>
|
||||
message: <% $.get('message', '') %>
|
||||
execution: <% execution() %>
|
||||
matching_nodes: <% $.matching_nodes or [] %>
|
||||
on-success:
|
||||
- fail: <% $.get('status') = "FAILED" %>
|
||||
|
||||
create_raid_configuration:
|
||||
description: Create and apply RAID configuration for given nodes
|
||||
input:
|
||||
|
Loading…
x
Reference in New Issue
Block a user