Merge "Change generate fencing parameters to call workflow"
This commit is contained in:
commit
e8a12eac8f
@ -92,15 +92,13 @@ class TestGenerateFencingParameters(utils.TestCommand):
|
||||
|
||||
self.cmd = overcloud_parameters.GenerateFencingParameters(self.app,
|
||||
None)
|
||||
self.app.client_manager.workflow_engine = mock.Mock()
|
||||
self.app.client_manager = mock.Mock()
|
||||
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
|
||||
def test_generate_parameters(self):
|
||||
nodes_file = tempfile.NamedTemporaryFile(suffix='.json', delete=False,
|
||||
mode="wt")
|
||||
self.addCleanup(os.unlink, nodes_file.name)
|
||||
nodes_file.write("""
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.parameters.generate_fencing_parameters',
|
||||
autospec=True)
|
||||
def test_generate_parameters(self, mock_gen_fence):
|
||||
mock_open_context = mock.mock_open(read_data="""
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
@ -127,24 +125,24 @@ class TestGenerateFencingParameters(utils.TestCommand):
|
||||
]
|
||||
}
|
||||
""")
|
||||
nodes_file.close()
|
||||
|
||||
os.environ["OS_USERNAME"] = "test_os_username"
|
||||
os.environ["OS_PASSWORD"] = "test_os_password"
|
||||
os.environ["OS_AUTH_URL"] = "test://auth.url"
|
||||
os.environ["OS_TENANT_NAME"] = "test_os_tenant_name"
|
||||
|
||||
arglist = [nodes_file.name]
|
||||
arglist = ['node_file.json']
|
||||
verifylist = []
|
||||
|
||||
self.workflow.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
mock_gen_fence.return_value = '{"result":[]}'
|
||||
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.parameters.generate_fencing',
|
||||
{
|
||||
with mock.patch('six.moves.builtins.open', mock_open_context):
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_gen_fence.assert_called_once_with(
|
||||
self.app.client_manager,
|
||||
**{
|
||||
'nodes_json': [
|
||||
{
|
||||
u'mac': [u'00:11:22:33:44:55'],
|
||||
@ -168,5 +166,4 @@ class TestGenerateFencingParameters(utils.TestCommand):
|
||||
'ipmi_cipher': None,
|
||||
'ipmi_lanplus': False,
|
||||
'ipmi_level': None
|
||||
},
|
||||
run_sync=True, save_result=True)
|
||||
})
|
||||
|
@ -209,3 +209,17 @@ class TestParameterWorkflows(utils.TestCommand):
|
||||
|
||||
std_output = mock_print.getvalue()
|
||||
self.assertNotIn('TestParameter1', std_output)
|
||||
|
||||
def test_generate_fencing_parameters(self):
|
||||
self.websocket.wait_for_messages.return_value = iter([{
|
||||
"execution": {"id": "IDID"},
|
||||
"status": "SUCCESS",
|
||||
"fencing_parameters": "{}"
|
||||
}])
|
||||
|
||||
parameters.generate_fencing_parameters(
|
||||
self.app.client_manager, **{})
|
||||
|
||||
self.workflow.executions.create.assert_called_once_with(
|
||||
'tripleo.parameters.v1.generate_fencing_parameters',
|
||||
workflow_input={})
|
||||
|
@ -21,7 +21,6 @@ from osc_lib.i18n import _
|
||||
from tripleoclient import command
|
||||
from tripleoclient import exceptions
|
||||
from tripleoclient import utils
|
||||
from tripleoclient.workflows import base
|
||||
from tripleoclient.workflows import parameters
|
||||
|
||||
|
||||
@ -125,11 +124,11 @@ class GenerateFencingParameters(command.Command):
|
||||
'ipmi_level': parsed_args.ipmi_level,
|
||||
'ipmi_cipher': parsed_args.ipmi_cipher,
|
||||
'ipmi_lanplus': parsed_args.ipmi_lanplus,
|
||||
}
|
||||
result = base.call_action(
|
||||
self.app.client_manager.workflow_engine,
|
||||
'tripleo.parameters.generate_fencing',
|
||||
**workflow_input)
|
||||
}
|
||||
|
||||
result = parameters.generate_fencing_parameters(
|
||||
self.app.client_manager, **workflow_input)
|
||||
|
||||
fencing_parameters = yaml.safe_dump(result, default_flow_style=False)
|
||||
if parsed_args.output:
|
||||
parsed_args.output.write(fencing_parameters)
|
||||
|
@ -138,3 +138,24 @@ def check_deprecated_parameters(clients, container):
|
||||
'role-specific inputs.')
|
||||
print('\n'.join([' {}'.format(param)
|
||||
for param in invalid_role_specific_params]))
|
||||
|
||||
|
||||
def generate_fencing_parameters(clients, **workflow_input):
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
|
||||
with tripleoclients.messaging_websocket() as ws:
|
||||
execution = base.start_workflow(
|
||||
workflow_client,
|
||||
'tripleo.parameters.v1.generate_fencing_parameters',
|
||||
workflow_input=workflow_input)
|
||||
|
||||
for payload in base.wait_for_messages(workflow_client,
|
||||
ws, execution, 600):
|
||||
if payload['status'] != 'SUCCESS':
|
||||
raise exceptions.WorkflowServiceError(
|
||||
'Exception generating fencing parameters: {}'.format(
|
||||
payload['message']))
|
||||
if ('fencing_parameters' in payload and
|
||||
(payload.get('status', 'FAILED') == "SUCCESS")):
|
||||
return payload['fencing_parameters']
|
||||
|
Loading…
Reference in New Issue
Block a user