summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorNikola Dipanov <ndipanov@redhat.com>2013-05-20 17:33:47 +0200
committerNikola Dipanov <ndipanov@redhat.com>2013-05-20 17:44:11 +0200
commit4465b705fc7cb7a150a7f8d6f70ccf6c20ff3284 (patch)
treebb612709c0f9ded7c5f9d39d139acec00233844e /nova/tests
parent5c3113b066e61cbc5d8d4d464f8200d4cb5e8395 (diff)
downloadnova-4465b705fc7cb7a150a7f8d6f70ccf6c20ff3284.tar.gz
nova-4465b705fc7cb7a150a7f8d6f70ccf6c20ff3284.tar.xz
nova-4465b705fc7cb7a150a7f8d6f70ccf6c20ff3284.zip
Fix resize when instance has no image
This patch makes it possible to resize an instance that has no image supplied (was booted from volume), by avoiding calling the image service and thus causing an uncaught exception, if there was no image suplied in the first place. Fixes bug: 1182114 blueprint: improve-boot-from-volume Change-Id: I67d63a7aef699b555897582c74b04e857db7aafb
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 3101e3aa2..36a6a36a6 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -6155,6 +6155,22 @@ class ComputeAPITestCase(BaseTestCase):
self.context, instance)
self.compute.terminate_instance(self.context, instance=instance)
+ def test_resize_no_image(self):
+ def _fake_prep_resize(_context, **args):
+ image = args['image']
+ self.assertEqual(image, {})
+
+ instance = self._create_fake_instance(params={'image_ref': ''})
+ instance = db.instance_get_by_uuid(self.context, instance['uuid'])
+ instance = jsonutils.to_primitive(instance)
+ self.compute.run_instance(self.context, instance=instance)
+
+ self.stubs.Set(self.compute_api.scheduler_rpcapi,
+ 'prep_resize', _fake_prep_resize)
+
+ self.compute_api.resize(self.context, instance, None)
+ self.compute.terminate_instance(self.context, instance=instance)
+
def test_migrate(self):
instance = self._create_fake_instance()
instance = db.instance_get_by_uuid(self.context, instance['uuid'])