Skip to content

Commit 03668f9

Browse files
tehasdfidob-cloudify
authored andcommitted
Add missing cfy executions resume (#908)
Frontend for the client.executions.resume call
1 parent 07d8c90 commit 03668f9

4 files changed

Lines changed: 38 additions & 0 deletions

File tree

cloudify_cli/cli/cfy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,13 @@ def __init__(self):
10151015
help=helptexts.QUEUE_EXECUTIONS
10161016
)
10171017

1018+
self.reset_operations = click.option(
1019+
'--reset-operations',
1020+
is_flag=True,
1021+
default=False,
1022+
help=helptexts.RESET_OPERATIONS
1023+
)
1024+
10181025
self.schedule = click.option(
10191026
'--schedule',
10201027
cls=MutuallyExclusiveOption,

cloudify_cli/cli/helptexts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,5 @@
314314

315315
WAIT_AFTER_FAIL = 'When a task fails, wait this many seconds for ' \
316316
'already-running tasks to return'
317+
RESET_OPERATIONS = 'Reset operations in started state, so that they are '\
318+
'ran again unconditionally'

cloudify_cli/commands/executions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,34 @@ def manager_cancel(execution_id, force, kill, logger, client, tenant_name):
341341
"cfy executions get {0}".format(execution_id))
342342

343343

344+
@cfy.command(name='resume',
345+
short_help='Resume a workflow execution [manager only]')
346+
@cfy.argument('execution-id')
347+
@cfy.options.common_options
348+
@cfy.options.reset_operations
349+
@cfy.options.tenant_name(required=False, resource_name_for_help='execution')
350+
@cfy.assert_manager_active()
351+
@cfy.pass_client()
352+
@cfy.pass_logger
353+
def manager_resume(execution_id, reset_operations, logger, client,
354+
tenant_name):
355+
"""Resume the execution of a workflow in a failed or cancelled state.
356+
357+
`EXECUTION_ID` is the ID of the execution to resume.
358+
The workflow will run again, restoring the tasks graph from the storage,
359+
and retrying failed tasks when necessary.
360+
If reset-operations is passed, tasks that were started but didn't fail
361+
will be retried as well.
362+
"""
363+
utils.explicit_tenant_name_message(tenant_name, logger)
364+
logger.info('Resuming execution {0}'.format(execution_id))
365+
client.executions.resume(execution_id, force=reset_operations)
366+
logger.info(
367+
"A resume request for execution {0} has been sent. "
368+
"To track the execution's status, use:\n"
369+
"cfy executions get {0}".format(execution_id))
370+
371+
344372
@cfy.command(name='list',
345373
short_help='List deployment executions')
346374
@cfy.options.blueprint_id(required=True)

cloudify_cli/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def _register_commands():
129129
executions.executions.add_command(executions.manager_get)
130130

131131
blueprints.blueprints.add_command(blueprints.manager_list)
132+
executions.executions.add_command(executions.manager_resume)
132133
else:
133134
_cfy.add_command(install.local)
134135
_cfy.add_command(uninstall.local)

0 commit comments

Comments
 (0)