Merge "Refactor LiveMigrationTask._find_destination"

This commit is contained in:
Jenkins 2017-09-06 07:50:40 +00:00 committed by Gerrit Code Review
commit 1c1ea2b19e
1 changed files with 18 additions and 3 deletions

View File

@ -286,9 +286,16 @@ class LiveMigrationTask(base.TaskBase):
reason=(_('Unable to determine in which cell '
'destination host %s lives.') % self.destination))
def _find_destination(self):
# TODO(johngarbutt) this retry loop should be shared
attempted_hosts = [self.source]
def _get_request_spec_for_select_destinations(self, attempted_hosts=None):
"""Builds a RequestSpec that can be passed to select_destinations
Used when calling the scheduler to pick a destination host for live
migrating the instance.
:param attempted_hosts: List of host names to ignore in the scheduler.
This is generally at least seeded with the source host.
:returns: nova.objects.RequestSpec object
"""
image = utils.get_image_from_system_metadata(
self.instance.system_metadata)
filter_properties = {'ignore_hosts': attempted_hosts}
@ -324,6 +331,14 @@ class LiveMigrationTask(base.TaskBase):
request_spec.requested_destination = objects.Destination(
cell=cell_mapping)
return request_spec
def _find_destination(self):
# TODO(johngarbutt) this retry loop should be shared
attempted_hosts = [self.source]
request_spec = self._get_request_spec_for_select_destinations(
attempted_hosts)
host = None
while host is None:
self._check_not_over_max_retries(attempted_hosts)