Change List Plans to call workflow
Update the client and tests to call the workflow tripleo.plan_management.v1.list_plans instead of the action tripleo.plan.action directly. Change-Id: I1eb47925a52dc36d063f11507a75324edf879a4e Depends-On: I5eed964a31d95c46472a792b61e41fad126d7819 Partial-Bug: #1640436
This commit is contained in:
parent
91751a7d50
commit
7b8646041f
|
@ -66,6 +66,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
os.unlink(self.parameter_defaults_env_file)
|
||||
self.cmd._download_missing_files_from_plan = self.real_download_missing
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
|
@ -98,7 +101,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_create_parameters_env,
|
||||
mock_breakpoints_cleanupm,
|
||||
mock_events, mock_tarball,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--ceph-storage-scale', '3']
|
||||
verifylist = [
|
||||
|
@ -115,6 +119,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_event = mock.Mock()
|
||||
mock_event.id = '1234'
|
||||
mock_events.return_value = [mock_events]
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -170,6 +175,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.parameters.invoke_plan_env_workflows',
|
||||
|
@ -208,7 +216,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_breakpoints_cleanup, mock_tarball,
|
||||
mock_postconfig, mock_get_overcloud_endpoint,
|
||||
mock_invoke_plan_env_wf,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--ceph-storage-scale', '3',
|
||||
'--control-flavor', 'oooq_control', '--no-cleanup']
|
||||
|
@ -226,6 +235,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
orchestration_client.stacks.get.side_effect = [None, mock.Mock()]
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -302,6 +312,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.assertEqual(env_map.get('parameter_defaults'),
|
||||
parameters_env.get('parameter_defaults'))
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.parameters.invoke_plan_env_workflows',
|
||||
|
@ -340,7 +353,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_validate_args, mock_breakpoints_cleanup,
|
||||
mock_tarball, mock_postconfig,
|
||||
mock_get_overcloud_endpoint, mock_shutil_rmtree,
|
||||
mock_invoke_plan_env_wf, mock_get_horizon_url):
|
||||
mock_invoke_plan_env_wf, mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
arglist = ['--templates', '-p', 'the-plan-environment.yaml']
|
||||
verifylist = [
|
||||
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
|
||||
|
@ -355,6 +369,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
orchestration_client.stacks.get.side_effect = [None, mock.Mock()]
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.environments.get.return_value = mock.MagicMock(
|
||||
variables={'environments': []})
|
||||
|
@ -437,6 +452,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
clients.tripleoclient.object_store.put_object.assert_called()
|
||||
self.assertTrue(mock_invoke_plan_env_wf.called)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.parameters.'
|
||||
|
@ -476,7 +494,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_create_parameters_env, mock_validate_args,
|
||||
mock_breakpoints_cleanup, mock_tarball,
|
||||
mock_postconfig, mock_get_overcloud_endpoint,
|
||||
mock_deprecated_params, mock_get_horizon_url):
|
||||
mock_deprecated_params, mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--skip-deploy-identifier']
|
||||
verifylist = [
|
||||
|
@ -492,6 +511,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
orchestration_client = clients.orchestration
|
||||
mock_stack = fakes.create_tht_stack()
|
||||
orchestration_client.stacks.get.side_effect = [None, mock.Mock()]
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -533,6 +553,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
deploy_plan_call_input = deploy_plan_call[1]['workflow_input']
|
||||
self.assertTrue(deploy_plan_call_input['skip_deploy_identifier'])
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
|
@ -560,7 +583,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_deploy_postconfig,
|
||||
mock_breakpoints_cleanup,
|
||||
mock_events, mock_tarball,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '/home/stack/tripleo-heat-templates']
|
||||
verifylist = [
|
||||
|
@ -583,6 +607,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
baremetal = clients.baremetal
|
||||
baremetal.node.list.return_value = range(10)
|
||||
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -644,6 +669,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.cmd.take_action, parsed_args)
|
||||
self.assertFalse(mock_deploy_tht.called)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
|
@ -663,9 +691,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_update_parameters, mock_post_config,
|
||||
mock_utils_endpoint, mock_utils_createrc,
|
||||
mock_utils_tempest, mock_tarball,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url, mock_list_plans):
|
||||
|
||||
clients = self.app.client_manager
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -711,6 +740,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
|
@ -729,9 +761,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_update_parameters, mock_post_config,
|
||||
mock_utils_get_stack, mock_utils_endpoint,
|
||||
mock_utils_createrc, mock_utils_tempest,
|
||||
mock_tarball):
|
||||
mock_tarball, mock_list_plans):
|
||||
|
||||
clients = self.app.client_manager
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -770,6 +803,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
|
||||
|
@ -790,9 +826,11 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_utils_endpoint,
|
||||
mock_utils_createrc,
|
||||
mock_utils_tempest,
|
||||
mock_tarball):
|
||||
mock_tarball,
|
||||
mock_list_plans):
|
||||
|
||||
clients = self.app.client_manager
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -913,6 +951,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
mock_create_tempest_deployer_input.assert_called_with()
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
|
@ -945,7 +986,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_deploy_postconfig,
|
||||
mock_breakpoints_cleanup,
|
||||
mock_events, mock_tarball,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--rhel-reg',
|
||||
'--reg-sat-url', 'https://example.com',
|
||||
|
@ -983,6 +1025,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
orchestration_client = clients.orchestration
|
||||
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
|
||||
mock_events.return_value = []
|
||||
mock_list_plans.return_value = []
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -1155,6 +1198,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.assertFalse(mock_create_ocrc.called)
|
||||
self.assertFalse(mock_create_tempest_deployer_input.called)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
|
@ -1173,9 +1219,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_oc_endpoint,
|
||||
mock_create_ocrc,
|
||||
mock_create_tempest_deployer_input,
|
||||
mock_tarball, mock_get_horizon_url):
|
||||
mock_tarball, mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
clients = self.app.client_manager
|
||||
|
||||
mock_list_plans.return_value = []
|
||||
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
@ -1280,6 +1329,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
role_counts,
|
||||
self.cmd._get_default_role_counts(parsed_args))
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.plan_management.tarball',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
|
@ -1295,7 +1347,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_process_env,
|
||||
mock_write_overcloudrc,
|
||||
mock_create_parameters_env,
|
||||
mock_tarball):
|
||||
mock_tarball,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--control-scale', '3']
|
||||
verifylist = [
|
||||
|
@ -1307,6 +1360,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
mock_list_plans.return_value = []
|
||||
|
||||
object_client = clients.tripleoclient.object_store
|
||||
object_client.get_object = mock.Mock()
|
||||
|
@ -1330,6 +1384,9 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.workflows.deployment.get_horizon_url',
|
||||
autospec=True)
|
||||
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
|
||||
|
@ -1367,7 +1424,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
mock_breakpoints_cleanup,
|
||||
mock_tarball,
|
||||
mock_deploy_post_config,
|
||||
mock_get_horizon_url):
|
||||
mock_get_horizon_url,
|
||||
mock_list_plans):
|
||||
|
||||
arglist = ['--templates', '--ceph-storage-scale', '3',
|
||||
'--control-scale', '3', '--ntp-server', 'ntp']
|
||||
|
@ -1393,6 +1451,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||
|
||||
orchestration_client.stacks.create.side_effect = _orch_clt_create
|
||||
|
||||
mock_list_plans.return_value = []
|
||||
|
||||
workflow_client = clients.workflow_engine
|
||||
workflow_client.action_executions.create.return_value = mock.MagicMock(
|
||||
output='{"result":[]}')
|
||||
|
|
|
@ -25,25 +25,27 @@ class TestOvercloudPlanList(utils.TestCommand):
|
|||
|
||||
self.cmd = overcloud_plan.ListPlans(self.app, None)
|
||||
self.app.client_manager.workflow_engine = mock.Mock()
|
||||
self.workflow = self.app.client_manager.workflow_engine
|
||||
|
||||
def test_list_empty(self):
|
||||
self.workflow.action_executions.create.return_value = (
|
||||
mock.Mock(output='{"result": []}'))
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
def test_list_empty(self, mock_list_plans):
|
||||
mock_list_plans.return_value = []
|
||||
|
||||
result = self.cmd.take_action(None)
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.plan.list')
|
||||
mock_list_plans.assert_called_once_with(self.app.client_manager)
|
||||
|
||||
self.assertEqual(0, len(result[1]))
|
||||
|
||||
def test_list(self):
|
||||
self.workflow.action_executions.create.return_value = (
|
||||
mock.Mock(output='{"result": ["test-plan-1", "test-plan-2"]}'))
|
||||
@mock.patch(
|
||||
'tripleoclient.workflows.plan_management.list_deployment_plans',
|
||||
autospec=True)
|
||||
def test_list(self, mock_list_plans):
|
||||
mock_list_plans.return_value = (
|
||||
['test-plan-1', 'test-plan-2'])
|
||||
|
||||
result = self.cmd.take_action(None)
|
||||
self.workflow.action_executions.create.assert_called_once_with(
|
||||
'tripleo.plan.list')
|
||||
mock_list_plans.assert_called_once_with(self.app.client_manager)
|
||||
|
||||
self.assertEqual(1, len(result[0]))
|
||||
self.assertEqual([('test-plan-1',), ('test-plan-2',)], result[1])
|
||||
|
|
|
@ -432,7 +432,7 @@ class DeployOvercloud(command.Command):
|
|||
tht_root, user_tht_root):
|
||||
"""Deploy the fixed templates in TripleO Heat Templates"""
|
||||
|
||||
plans = plan_management.list_deployment_plans(self.workflow_client)
|
||||
plans = plan_management.list_deployment_plans(self.clients)
|
||||
generate_passwords = not parsed_args.disable_password_generation
|
||||
|
||||
# TODO(d0ugal): We need to put a more robust strategy in place here to
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os.path
|
||||
|
||||
|
@ -33,18 +32,12 @@ class ListPlans(command.Lister):
|
|||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
|
||||
workflow_client = self.app.client_manager.workflow_engine
|
||||
execution = workflow_client.action_executions.create(
|
||||
'tripleo.plan.list')
|
||||
clients = self.app.client_manager
|
||||
|
||||
try:
|
||||
json_results = json.loads(execution.output)['result']
|
||||
except Exception:
|
||||
self.log.exception("Error parsing JSON %s", execution.output)
|
||||
json_results = []
|
||||
plans = plan_management.list_deployment_plans(clients)
|
||||
|
||||
result = []
|
||||
for r in json_results:
|
||||
for r in plans:
|
||||
result.append((r,))
|
||||
|
||||
return (("Plan Name",), result)
|
||||
|
|
|
@ -108,8 +108,24 @@ def update_deployment_plan(clients, **workflow_input):
|
|||
'Exception updating plan: {}'.format(payload['message']))
|
||||
|
||||
|
||||
def list_deployment_plans(workflow_client, **input_):
|
||||
return base.call_action(workflow_client, 'tripleo.plan.list', **input_)
|
||||
def list_deployment_plans(clients, **workflow_input):
|
||||
workflow_client = clients.workflow_engine
|
||||
tripleoclients = clients.tripleoclient
|
||||
|
||||
with tripleoclients.messaging_websocket() as ws:
|
||||
execution = base.start_workflow(
|
||||
workflow_client,
|
||||
'tripleo.plan_management.v1.list_plans',
|
||||
workflow_input=workflow_input
|
||||
)
|
||||
|
||||
for payload in base.wait_for_messages(workflow_client, ws, execution,
|
||||
_WORKFLOW_TIMEOUT):
|
||||
if payload['status'] != 'SUCCESS':
|
||||
raise exceptions.WorkflowServiceError(
|
||||
'Exception listing plans: {}'.format(payload['message']))
|
||||
|
||||
return payload['plans']
|
||||
|
||||
|
||||
def create_container(workflow_client, **input_):
|
||||
|
|
Loading…
Reference in New Issue