Skip to content

Commit

Permalink
remove the CONF.allow_migrate_to_same_host
Browse files Browse the repository at this point in the history
When running the "migrate" operation and the
CONF.allow_resize_to_same_host is set as "false",
the CONF.allow_migrate_to_same_host doesn't work
in the function 'resize' from nova/compute/api.py.
At the same time, there is no checking the
CONF.allow_migrate_to_same_host in the function
_prep_resize from nova/compute/manager.py

DocImpact: remove the CONF.allow_migrate_to_same_host
Change-Id: I4c54c7c6e0e5e37cc46c52350ba4ce2047325ef9
Closes-Bug: #1364851
  • Loading branch information
zhangchunlong committed Apr 21, 2015
1 parent c48a7da commit 9b22464
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
8 changes: 0 additions & 8 deletions nova/compute/api.py
Expand Up @@ -88,10 +88,6 @@
default=False,
help='Allow destination machine to match source for resize. '
'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',
help='Availability zone to use when user doesn\'t specify one'),
cfg.ListOpt('non_inheritable_image_properties',
Expand Down Expand Up @@ -2661,10 +2657,6 @@ def resize(self, context, instance, flavor_id=None, clean_shutdown=True,
if not CONF.allow_resize_to_same_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':
# Commit reservations early and create migration record.
self._resize_cells_support(context, quotas, instance,
Expand Down
8 changes: 7 additions & 1 deletion nova/compute/manager.py
Expand Up @@ -3685,7 +3685,13 @@ def _prep_resize(self, context, image, instance, instance_type,
raise exception.MigrationError(reason=msg)

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)
msg = _('destination same as source!')
raise exception.MigrationError(reason=msg)
Expand Down
6 changes: 1 addition & 5 deletions nova/tests/unit/compute/test_compute_api.py
Expand Up @@ -1375,16 +1375,14 @@ def test_revert_resize_concurent_fail(self):

def _test_resize(self, flavor_id_passed=True,
same_host=False, allow_same_host=False,
allow_mig_same_host=False,
project_id=None,
extra_kwargs=None,
same_flavor=False,
clean_shutdown=True):
if extra_kwargs is None:
extra_kwargs = {}

self.flags(allow_resize_to_same_host=allow_same_host,
allow_migrate_to_same_host=allow_mig_same_host)
self.flags(allow_resize_to_same_host=allow_same_host)

params = {}
if project_id is not None:
Expand Down Expand Up @@ -1441,8 +1439,6 @@ def _check_state(expected_task_state=None):
else:
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:
expected_reservations = fake_quotas.reservations
else:
Expand Down
2 changes: 2 additions & 0 deletions nova/tests/unit/virt/vmwareapi/test_driver_api.py
Expand Up @@ -307,6 +307,8 @@ def test_cleanup_host(self):
def test_driver_capabilities(self):
self.assertTrue(self.conn.capabilities['has_imagecache'])
self.assertFalse(self.conn.capabilities['supports_recreate'])
self.assertTrue(
self.conn.capabilities['supports_migrate_to_same_host'])

def test_configuration_linked_clone(self):
self.flags(use_linked_clone=None, group='vmware')
Expand Down
3 changes: 2 additions & 1 deletion nova/virt/driver.py
Expand Up @@ -136,7 +136,8 @@ class ComputeDriver(object):
capabilities = {
"has_imagecache": False,
"supports_recreate": False,
}
"supports_migrate_to_same_host": False
}

def __init__(self, virtapi):
self.virtapi = virtapi
Expand Down
1 change: 1 addition & 0 deletions nova/virt/fake.py
Expand Up @@ -90,6 +90,7 @@ class FakeDriver(driver.ComputeDriver):
capabilities = {
"has_imagecache": True,
"supports_recreate": True,
"supports_migrate_to_same_host": True
}

# Since we don't have a real hypervisor, pretend we have lots of
Expand Down
3 changes: 2 additions & 1 deletion nova/virt/ironic/driver.py
Expand Up @@ -159,7 +159,8 @@ class IronicDriver(virt_driver.ComputeDriver):
"""Hypervisor driver for Ironic - bare metal provisioning."""

capabilities = {"has_imagecache": False,
"supports_recreate": False}
"supports_recreate": False,
"supports_migrate_to_same_host": False}

def __init__(self, virtapi, read_only=False):
super(IronicDriver, self).__init__(virtapi)
Expand Down
4 changes: 2 additions & 2 deletions nova/virt/libvirt/driver.py
Expand Up @@ -382,11 +382,11 @@ def repr_method(self):


class LibvirtDriver(driver.ComputeDriver):

capabilities = {
"has_imagecache": True,
"supports_recreate": True,
}
"supports_migrate_to_same_host": False
}

def __init__(self, virtapi, read_only=False):
super(LibvirtDriver, self).__init__(virtapi)
Expand Down
3 changes: 2 additions & 1 deletion nova/virt/vmwareapi/driver.py
Expand Up @@ -109,7 +109,8 @@ class VMwareVCDriver(driver.ComputeDriver):
capabilities = {
"has_imagecache": True,
"supports_recreate": False,
}
"supports_migrate_to_same_host": True
}

# The vCenter driver includes API that acts on ESX hosts or groups
# of ESX hosts in clusters or non-cluster logical-groupings.
Expand Down

0 comments on commit 9b22464

Please sign in to comment.