Fixed bug 912701
Add an check to the list_instances method so that the domains whose ID is 0 are not listed, since this is reserved in libvirt for hypervisors. Refers to https://lists.launchpad.net/openstack/msg06699.html Change-Id: I55f6f370cbaf8bd2254e08afad8b36d833726817
This commit is contained in:
@@ -433,7 +433,7 @@ class Connection(object):
|
||||
self._uri = uri
|
||||
self._vms = {}
|
||||
self._running_vms = {}
|
||||
self._id_counter = 0
|
||||
self._id_counter = 1 # libvirt reserves 0 for the hypervisor.
|
||||
self._nwfilters = {}
|
||||
|
||||
def _add_filter(self, nwfilter):
|
||||
|
@@ -91,6 +91,9 @@ class FakeVirtDomain(object):
|
||||
</domain>
|
||||
"""
|
||||
|
||||
def name(self):
|
||||
return "fake-domain %s" % self
|
||||
|
||||
def snapshotCreateXML(self, *args):
|
||||
return FakeVirDomainSnapshot(self)
|
||||
|
||||
@@ -401,6 +404,17 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
self._check_xml_and_disk_bus({"disk_format": "iso"},
|
||||
"cdrom", "ide")
|
||||
|
||||
def test_list_instances(self):
|
||||
self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
|
||||
connection.LibvirtConnection._conn.lookupByID = self.fake_lookup
|
||||
connection.LibvirtConnection._conn.listDomainsID = lambda: [0, 1]
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = connection.LibvirtConnection(False)
|
||||
instances = conn.list_instances()
|
||||
# Only one should be listed, since domain with ID 0 must be skiped
|
||||
self.assertEquals(len(instances), 1)
|
||||
|
||||
@test.skip_if(missing_libvirt(), "Test requires libvirt")
|
||||
def test_snapshot_in_ami_format(self):
|
||||
self.flags(image_service='nova.image.fake.FakeImageService')
|
||||
|
Reference in New Issue
Block a user