Merge "remove the CONF.allow_migrate_to_same_host"

This commit is contained in:
Jenkins 2015-04-23 13:46:28 +00:00 committed by Gerrit Code Review
commit 49cec4c74f
9 changed files with 19 additions and 19 deletions

View File

@ -88,10 +88,6 @@ compute_opts = [
default=False, default=False,
help='Allow destination machine to match source for resize. ' help='Allow destination machine to match source for resize. '
'Useful when testing in single-host environments.'), 'Useful when testing in single-host environments.'),
cfg.BoolOpt('allow_migrate_to_same_host',
default=False,
help='Allow migrate machine to the same host. '
'Useful when testing in single-host environments.'),
cfg.StrOpt('default_schedule_zone', cfg.StrOpt('default_schedule_zone',
help='Availability zone to use when user doesn\'t specify one'), help='Availability zone to use when user doesn\'t specify one'),
cfg.ListOpt('non_inheritable_image_properties', cfg.ListOpt('non_inheritable_image_properties',
@ -2643,10 +2639,6 @@ class API(base.Base):
if not CONF.allow_resize_to_same_host: if not CONF.allow_resize_to_same_host:
filter_properties['ignore_hosts'].append(instance.host) filter_properties['ignore_hosts'].append(instance.host)
# Here when flavor_id is None, the process is considered as migrate.
if (not flavor_id and not CONF.allow_migrate_to_same_host):
filter_properties['ignore_hosts'].append(instance.host)
if self.cell_type == 'api': if self.cell_type == 'api':
# Commit reservations early and create migration record. # Commit reservations early and create migration record.
self._resize_cells_support(context, quotas, instance, self._resize_cells_support(context, quotas, instance,

View File

@ -3828,7 +3828,13 @@ class ComputeManager(manager.Manager):
raise exception.MigrationError(reason=msg) raise exception.MigrationError(reason=msg)
same_host = instance.host == self.host same_host = instance.host == self.host
if same_host and not CONF.allow_resize_to_same_host: # if the flavor IDs match, it's migrate; otherwise resize
if same_host and instance_type['id'] == instance['instance_type_id']:
# check driver whether support migrate to same host
if not self.driver.capabilities['supports_migrate_to_same_host']:
raise exception.UnableToMigrateToSelf(
instance_id=instance.uuid, host=self.host)
elif same_host and not CONF.allow_resize_to_same_host:
self._set_instance_error_state(context, instance) self._set_instance_error_state(context, instance)
msg = _('destination same as source!') msg = _('destination same as source!')
raise exception.MigrationError(reason=msg) raise exception.MigrationError(reason=msg)

View File

@ -1246,7 +1246,6 @@ class _ComputeAPIUnitTestMixIn(object):
def _test_resize(self, flavor_id_passed=True, def _test_resize(self, flavor_id_passed=True,
same_host=False, allow_same_host=False, same_host=False, allow_same_host=False,
allow_mig_same_host=False,
project_id=None, project_id=None,
extra_kwargs=None, extra_kwargs=None,
same_flavor=False, same_flavor=False,
@ -1254,8 +1253,7 @@ class _ComputeAPIUnitTestMixIn(object):
if extra_kwargs is None: if extra_kwargs is None:
extra_kwargs = {} extra_kwargs = {}
self.flags(allow_resize_to_same_host=allow_same_host, self.flags(allow_resize_to_same_host=allow_same_host)
allow_migrate_to_same_host=allow_mig_same_host)
params = {} params = {}
if project_id is not None: if project_id is not None:
@ -1312,8 +1310,6 @@ class _ComputeAPIUnitTestMixIn(object):
else: else:
filter_properties = {'ignore_hosts': [fake_inst['host']]} filter_properties = {'ignore_hosts': [fake_inst['host']]}
if not flavor_id_passed and not allow_mig_same_host:
filter_properties['ignore_hosts'].append(fake_inst['host'])
if flavor_id_passed: if flavor_id_passed:
expected_reservations = fake_quotas.reservations expected_reservations = fake_quotas.reservations
else: else:

View File

@ -306,6 +306,8 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
def test_driver_capabilities(self): def test_driver_capabilities(self):
self.assertTrue(self.conn.capabilities['has_imagecache']) self.assertTrue(self.conn.capabilities['has_imagecache'])
self.assertFalse(self.conn.capabilities['supports_recreate']) self.assertFalse(self.conn.capabilities['supports_recreate'])
self.assertTrue(
self.conn.capabilities['supports_migrate_to_same_host'])
def test_configuration_linked_clone(self): def test_configuration_linked_clone(self):
self.flags(use_linked_clone=None, group='vmware') self.flags(use_linked_clone=None, group='vmware')

View File

@ -136,7 +136,8 @@ class ComputeDriver(object):
capabilities = { capabilities = {
"has_imagecache": False, "has_imagecache": False,
"supports_recreate": False, "supports_recreate": False,
} "supports_migrate_to_same_host": False
}
def __init__(self, virtapi): def __init__(self, virtapi):
self.virtapi = virtapi self.virtapi = virtapi

View File

@ -125,6 +125,7 @@ class FakeDriver(driver.ComputeDriver):
capabilities = { capabilities = {
"has_imagecache": True, "has_imagecache": True,
"supports_recreate": True, "supports_recreate": True,
"supports_migrate_to_same_host": True
} }
# Since we don't have a real hypervisor, pretend we have lots of # Since we don't have a real hypervisor, pretend we have lots of

View File

@ -162,7 +162,8 @@ class IronicDriver(virt_driver.ComputeDriver):
"""Hypervisor driver for Ironic - bare metal provisioning.""" """Hypervisor driver for Ironic - bare metal provisioning."""
capabilities = {"has_imagecache": False, capabilities = {"has_imagecache": False,
"supports_recreate": False} "supports_recreate": False,
"supports_migrate_to_same_host": False}
def __init__(self, virtapi, read_only=False): def __init__(self, virtapi, read_only=False):
super(IronicDriver, self).__init__(virtapi) super(IronicDriver, self).__init__(virtapi)

View File

@ -381,11 +381,11 @@ MIN_LIBVIRT_PARALLELS_VERSION = (1, 2, 12)
class LibvirtDriver(driver.ComputeDriver): class LibvirtDriver(driver.ComputeDriver):
capabilities = { capabilities = {
"has_imagecache": True, "has_imagecache": True,
"supports_recreate": True, "supports_recreate": True,
} "supports_migrate_to_same_host": False
}
def __init__(self, virtapi, read_only=False): def __init__(self, virtapi, read_only=False):
super(LibvirtDriver, self).__init__(virtapi) super(LibvirtDriver, self).__init__(virtapi)

View File

@ -110,7 +110,8 @@ class VMwareVCDriver(driver.ComputeDriver):
capabilities = { capabilities = {
"has_imagecache": True, "has_imagecache": True,
"supports_recreate": False, "supports_recreate": False,
} "supports_migrate_to_same_host": True
}
# The vCenter driver includes API that acts on ESX hosts or groups # The vCenter driver includes API that acts on ESX hosts or groups
# of ESX hosts in clusters or non-cluster logical-groupings. # of ESX hosts in clusters or non-cluster logical-groupings.