Skip to content

Commit e548b3b

Browse files
authored
CY-901 cfy local: add executions list and get (#897)
* cfy local: add `executions list` * cfy local: add `executions get` * BASE_EXECUTION_COLUMNS
1 parent ed10a1c commit e548b3b

2 files changed

Lines changed: 54 additions & 12 deletions

File tree

cloudify_cli/commands/executions.py

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
'NOTE: Executions currently in a "canceling/force-canceling" status '
3535
'may take a while to change into "cancelled"')
3636

37-
FULL_EXECUTION_COLUMNS = ['id', 'workflow_id', 'status_display', 'is_dry_run',
38-
'deployment_id', 'created_at', 'ended_at',
39-
'error', 'visibility', 'tenant_name',
40-
'created_by', 'started_at', 'scheduled_for']
41-
MINIMAL_EXECUTION_COLUMNS = ['id', 'workflow_id', 'status_display',
42-
'is_dry_run',
43-
'deployment_id', 'created_at', 'started_at',
44-
'scheduled_for', 'visibility', 'tenant_name',
45-
'created_by']
37+
BASE_EXECUTION_COLUMNS = ['id', 'workflow_id', 'status_display']
38+
LOCAL_EXECUTION_COLUMNS = BASE_EXECUTION_COLUMNS + [
39+
'blueprint_id', 'started_at', 'ended_at', 'error']
40+
FULL_EXECUTION_COLUMNS = BASE_EXECUTION_COLUMNS + [
41+
'is_dry_run', 'deployment_id', 'created_at', 'ended_at', 'error',
42+
'visibility', 'tenant_name', 'created_by', 'started_at', 'scheduled_for']
43+
MINIMAL_EXECUTION_COLUMNS = BASE_EXECUTION_COLUMNS + [
44+
'is_dry_run', 'deployment_id', 'created_at', 'started_at', 'scheduled_for',
45+
'visibility', 'tenant_name', 'created_by']
4646
EXECUTION_TABLE_LABELS = {'status_display': 'status'}
4747

4848

@@ -90,7 +90,7 @@ def manager_get(execution_id, logger, client, tenant_name):
9090

9191

9292
@cfy.command(name='list',
93-
short_help='List deployment executions [manager only]')
93+
short_help='List deployment executions')
9494
@cfy.options.deployment_id(required=False)
9595
@cfy.options.include_system_workflows
9696
@cfy.options.sort_by()
@@ -333,6 +333,46 @@ def manager_cancel(execution_id, force, kill, logger, client, tenant_name):
333333
"cfy executions get {0}".format(execution_id))
334334

335335

336+
@cfy.command(name='list',
337+
short_help='List deployment executions')
338+
@cfy.options.blueprint_id(required=True)
339+
@cfy.options.common_options
340+
@cfy.pass_logger
341+
def local_list(blueprint_id, logger):
342+
"""Execute a workflow
343+
344+
`WORKFLOW_ID` is the id of the workflow to execute (e.g. `uninstall`)
345+
"""
346+
env = local.load_env(blueprint_id)
347+
executions = env.storage.get_executions()
348+
print_data(LOCAL_EXECUTION_COLUMNS, executions, 'Executions:',
349+
labels=EXECUTION_TABLE_LABELS)
350+
351+
352+
@cfy.command(name='get',
353+
short_help='Retrieve execution information')
354+
@cfy.argument('execution-id')
355+
@cfy.options.blueprint_id(required=True)
356+
@cfy.options.common_options
357+
@cfy.pass_logger
358+
def local_get(execution_id, blueprint_id, logger):
359+
"""Retrieve information for a specific execution
360+
361+
`EXECUTION_ID` is the execution to get information on.
362+
"""
363+
env = local.load_env(blueprint_id)
364+
execution = env.storage.get_execution(execution_id)
365+
if not execution:
366+
raise CloudifyCliError('Execution {0} not found'.format(execution_id))
367+
columns = LOCAL_EXECUTION_COLUMNS
368+
if get_global_json_output():
369+
columns += ['parameters']
370+
print_single(LOCAL_EXECUTION_COLUMNS, execution, 'Execution:',
371+
labels=EXECUTION_TABLE_LABELS)
372+
if not get_global_json_output():
373+
print_details(execution['parameters'], 'Execution Parameters:')
374+
375+
336376
@cfy.command(name='start',
337377
short_help='Execute a workflow')
338378
@cfy.argument('workflow-id')

cloudify_cli/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ def _register_commands():
114114
deployments.deployments.add_command(deployments.manager_set_visibility)
115115

116116
executions.executions.add_command(executions.manager_cancel)
117-
executions.executions.add_command(executions.manager_list)
118-
executions.executions.add_command(executions.manager_get)
119117

120118
# Commands which should be both in manager and local context
121119
# But change depending on the context.
@@ -129,6 +127,8 @@ def _register_commands():
129127
deployments.deployments.add_command(deployments.manager_capabilities)
130128

131129
executions.executions.add_command(executions.manager_start)
130+
executions.executions.add_command(executions.manager_list)
131+
executions.executions.add_command(executions.manager_get)
132132

133133
blueprints.blueprints.add_command(blueprints.manager_list)
134134
else:
@@ -140,6 +140,8 @@ def _register_commands():
140140
deployments.deployments.add_command(deployments.local_outputs)
141141

142142
executions.executions.add_command(executions.local_start)
143+
executions.executions.add_command(executions.local_list)
144+
executions.executions.add_command(executions.local_get)
143145

144146
blueprints.blueprints.add_command(blueprints.local_list)
145147

0 commit comments

Comments
 (0)