Fix libvirt forbidden error in set_boot_mode

get_xml_desc (unless dump_sensitive=False) requires a read-write libvirt
connection.
set_boot_mode was calling this using a read-only connection.

Related to: I562e19a4290df64010ef59f6c5d9f49aeb09a693

Story: 2010575
Task: 47322
Change-Id: I60a8a8b5678e548541c05ea1066032a338013aff
This commit is contained in:
Oliver Walsh 2023-02-08 15:22:30 +00:00
parent af7de384e2
commit 0a8c1b0d62
3 changed files with 11 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes ``libvirtError: operation forbidden`` when setting boot mode

View File

@ -513,7 +513,7 @@ class LibvirtDriver(AbstractSystemsDriver):
:raises: `error.FishyError` if boot mode can't be set
"""
domain = self._get_domain(identity, readonly=True)
domain = self._get_domain(identity)
# XML schema:
# https://libvirt.org/formatdomain.html#operating-system-booting

View File

@ -360,7 +360,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
with open('sushy_tools/tests/unit/emulator/domain.xml', 'r') as f:
data = f.read()
conn_mock = libvirt_mock.return_value
conn_mock = libvirt_rw_mock.return_value
domain_mock = conn_mock.lookupByUUID.return_value
domain_mock.XMLDesc.return_value = data
@ -378,7 +378,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
'r') as f:
data = f.read()
conn_mock = libvirt_mock.return_value
conn_mock = libvirt_rw_mock.return_value
domain_mock = conn_mock.lookupByUUID.return_value
domain_mock.XMLDesc.return_value = data
@ -406,7 +406,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
data = ET.tostring(tree)
conn_mock = libvirt_mock.return_value
conn_mock = libvirt_rw_mock.return_value
domain_mock = conn_mock.lookupByUUID.return_value
domain_mock.XMLDesc.return_value = data
@ -428,7 +428,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
data = ET.tostring(tree)
conn_mock = libvirt_mock.return_value
conn_mock = libvirt_rw_mock.return_value
domain_mock = conn_mock.lookupByUUID.return_value
domain_mock.XMLDesc.return_value = data
@ -450,7 +450,7 @@ class LibvirtDriverTestCase(base.BaseTestCase):
data = ET.tostring(tree)
conn_mock = libvirt_mock.return_value
conn_mock = libvirt_rw_mock.return_value
domain_mock = conn_mock.lookupByUUID.return_value
domain_mock.XMLDesc.return_value = data