Skip to content

Commit ec9daa3

Browse files
authored
Cy 811 add scheduled executions to cli (#891)
* Added schedule executions option to CLI * Added 'scheduled_for' column to executions list display * CLI doesn't wait for scheduled executions * dev-requirements
1 parent 93ad7b7 commit ec9daa3

3 files changed

Lines changed: 22 additions & 4 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.schedule = click.option(
1019+
'--schedule',
1020+
cls=MutuallyExclusiveOption,
1021+
mutually_exclusive=['queue'],
1022+
help=helptexts.SCHEDULE_EXECUTIONS
1023+
)
1024+
10181025
self.queue_snapshot = click.option(
10191026
'--queue',
10201027
is_flag=True,

cloudify_cli/cli/helptexts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@
297297
'run will be queued and run automatically when possible'
298298
QUEUE_EXECUTIONS = 'If set, executions that can`t currently run will be '\
299299
'queued and run automatically when possible'
300+
SCHEDULE_EXECUTIONS = 'The time (including timezone) this workflow will be' \
301+
' executed at; expected format: YYYYMMDDHHMM+HHMM or ' \
302+
'YYYYMMDDHHMM-HHMM. i.e: 201801012230-0500' \
303+
' (Jan-01-18 10:30pm EST)'
300304

301305
_MULTIPLE_TIMES_FRAGMENT = ' (can be passed multiple times, ' \
302306
'or comma-separated)'

cloudify_cli/commands/executions.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
FULL_EXECUTION_COLUMNS = ['id', 'workflow_id', 'status_display', 'is_dry_run',
3838
'deployment_id', 'created_at', 'ended_at',
3939
'error', 'visibility', 'tenant_name',
40-
'created_by', 'started_at']
40+
'created_by', 'started_at', 'scheduled_for']
4141
MINIMAL_EXECUTION_COLUMNS = ['id', 'workflow_id', 'status_display',
4242
'is_dry_run',
4343
'deployment_id', 'created_at', 'started_at',
44-
'visibility', 'tenant_name',
44+
'scheduled_for', 'visibility', 'tenant_name',
4545
'created_by']
4646
EXECUTION_TABLE_LABELS = {'status_display': 'status'}
4747

@@ -168,6 +168,7 @@ def manager_list(
168168
@cfy.options.wait_after_fail
169169
@cfy.options.common_options
170170
@cfy.options.tenant_name(required=False, resource_name_for_help='execution')
171+
@cfy.options.schedule
171172
@cfy.options.queue
172173
@cfy.assert_manager_active()
173174
@cfy.pass_client()
@@ -183,6 +184,7 @@ def manager_start(workflow_id,
183184
dry_run,
184185
wait_after_fail,
185186
queue,
187+
schedule,
186188
logger,
187189
client,
188190
tenant_name):
@@ -209,7 +211,8 @@ def manager_start(workflow_id,
209211
force=force,
210212
dry_run=dry_run,
211213
queue=queue,
212-
wait_after_fail=wait_after_fail)
214+
wait_after_fail=wait_after_fail,
215+
schedule=schedule)
213216
except (exceptions.DeploymentEnvironmentCreationInProgressError,
214217
exceptions.DeploymentEnvironmentCreationPendingError) as e:
215218
# wait for deployment environment creation workflow
@@ -242,12 +245,16 @@ def manager_start(workflow_id,
242245
force=force,
243246
dry_run=dry_run,
244247
queue=queue,
245-
wait_after_fail=wait_after_fail)
248+
wait_after_fail=wait_after_fail,
249+
schedule=schedule)
246250

247251
if execution.status == 'queued': # We don't need to wait for execution
248252
logger.info('Execution is being queued. It will automatically'
249253
' start when possible.')
250254
return
255+
if execution.status == 'scheduled':
256+
logger.info('Execution is scheduled for {0}.'.format(schedule))
257+
return
251258
execution = wait_for_execution(client,
252259
execution,
253260
events_handler=events_logger,

0 commit comments

Comments
 (0)