diff options
author | Guan Qiang <hzguanqiang@corp.netease.com> | 2013-03-26 17:47:11 +0800 |
---|---|---|
committer | Guan Qiang <hzguanqiang@corp.netease.com> | 2013-03-28 13:37:51 +0800 |
commit | 0fe9beb7c0ae763c9d5bfd8598ec7e79b2fbf42c (patch) | |
tree | b717b4e39fc02233a48133d6e9b6aae390930c69 /nova/compute | |
parent | 5b075b0a364dc1f9259ded105e08e1982e0fee08 (diff) | |
download | nova-0fe9beb7c0ae763c9d5bfd8598ec7e79b2fbf42c.tar.gz nova-0fe9beb7c0ae763c9d5bfd8598ec7e79b2fbf42c.tar.xz nova-0fe9beb7c0ae763c9d5bfd8598ec7e79b2fbf42c.zip |
Fix migrating instance to the same host.
In current code logic, Migration to the same host is allowed which is
meaningless.
In the patch, a Conf flag 'allow_migrate_to_same_host' is added and set to
false as default. When 'allow_migrate_to_same_host' is false, the current
instance host will be added into filter property 'ignore_hosts' to avoid
migrating instance to the same host.
Fixes: bug #1160268
Change-Id: I5ac0391cf468310a89fb6d8a8f5120c5654cb4ff
Diffstat (limited to 'nova/compute')
-rw-r--r-- | nova/compute/api.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 30b4e73e0..3a093774a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -68,6 +68,10 @@ compute_opts = [ 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', default=None, help='availability zone to use when user doesn\'t specify one'), @@ -2035,6 +2039,10 @@ class API(base.Base): 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']) + # With cells, the best we can do right now is commit the reservations # immediately... if CONF.cells.enable and reservations: |