Update list_instances to catch libvirtError.

Commit be590cfa4b caught (and tested
for) the wrong exception. lookupByID throws a libvirtError.

Fixes LP Bug #1032741.

Change-Id: I6745660658df4d0f2bc4cd423e173200fc23cd8e
This commit is contained in:
Dan Prince
2012-08-03 15:38:32 -04:00
parent fbd8bf5adb
commit 25f50d9aa5
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -912,10 +912,10 @@ class LibvirtConnTestCase(test.TestCase):
# Only one should be listed, since domain with ID 0 must be skiped
self.assertEquals(len(instances), 1)
def test_list_instances_when_not_found(self):
def test_list_instances_when_instance_deleted(self):
def fake_lookup(instance_name):
raise exception.InstanceNotFound()
raise libvirt.libvirtError("we deleted an instance!")
self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, '_conn')
libvirt_driver.LibvirtDriver._conn.lookupByID = fake_lookup
+1 -1
View File
@@ -417,7 +417,7 @@ class LibvirtDriver(driver.ComputeDriver):
if domain_id != 0:
domain = self._conn.lookupByID(domain_id)
names.append(domain.name())
except exception.InstanceNotFound:
except libvirt.libvirtError:
# Instance was deleted while listing... ignore it
pass
return names