diff --git a/mistralclient/api/v2/executions.py b/mistralclient/api/v2/executions.py index 9836707e..635d4b66 100644 --- a/mistralclient/api/v2/executions.py +++ b/mistralclient/api/v2/executions.py @@ -124,7 +124,8 @@ class ExecutionManager(base.ResourceManager): self._delete('/executions/%s%s' % (id, query_string)) - def get_report(self, id, errors_only=True, max_depth=None): + def get_report(self, id, errors_only=True, max_depth=None, + statistics_only=False): self._ensure_not_empty(id=id) query_params = {} @@ -132,6 +133,9 @@ class ExecutionManager(base.ResourceManager): if errors_only: query_params['errors_only'] = True + if statistics_only: + query_params['statistics_only'] = True + if max_depth is not None: query_params['max_depth'] = max_depth diff --git a/mistralclient/commands/v2/executions.py b/mistralclient/commands/v2/executions.py index c012d62b..c666112b 100644 --- a/mistralclient/commands/v2/executions.py +++ b/mistralclient/commands/v2/executions.py @@ -361,6 +361,12 @@ class GetReport(command.Command): action='store_true', help='Only error paths will be included.' ) + parser.add_argument( + '--statistics-only', + dest='statistics_only', + action='store_true', + help='Only the statistics will be included.' + ) parser.add_argument( '--no-errors-only', dest='errors_only', @@ -459,6 +465,12 @@ class GetReport(command.Command): stat['paused_tasks_count'] ) + if 'estimated_time' in stat: + self.print_line( + 'Estimated time (seconds) for the execution to finish:'' %s\n' + % stat['estimated_time'] + ) + def print_report(self, report_json): self.print_line( "\nTo get more details on a task failure " @@ -473,14 +485,15 @@ class GetReport(command.Command): ) self.print_statistics(report_json['statistics']) - self.print_line( - '%s Workflow Execution Tree %s\n' % - (frame_line, frame_line) - ) - self.print_workflow_execution_entry( - report_json['root_workflow_execution'], - 0 - ) + if 'root_workflow_execution' in report_json: + self.print_line( + '%s Workflow Execution Tree %s\n' % + (frame_line, frame_line) + ) + self.print_workflow_execution_entry( + report_json['root_workflow_execution'], + 0 + ) def take_action(self, parsed_args): mistral_client = self.app.client_manager.workflow_engine @@ -488,7 +501,8 @@ class GetReport(command.Command): report_json = mistral_client.executions.get_report( parsed_args.id, errors_only=parsed_args.errors_only, - max_depth=parsed_args.max_depth + max_depth=parsed_args.max_depth, + statistics_only=parsed_args.statistics_only, ) self.print_report(report_json) diff --git a/mistralclient/tests/functional/cli/v2/test_cli_v2.py b/mistralclient/tests/functional/cli/v2/test_cli_v2.py index fec1a1ae..08e720e5 100644 --- a/mistralclient/tests/functional/cli/v2/test_cli_v2.py +++ b/mistralclient/tests/functional/cli/v2/test_cli_v2.py @@ -272,7 +272,7 @@ class WorkflowCLITests(base_v2.MistralClientTestBase): for wf_name in wf_names: self.mistral_admin( 'workflow-delete', - params=wf_name+' --namespace abcdef' + params=wf_name + ' --namespace abcdef' ) wfs = self.mistral_admin('workflow-list') diff --git a/mistralclient/tests/unit/v2/test_executions.py b/mistralclient/tests/unit/v2/test_executions.py index a20b48c5..8cca98e9 100644 --- a/mistralclient/tests/unit/v2/test_executions.py +++ b/mistralclient/tests/unit/v2/test_executions.py @@ -279,6 +279,20 @@ class TestExecutionsV2(base.BaseClientV2Test): self.executions.delete(EXEC['id']) + def test_report_statistics_only(self): + url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id'] \ + + '/report?statistics_only=True' + + expected_json = { + 'statistics': {} + } + + self.requests_mock.get(url, json=expected_json) + + report = self.executions.get_report(EXEC['id'], statistics_only=True) + + self.assertDictEqual(expected_json, report) + def test_report(self): url = self.TEST_URL + URL_TEMPLATE_ID % EXEC['id'] + '/report'