Add instance action db and obj pagination support.
This will be used by instance action pagination API. Add limit/marker/filters support to get_by_instance_uuid of InstanceActionList object, also add limit/marker/filters support to actions_get method of db. Part of blueprint pagination-add-changes-since-for-instance-action-list Change-Id: Ic7dd6480a4b250ae6529d94ee0386b5e95b0ca04
This commit is contained in:
parent
612db97f4b
commit
520b121d20
@ -1953,9 +1953,10 @@ def action_finish(context, values):
|
||||
return IMPL.action_finish(context, values)
|
||||
|
||||
|
||||
def actions_get(context, uuid):
|
||||
"""Get all instance actions for the provided instance."""
|
||||
return IMPL.actions_get(context, uuid)
|
||||
def actions_get(context, instance_uuid, limit=None, marker=None,
|
||||
filters=None):
|
||||
"""Get all instance actions for the provided instance and filters."""
|
||||
return IMPL.actions_get(context, instance_uuid, limit, marker, filters)
|
||||
|
||||
|
||||
def action_get_by_request_id(context, uuid, request_id):
|
||||
|
@ -6227,12 +6227,30 @@ def action_finish(context, values):
|
||||
|
||||
|
||||
@pick_context_manager_reader
|
||||
def actions_get(context, instance_uuid):
|
||||
"""Get all instance actions for the provided uuid."""
|
||||
actions = model_query(context, models.InstanceAction).\
|
||||
filter_by(instance_uuid=instance_uuid).\
|
||||
order_by(desc("created_at"), desc("id")).\
|
||||
all()
|
||||
def actions_get(context, instance_uuid, limit=None, marker=None,
|
||||
filters=None):
|
||||
"""Get all instance actions for the provided uuid and filters."""
|
||||
if limit == 0:
|
||||
return []
|
||||
|
||||
sort_keys = ['created_at', 'id']
|
||||
sort_dirs = ['desc', 'desc']
|
||||
|
||||
query_prefix = model_query(context, models.InstanceAction).\
|
||||
filter_by(instance_uuid=instance_uuid)
|
||||
if filters and 'changes-since' in filters:
|
||||
changes_since = timeutils.normalize_time(filters['changes-since'])
|
||||
query_prefix = query_prefix. \
|
||||
filter(models.InstanceAction.updated_at >= changes_since)
|
||||
|
||||
if marker is not None:
|
||||
marker = action_get_by_request_id(context, instance_uuid, marker)
|
||||
if not marker:
|
||||
raise exception.MarkerNotFound(marker=marker)
|
||||
actions = sqlalchemyutils.paginate_query(query_prefix,
|
||||
models.InstanceAction, limit,
|
||||
sort_keys, marker=marker,
|
||||
sort_dirs=sort_dirs).all()
|
||||
return actions
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user