Merge "Remove mistral from the discover_and_enroll workflow"
This commit is contained in:
commit
fc324e38e0
|
@ -26,6 +26,8 @@ from osc_lib.tests import utils as test_utils
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from tripleoclient import exceptions
|
from tripleoclient import exceptions
|
||||||
|
from tripleoclient import plugin
|
||||||
|
from tripleoclient.tests import fakes as ooofakes
|
||||||
from tripleoclient.tests.v1.overcloud_node import fakes
|
from tripleoclient.tests.v1.overcloud_node import fakes
|
||||||
from tripleoclient.v1 import overcloud_node
|
from tripleoclient.v1 import overcloud_node
|
||||||
|
|
||||||
|
@ -1205,10 +1207,26 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
||||||
execution.id = "IDID"
|
execution.id = "IDID"
|
||||||
self.workflow.executions.create.return_value = execution
|
self.workflow.executions.create.return_value = execution
|
||||||
client = self.app.client_manager.tripleoclient
|
client = self.app.client_manager.tripleoclient
|
||||||
|
client.create_mistral_context = plugin.ClientWrapper(
|
||||||
|
instance=ooofakes.FakeInstanceData
|
||||||
|
).create_mistral_context
|
||||||
self.websocket = client.messaging_websocket()
|
self.websocket = client.messaging_websocket()
|
||||||
|
|
||||||
self.cmd = overcloud_node.DiscoverNode(self.app, None)
|
self.cmd = overcloud_node.DiscoverNode(self.app, None)
|
||||||
|
|
||||||
|
self.gcn = mock.patch(
|
||||||
|
'tripleo_common.actions.baremetal.GetCandidateNodes',
|
||||||
|
autospec=True
|
||||||
|
)
|
||||||
|
self.gcn.start()
|
||||||
|
self.addCleanup(self.gcn.stop)
|
||||||
|
self.roun = mock.patch(
|
||||||
|
'tripleo_common.actions.baremetal.RegisterOrUpdateNodes',
|
||||||
|
autospec=True
|
||||||
|
)
|
||||||
|
self.roun.start()
|
||||||
|
self.addCleanup(self.roun.stop)
|
||||||
|
|
||||||
self.websocket.wait_for_messages.return_value = [{
|
self.websocket.wait_for_messages.return_value = [{
|
||||||
"status": "SUCCESS",
|
"status": "SUCCESS",
|
||||||
"message": "Success",
|
"message": "Success",
|
||||||
|
@ -1229,17 +1247,6 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
||||||
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.discover_and_enroll_nodes',
|
|
||||||
workflow_input={
|
|
||||||
'ip_addresses': '10.0.0.0/24',
|
|
||||||
'credentials': [['admin', 'password']],
|
|
||||||
'kernel_name': 'file://%s/agent.kernel' % self.http_boot,
|
|
||||||
'ramdisk_name': 'file://%s/agent.ramdisk' % self.http_boot,
|
|
||||||
'instance_boot_option': 'local'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_with_address_list(self):
|
def test_with_address_list(self):
|
||||||
argslist = ['--ip', '10.0.0.1', '--ip', '10.0.0.2',
|
argslist = ['--ip', '10.0.0.1', '--ip', '10.0.0.2',
|
||||||
'--credentials', 'admin:password']
|
'--credentials', 'admin:password']
|
||||||
|
@ -1249,17 +1256,6 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
||||||
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.workflow.executions.create.assert_called_once_with(
|
|
||||||
'tripleo.baremetal.v1.discover_and_enroll_nodes',
|
|
||||||
workflow_input={
|
|
||||||
'ip_addresses': ['10.0.0.1', '10.0.0.2'],
|
|
||||||
'credentials': [['admin', 'password']],
|
|
||||||
'kernel_name': 'file://%s/agent.kernel' % self.http_boot,
|
|
||||||
'ramdisk_name': 'file://%s/agent.ramdisk' % self.http_boot,
|
|
||||||
'instance_boot_option': 'local'
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_with_all_options(self):
|
def test_with_all_options(self):
|
||||||
argslist = ['--range', '10.0.0.0/24',
|
argslist = ['--range', '10.0.0.0/24',
|
||||||
'--credentials', 'admin:password',
|
'--credentials', 'admin:password',
|
||||||
|
@ -1282,20 +1278,12 @@ class TestDiscoverNode(fakes.TestOvercloudNode):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
workflows_calls = [
|
workflows_calls = [
|
||||||
mock.call('tripleo.baremetal.v1.discover_and_enroll_nodes',
|
|
||||||
workflow_input={'ip_addresses': '10.0.0.0/24',
|
|
||||||
'credentials': [['admin', 'password'],
|
|
||||||
['admin2', 'password2']],
|
|
||||||
'ports': [623, 6230],
|
|
||||||
'kernel_name': None,
|
|
||||||
'ramdisk_name': None,
|
|
||||||
'instance_boot_option': 'netboot'}),
|
|
||||||
mock.call('tripleo.baremetal.v1.introspect',
|
mock.call('tripleo.baremetal.v1.introspect',
|
||||||
workflow_input={'node_uuids': ['MOCK_NODE_UUID'],
|
workflow_input={'node_uuids': [],
|
||||||
'run_validations': True,
|
'run_validations': True,
|
||||||
'concurrency': 10}),
|
'concurrency': 10}),
|
||||||
mock.call('tripleo.baremetal.v1.provide',
|
mock.call('tripleo.baremetal.v1.provide',
|
||||||
workflow_input={'node_uuids': ['MOCK_NODE_UUID']}
|
workflow_input={'node_uuids': []}
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self.workflow.executions.create.assert_has_calls(workflows_calls)
|
self.workflow.executions.create.assert_has_calls(workflows_calls)
|
||||||
|
|
|
@ -16,6 +16,8 @@ from __future__ import print_function
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
from tripleo_common.actions import baremetal
|
||||||
|
|
||||||
from tripleoclient import exceptions
|
from tripleoclient import exceptions
|
||||||
from tripleoclient.workflows import base
|
from tripleoclient.workflows import base
|
||||||
|
|
||||||
|
@ -313,34 +315,74 @@ def create_raid_configuration(clients, **workflow_input):
|
||||||
'Failed to create RAID: {}'.format(payload['message']))
|
'Failed to create RAID: {}'.format(payload['message']))
|
||||||
|
|
||||||
|
|
||||||
def discover_and_enroll(clients, **workflow_input):
|
def discover_and_enroll(clients, ip_addresses, credentials, kernel_name,
|
||||||
"""Discover nodes.
|
ramdisk_name, instance_boot_option,
|
||||||
|
existing_nodes=None, ports=None):
|
||||||
|
"""Discover nodes and enroll baremetal nodes.
|
||||||
|
|
||||||
Run the tripleo.baremetal.v1.discover_and_enroll_nodes Mistral workflow.
|
:param clients: application client object.
|
||||||
|
:type clients: Object
|
||||||
|
|
||||||
|
:param ip_addresses: List of IP addresses.
|
||||||
|
:type ip_addresses: List || String
|
||||||
|
|
||||||
|
:param credentials: Credential information object
|
||||||
|
:type credentials: Tuple
|
||||||
|
|
||||||
|
:param kernel_name: Kernel to use
|
||||||
|
:type kernel_name: String
|
||||||
|
|
||||||
|
:param ramdisk_name: RAMDISK to use
|
||||||
|
:type ramdisk_name: String
|
||||||
|
|
||||||
|
:param instance_boot_option: Boot options to use
|
||||||
|
:type instance_boot_option: String
|
||||||
|
|
||||||
|
:param existing_nodes: List of nodes already discovered. If this is
|
||||||
|
undefined this object will be set to an empty
|
||||||
|
array.
|
||||||
|
:type existing_nodes: List
|
||||||
|
|
||||||
|
:param ports: List of ports, if no ports are provided the list of ports
|
||||||
|
will be limted to [623].
|
||||||
|
:type ports: List
|
||||||
|
|
||||||
|
:returns: List
|
||||||
"""
|
"""
|
||||||
|
|
||||||
workflow_client = clients.workflow_engine
|
if not ports:
|
||||||
tripleoclients = clients.tripleoclient
|
ports = [623]
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
if not existing_nodes:
|
||||||
execution = base.start_workflow(
|
existing_nodes = list()
|
||||||
workflow_client,
|
|
||||||
'tripleo.baremetal.v1.discover_and_enroll_nodes',
|
context = clients.tripleoclient.create_mistral_context()
|
||||||
workflow_input=workflow_input
|
|
||||||
|
get_candiate_nodes = baremetal.GetCandidateNodes(
|
||||||
|
ip_addresses,
|
||||||
|
ports,
|
||||||
|
credentials,
|
||||||
|
existing_nodes
|
||||||
|
)
|
||||||
|
probed_nodes = list()
|
||||||
|
for node in get_candiate_nodes.run(context=context):
|
||||||
|
probed_nodes.append(
|
||||||
|
baremetal.ProbeNode(**node).run(context=context)
|
||||||
)
|
)
|
||||||
|
print('Successfully probed node IP {}'.format(node['ip']))
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution):
|
register_or_update = baremetal.RegisterOrUpdateNodes(
|
||||||
if payload.get('message'):
|
nodes_json=probed_nodes,
|
||||||
print(payload['message'])
|
instance_boot_option=instance_boot_option,
|
||||||
|
kernel_name=kernel_name,
|
||||||
if payload['status'] == 'SUCCESS':
|
ramdisk_name=ramdisk_name
|
||||||
registered_nodes = payload['registered_nodes']
|
)
|
||||||
for nd in registered_nodes:
|
registered_nodes = list()
|
||||||
print('Successfully registered node UUID %s' % nd['uuid'])
|
for node in register_or_update.run(context=context):
|
||||||
return registered_nodes
|
print('Successfully registered node UUID {}'.format(node['uuid']))
|
||||||
|
registered_nodes.append(node)
|
||||||
else:
|
else:
|
||||||
raise exceptions.RegisterOrUpdateError(
|
return registered_nodes
|
||||||
'Exception discovering nodes: {}'.format(payload['message']))
|
|
||||||
|
|
||||||
|
|
||||||
def clean_nodes(clients, **workflow_input):
|
def clean_nodes(clients, **workflow_input):
|
||||||
|
|
Loading…
Reference in New Issue