Include all libvirt domains in Systems

This patch fixes libvirt domains listing so that both active and
inactive domains are rendered as available Systems resource. Before
this fix, only inactive domains were listed.

Change-Id: I7ca5c6e2b53a231c1913160e2f07b45eac6c5f18
This commit is contained in:
Ilya Etingof 2019-03-29 15:26:09 +01:00
parent ae5065cc56
commit 2dbb808dba
3 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes libvirt domains listing so that both active and inactive domains
are rendered as available Systems resource. Before this fix, only inactive
domains were listed.

View File

@ -152,8 +152,7 @@ class LibvirtDriver(AbstractDriver):
:returns: list of UUIDs representing the systems
"""
with libvirt_open(self._uri, readonly=True) as conn:
return [conn.lookupByName(domain).UUIDString()
for domain in conn.listDefinedDomains()]
return [domain.UUIDString() for domain in conn.listAllDomains()]
def uuid(self, identity):
"""Get computer system UUID

View File

@ -60,7 +60,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
conn_mock = libvirt_mock.return_value
domain = mock.MagicMock()
domain.UUIDString.return_value = self.uuid
conn_mock.listDefinedDomains.return_value = [domain]
conn_mock.listAllDomains.return_value = [domain]
uuidstring_mock = conn_mock.lookupByName.return_value.UUIDString
uuidstring_mock.return_value = self.uuid
systems = self.test_driver.systems