Handles exception when unsupported virt-type given

When a wrong virt type is configured in nova configuration files
there is no mechaninsm to tell to the user about the unsupported
virt type.  This fix throws an unsupported virt type expection
to the user if a wrong virt type is configured in the configs.

Change-Id: I794a7c37d7a6224235a7fcb649f7db418687a794
Closes-Bug: #1425571
This commit is contained in:
Anand Shanmugam 2015-03-11 01:02:22 +05:30
parent e5ed57dc3f
commit 2ffcd15192
2 changed files with 10 additions and 0 deletions

View File

@ -654,6 +654,13 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
for res, args in expected:
self.assertEqual(res, blockinfo.get_disk_bus_for_disk_dev(*args))
def test_fail_get_disk_bus_for_disk_dev_unsupported_virt_type(self):
image_meta = {}
self.assertRaises(exception.UnsupportedVirtType,
blockinfo.get_disk_bus_for_device_type,
'kvm1',
image_meta)
def test_fail_get_disk_bus_for_disk_dev(self):
self.assertRaises(exception.NovaException,
blockinfo.get_disk_bus_for_disk_dev, 'inv', 'val')

View File

@ -266,6 +266,9 @@ def get_disk_bus_for_device_type(virt_type,
return "ide"
elif device_type == "disk":
return "sata"
else:
# If virt-type not in list then it is unsupported
raise exception.UnsupportedVirtType(virt=virt_type)
return None