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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user