Merge "Add new APIs and deprecate old API for migrations"

This commit is contained in:
Jenkins 2016-02-26 18:07:47 +00:00 committed by Gerrit Code Review
commit 7ddec4256d
2 changed files with 24 additions and 0 deletions

View File

@ -511,6 +511,13 @@ def migration_get_all_by_filters(context, filters):
return IMPL.migration_get_all_by_filters(context, filters)
def migration_get_in_progress_by_instance(context, instance_uuid,
migration_type=None):
"""Finds all migrations of an instance in progress."""
return IMPL.migration_get_in_progress_by_instance(context, instance_uuid,
migration_type)
####################

View File

@ -4547,6 +4547,23 @@ def migration_get_in_progress_by_host_and_node(context, host, node):
all()
@main_context_manager.reader
def migration_get_in_progress_by_instance(context, instance_uuid,
migration_type=None):
# TODO(Shaohe Feng) we should share the in-progress list.
# TODO(Shaohe Feng) will also summarize all status to a new
# MigrationStatus class.
query = model_query(context, models.Migration).\
filter_by(instance_uuid=instance_uuid).\
filter(models.Migration.status.in_(['queued', 'preparing',
'running',
'post-migrating']))
if migration_type:
query = query.filter(models.Migration.migration_type == migration_type)
return query.all()
@main_context_manager.reader
def migration_get_all_by_filters(context, filters):
query = model_query(context, models.Migration)