summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-11 14:02:18 +0000
committerGerrit Code Review <review@openstack.org>2013-03-11 14:02:18 +0000
commitf543f347c84e7f5de2c584ca55363e4dee5b0a3d (patch)
tree3c724ba1280cbfd4ac43df75f64379b9a363d494
parente78528e113c3a8bb8900052f6db2c0ca2c05c9f9 (diff)
parent3d7d819f6420857c9e0d31c83a130fc6dc9aff64 (diff)
downloadnova-f543f347c84e7f5de2c584ca55363e4dee5b0a3d.tar.gz
nova-f543f347c84e7f5de2c584ca55363e4dee5b0a3d.tar.xz
nova-f543f347c84e7f5de2c584ca55363e4dee5b0a3d.zip
Merge "Correct exception args in vfs/guestfs."
-rw-r--r--nova/tests/test_virt_disk_vfs_guestfs.py27
-rw-r--r--nova/virt/disk/vfs/guestfs.py6
2 files changed, 30 insertions, 3 deletions
diff --git a/nova/tests/test_virt_disk_vfs_guestfs.py b/nova/tests/test_virt_disk_vfs_guestfs.py
index 1ff2581e7..16c85f815 100644
--- a/nova/tests/test_virt_disk_vfs_guestfs.py
+++ b/nova/tests/test_virt_disk_vfs_guestfs.py
@@ -16,6 +16,7 @@
import sys
+from nova import exception
from nova import test
from nova.tests import fakeguestfs
@@ -51,6 +52,32 @@ class VirtDiskVFSGuestFSTest(test.TestCase):
self.assertEqual(handle.closed, True)
self.assertEqual(len(handle.mounts), 0)
+ def test_appliance_setup_inspect_no_root_raises(self):
+ vfs = vfsimpl.VFSGuestFS(imgfile="/dummy.qcow2",
+ imgfmt="qcow2",
+ partition=-1)
+ # call setup to init the handle so we can stub it
+ vfs.setup()
+
+ def fake_inspect_os():
+ return []
+
+ self.stubs.Set(vfs.handle, 'inspect_os', fake_inspect_os)
+ self.assertRaises(exception.NovaException, vfs.setup_os_inspect)
+
+ def test_appliance_setup_inspect_multi_boots_raises(self):
+ vfs = vfsimpl.VFSGuestFS(imgfile="/dummy.qcow2",
+ imgfmt="qcow2",
+ partition=-1)
+ # call setup to init the handle so we can stub it
+ vfs.setup()
+
+ def fake_inspect_os():
+ return ['fake1', 'fake2']
+
+ self.stubs.Set(vfs.handle, 'inspect_os', fake_inspect_os)
+ self.assertRaises(exception.NovaException, vfs.setup_os_inspect)
+
def test_appliance_setup_static_nopart(self):
vfs = vfsimpl.VFSGuestFS(imgfile="/dummy.qcow2",
imgfmt="qcow2",
diff --git a/nova/virt/disk/vfs/guestfs.py b/nova/virt/disk/vfs/guestfs.py
index 985858a0d..5be2b0d37 100644
--- a/nova/virt/disk/vfs/guestfs.py
+++ b/nova/virt/disk/vfs/guestfs.py
@@ -65,13 +65,13 @@ class VFSGuestFS(vfs.VFS):
roots = self.handle.inspect_os()
if len(roots) == 0:
- raise exception.NovaException(_("No operating system found in %s"),
- self.imgfile)
+ raise exception.NovaException(_("No operating system found in %s")
+ % self.imgfile)
if len(roots) != 1:
LOG.debug(_("Multi-boot OS %(roots)s") % {'roots': str(roots)})
raise exception.NovaException(
- _("Multi-boot operating system found in %s"),
+ _("Multi-boot operating system found in %s") %
self.imgfile)
self.setup_os_root(roots[0])