summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-11-22 08:59:36 +0000
committerGerrit Code Review <review@openstack.org>2012-11-22 08:59:36 +0000
commitd0432fabc8e5893fe1f7f043cd368836acaee087 (patch)
tree0863a6008cd53cb811e5e1d97580e052c62cbfe3
parentc45915391647ddf7798d46c50649d155985799ac (diff)
parent7c5c8a743c21733120c85fdefb84b4357f5848d0 (diff)
downloadnova-d0432fabc8e5893fe1f7f043cd368836acaee087.tar.gz
nova-d0432fabc8e5893fe1f7f043cd368836acaee087.tar.xz
nova-d0432fabc8e5893fe1f7f043cd368836acaee087.zip
Merge "Xenapi: Don't resize down if not auto_disk_config"
-rw-r--r--nova/exception.py4
-rw-r--r--nova/tests/test_xenapi.py14
-rw-r--r--nova/virt/xenapi/vmops.py6
3 files changed, 22 insertions, 2 deletions
diff --git a/nova/exception.py b/nova/exception.py
index 54b3a17cc..68bc294a3 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -865,6 +865,10 @@ class CannotResizeToSameFlavor(NovaException):
message = _("When resizing, instances must change flavor!")
+class ResizeError(NovaException):
+ message = _("Resize error: %(reason)s")
+
+
class ImageTooLarge(NovaException):
message = _("Image is larger than instance type allows")
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 971850aa7..b139f2d11 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -1255,6 +1255,20 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
dict(base_copy='hurr', cow='durr'),
network_info, image_meta, resize_instance=False)
+ def test_migrate_no_auto_disk_config_no_resize_down(self):
+ """Resize down should fail when auto_disk_config not set"""
+ instance_values = self.instance_values
+ instance_values['root_gb'] = 40
+ instance_values['auto_disk_config'] = False
+ instance = db.instance_create(self.context, instance_values)
+ xenapi_fake.create_vm(instance.name, 'Running')
+ instance_type = db.instance_type_get_by_name(self.context, 'm1.small')
+ conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
+ self.assertRaises(exception.ResizeError,
+ conn.migrate_disk_and_power_off,
+ self.context, instance,
+ '127.0.0.1', instance_type, None)
+
class XenAPIImageTypeTestCase(test.TestCase):
"""Test ImageType class."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 4915804a9..a68c9eb8d 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -770,8 +770,10 @@ class VMOps(object):
"""
vm_ref = self._get_vm_opaque_ref(instance)
sr_path = vm_utils.get_sr_path(self._session)
- resize_down = (instance['auto_disk_config'] and
- instance['root_gb'] > instance_type['root_gb'])
+ resize_down = instance['root_gb'] > instance_type['root_gb']
+ if resize_down and not instance['auto_disk_config']:
+ reason = _('Resize down not allowed without auto_disk_config')
+ raise exception.ResizeError(reason=reason)
# 0. Zero out the progress to begin
self._update_instance_progress(context, instance,