diff options
| author | Wangpan <hzwangpan@corp.netease.com> | 2013-01-09 19:33:43 +0800 |
|---|---|---|
| committer | Wangpan <hzwangpan@corp.netease.com> | 2013-01-10 11:43:12 +0800 |
| commit | 67376d34ed6bf68b15ac87ef444887cbc27dc6b0 (patch) | |
| tree | aec69d3759bd5eaaae2b9f1d44a6dff9cc90e831 /nova/tests | |
| parent | 5a87a506420c31a9490fccc7eac3f02e834ef9bc (diff) | |
Map libvirt error to InstanceNotFound in get_instance_disk_info
When getting instance disk info, the instance may be destroyed/deleted, and a
libvirtError will be raised in XMLDesc method, so catching and mapping it to
InstanceNotFound and the caller can handle it correctly.
Fixes bug #1064581
Change-Id: I07fed3e82e10dad4cb84ae5c8650ada351c24e78
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_libvirt.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index cce220b20..ed7f2b509 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -4589,6 +4589,25 @@ class LibvirtDriverTestCase(test.TestCase): self.libvirtconnection._cleanup_resize(ins_ref, _fake_network_info(self.stubs, 1)) + def test_get_instance_disk_info_exception(self): + instance_name = "fake-instance-name" + + class FakeExceptionDomain(FakeVirtDomain): + def __init__(self): + super(FakeExceptionDomain, self).__init__() + + def XMLDesc(self, *args): + raise libvirt.libvirtError("Libvirt error") + + def fake_lookup_by_name(instance_name): + return FakeExceptionDomain() + + self.stubs.Set(self.libvirtconnection, '_lookup_by_name', + fake_lookup_by_name) + self.assertRaises(exception.InstanceNotFound, + self.libvirtconnection.get_instance_disk_info, + instance_name) + class LibvirtVolumeUsageTestCase(test.TestCase): """Test for nova.virt.libvirt.libvirt_driver.LibvirtDriver |
