Merge "Add cross cell sort support for get_migrations"
This commit is contained in:
commit
3a95271807
@ -584,6 +584,17 @@ def migration_get_in_progress_by_instance(context, instance_uuid,
|
||||
migration_type)
|
||||
|
||||
|
||||
def migration_get_by_sort_filters(context, sort_keys, sort_dirs, values):
|
||||
"""Get the uuid of the first migration in a sort order.
|
||||
|
||||
Return the first migration (uuid) of the set where each column value
|
||||
is greater than or equal to the matching one in @values, for each key
|
||||
in @sort_keys.
|
||||
"""
|
||||
return IMPL.migration_get_by_sort_filters(context, sort_keys, sort_dirs,
|
||||
values)
|
||||
|
||||
|
||||
####################
|
||||
|
||||
|
||||
|
@ -2268,6 +2268,12 @@ def instance_get_by_sort_filters(context, sort_keys, sort_dirs, values):
|
||||
"""
|
||||
|
||||
model = models.Instance
|
||||
return _model_get_uuid_by_sort_filters(context, model, sort_keys,
|
||||
sort_dirs, values)
|
||||
|
||||
|
||||
def _model_get_uuid_by_sort_filters(context, model, sort_keys, sort_dirs,
|
||||
values):
|
||||
query = context.session.query(model.uuid)
|
||||
|
||||
# NOTE(danms): Below is a re-implementation of our
|
||||
@ -4398,6 +4404,12 @@ def migration_get_all_by_filters(context, filters,
|
||||
return []
|
||||
|
||||
query = model_query(context, models.Migration)
|
||||
if "uuid" in filters:
|
||||
# The uuid filter is here for the MigrationLister and multi-cell
|
||||
# paging support in the compute API.
|
||||
uuid = filters["uuid"]
|
||||
uuid = [uuid] if isinstance(uuid, six.string_types) else uuid
|
||||
query = query.filter(models.Migration.uuid.in_(uuid))
|
||||
if 'changes-since' in filters:
|
||||
changes_since = timeutils.normalize_time(filters['changes-since'])
|
||||
query = query. \
|
||||
@ -4441,6 +4453,20 @@ def migration_get_all_by_filters(context, filters,
|
||||
return query.all()
|
||||
|
||||
|
||||
@require_context
|
||||
@pick_context_manager_reader_allow_async
|
||||
def migration_get_by_sort_filters(context, sort_keys, sort_dirs, values):
|
||||
"""Attempt to get a single migration based on a combination of sort
|
||||
keys, directions and filter values. This is used to try to find a
|
||||
marker migration when we don't have a marker uuid.
|
||||
|
||||
This returns just a uuid of the migration that matched.
|
||||
"""
|
||||
model = models.Migration
|
||||
return _model_get_uuid_by_sort_filters(context, model, sort_keys,
|
||||
sort_dirs, values)
|
||||
|
||||
|
||||
@pick_context_manager_writer
|
||||
def migration_migrate_to_uuid(context, count):
|
||||
# Avoid circular import
|
||||
|
Loading…
x
Reference in New Issue
Block a user