libvirt: Introduce Guest.get_config method
There are some places in libvirt driver code which have to get and parse domain xml manually. This patch adds get_config method to Guest object, dedicated to be used there instead. Change-Id: I9a28570ebe00f9973aaa9ed2c7f2d5254fd1216e
This commit is contained in:
parent
531f3b7d71
commit
dcec14fc0c
|
@ -359,6 +359,14 @@ class GuestTestCase(test.NoDBTestCase):
|
||||||
self.guest.set_user_password("foo", "123")
|
self.guest.set_user_password("foo", "123")
|
||||||
self.domain.setUserPassword.assert_called_once_with("foo", "123", 0)
|
self.domain.setUserPassword.assert_called_once_with("foo", "123", 0)
|
||||||
|
|
||||||
|
def test_get_config(self):
|
||||||
|
xml = "<domain type='kvm'><name>fake</name></domain>"
|
||||||
|
self.domain.XMLDesc.return_value = xml
|
||||||
|
result = self.guest.get_config()
|
||||||
|
self.assertIsInstance(result, vconfig.LibvirtConfigGuest)
|
||||||
|
self.assertEqual('kvm', result.virt_type)
|
||||||
|
self.assertEqual('fake', result.name)
|
||||||
|
|
||||||
def test_get_devices(self):
|
def test_get_devices(self):
|
||||||
xml = """
|
xml = """
|
||||||
<domain type='qemu'>
|
<domain type='qemu'>
|
||||||
|
|
|
@ -308,6 +308,15 @@ class Guest(object):
|
||||||
LOG.debug("attach device xml: %s", device_xml)
|
LOG.debug("attach device xml: %s", device_xml)
|
||||||
self._domain.attachDeviceFlags(device_xml, flags=flags)
|
self._domain.attachDeviceFlags(device_xml, flags=flags)
|
||||||
|
|
||||||
|
def get_config(self):
|
||||||
|
"""Returns the config instance for a guest
|
||||||
|
|
||||||
|
:returns: LibvirtConfigGuest instance
|
||||||
|
"""
|
||||||
|
config = vconfig.LibvirtConfigGuest()
|
||||||
|
config.parse_str(self._domain.XMLDesc(0))
|
||||||
|
return config
|
||||||
|
|
||||||
def get_disk(self, device):
|
def get_disk(self, device):
|
||||||
"""Returns the disk mounted at device
|
"""Returns the disk mounted at device
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue