Make LiveMigrateTask use build_request_spec()

Some filters like TrustedFilter makes use of extra_specs. Currently,
when live-migration uses the scheduler to select a host, it constructs
a request_spec that has no extra_specs in it.

By making use of the existing helper method build_request_spec(), the
request to the scheduler will include extra_specs.

Change-Id: I5bc6c6418653c256a42da7b0a343086ec9863da1
Closes-Bug: #1224014
This commit is contained in:
Hans Lindgren
2013-09-27 13:11:21 +02:00
parent 2bea97bae6
commit e80121a2c5
2 changed files with 27 additions and 42 deletions

View File

@@ -14,7 +14,6 @@
from oslo.config import cfg
from nova.compute import flavors
from nova.compute import power_state
from nova.compute import rpcapi as compute_rpcapi
from nova.compute import utils as compute_utils
@@ -25,6 +24,7 @@ from nova.objects import base as obj_base
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova.scheduler import utils as scheduler_utils
from nova import servicegroup
LOG = logging.getLogger(__name__)
@@ -152,14 +152,16 @@ class LiveMigrationTask(object):
self.image_service,
self.instance.image_ref,
self.instance)
instance_type = flavors.extract_flavor(self.instance)
instance_p = obj_base.obj_to_primitive(self.instance)
request_spec = scheduler_utils.build_request_spec(self.context, image,
[instance_p])
host = None
while host is None:
self._check_not_over_max_retries(attempted_hosts)
host = self._get_candidate_destination(image,
instance_type, attempted_hosts)
filter_properties = {'ignore_hosts': attempted_hosts}
host = self.scheduler_rpcapi.select_hosts(self.context,
request_spec, filter_properties)[0]
try:
self._check_compatible_with_source_hypervisor(host)
self._call_livem_checks_on_host(host)
@@ -170,18 +172,6 @@ class LiveMigrationTask(object):
host = None
return host
def _get_candidate_destination(self, image, instance_type,
attempted_hosts):
instance_p = obj_base.obj_to_primitive(self.instance)
request_spec = {'instance_properties': instance_p,
'instance_type': instance_type,
'instance_uuids': [self.instance.uuid]}
if image:
request_spec['image'] = image
filter_properties = {'ignore_hosts': attempted_hosts}
return self.scheduler_rpcapi.select_hosts(self.context,
request_spec, filter_properties)[0]
def _check_not_over_max_retries(self, attempted_hosts):
if CONF.migrate_max_retries == -1:
return