Support workflow list

Change-Id: I28e3ceffba3eb2bb75e5c282ee91feeca25769b1
Partial-Implements: blueprint workflow
This commit is contained in:
lawrancejing 2015-11-20 12:48:29 +00:00
parent bf30391841
commit f2245c0b1a
6 changed files with 31 additions and 0 deletions

View File

@ -26,3 +26,9 @@ class Controller(rest.RestController):
name=kwargs['name'], wf_spec=kwargs['wf_spec'])
return workflow
@pecan.expose('json')
def get_all(self):
workflows = pecan.request.workflow_api.workflow_list()
return workflows

View File

@ -50,6 +50,12 @@ def workflow_create(context, values):
return IMPL.workflow_create(context, values)
def workflow_get_all(context, filters=None, limit=None, marker=None,
sort_key=None, sort_dir=None):
return IMPL.workflow_get_all(context, filters=None, limit=None,
marker=None, sort_key=None, sort_dir=None)
# Utils
def db_sync(engine, version=None):
"""Migrate the database to `version` or the most recent version."""

View File

@ -97,6 +97,13 @@ def workflow_create(context, values):
return workflow_ref
def workflow_get_all(context, filters=None, limit=None, marker=None,
sort_key=None, sort_dir=None):
query = model_query(models.Workflow)
return _paginate_query(models.Workflow, limit, marker,
sort_key, sort_dir, query)
# Utils
def db_sync(engine, version=None):
"""Migrate the database to `version` or the most recent version."""

View File

@ -20,3 +20,6 @@ class API(rpc_service.API):
def workflow_create(self, name, wf_spec):
return self._call('workflow_create', name=name, wf_spec=wf_spec)
def workflow_list(self):
return self._call('workflow_list')

View File

@ -23,3 +23,8 @@ class Handler(object):
workflow = self.workflow_driver.workflow_create(
context, name, wf_spec)
return {'workflow': workflow}
def workflow_list(self, context):
workflows = self.workflow_driver.workflow_list(
context)
return {'workflows': workflows}

View File

@ -31,3 +31,7 @@ class Workflow(workflow.Base):
}
workflow = db_api.workflow_create(context, values)
return workflow
def workflow_list(self, context):
workflows = db_api.workflow_get_all(context)
return workflows