From e1f8fe8dc9187a841480e28d21503e5e6d426e96 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Fri, 22 Jan 2016 18:47:28 +1300 Subject: [PATCH] Support workflow id for cron trigger creation Change-Id: I59eacf4b8ecc3f777064d51d9660d86f165de8d9 --- mistralclient/api/v2/cron_triggers.py | 12 +++++++++--- mistralclient/commands/v2/cron_triggers.py | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mistralclient/api/v2/cron_triggers.py b/mistralclient/api/v2/cron_triggers.py index 1e5aa024..036b1d17 100644 --- a/mistralclient/api/v2/cron_triggers.py +++ b/mistralclient/api/v2/cron_triggers.py @@ -14,6 +14,8 @@ import json +from oslo_utils import uuidutils + from mistralclient.api import base @@ -24,22 +26,26 @@ class CronTrigger(base.Resource): class CronTriggerManager(base.ResourceManager): resource_class = CronTrigger - def create(self, name, workflow_name, workflow_input=None, + def create(self, name, workflow_identifier, workflow_input=None, workflow_params=None, pattern=None, first_time=None, count=None): self._ensure_not_empty( name=name, - workflow_name=workflow_name + workflow_identifier=workflow_identifier ) data = { 'name': name, - 'workflow_name': workflow_name, 'pattern': pattern, 'first_execution_time': first_time, 'remaining_executions': count } + if uuidutils.is_uuid_like(workflow_identifier): + data.update({'workflow_id': workflow_identifier}) + else: + data.update({'workflow_name': workflow_identifier}) + if workflow_input: data.update({'workflow_input': json.dumps(workflow_input)}) diff --git a/mistralclient/commands/v2/cron_triggers.py b/mistralclient/commands/v2/cron_triggers.py index 1a90056d..5a067aa9 100644 --- a/mistralclient/commands/v2/cron_triggers.py +++ b/mistralclient/commands/v2/cron_triggers.py @@ -105,7 +105,7 @@ class Create(show.ShowOne): parser = super(Create, self).get_parser(prog_name) parser.add_argument('name', help='Cron trigger name') - parser.add_argument('workflow_name', help='Workflow name') + parser.add_argument('workflow_identifier', help='Workflow name or ID') parser.add_argument( 'workflow_input', @@ -157,7 +157,7 @@ class Create(show.ShowOne): trigger = mistral_client.cron_triggers.create( parsed_args.name, - parsed_args.workflow_name, + parsed_args.workflow_identifier, wf_input, wf_params, parsed_args.pattern,