mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
fix(instances): allow editing disks that have no driver format
A disk without driver/@type could not be edited: the empty format was rejected, and edit_disk would have written type=''. An empty format is now accepted and edit_disk leaves the type attribute out.
This commit is contained in:
parent
0f611e6383
commit
479faaa4ca
4 changed files with 36 additions and 5 deletions
|
|
@ -304,3 +304,22 @@ class TestChangeDiskBus(unittest.TestCase):
|
|||
self.assertEqual(disk.find("source").get("name"), "pool/vm-disk")
|
||||
self.assertEqual(disk.find("source/host").get("name"), "mon1")
|
||||
self.assertEqual(disk.find("auth/secret").get("uuid"), "aaaa")
|
||||
|
||||
def test_edit_disk_without_format_omits_the_driver_type(self):
|
||||
from lxml import etree
|
||||
|
||||
inst = wvmInstance.__new__(wvmInstance)
|
||||
inst.instance = MagicMock()
|
||||
inst._XMLDesc = MagicMock(
|
||||
return_value=(
|
||||
"<domain><devices><disk type='file' device='disk'>"
|
||||
"<driver name='qemu'/><source file='/images/vm.img'/>"
|
||||
"<target dev='vda' bus='virtio'/></disk></devices></domain>"
|
||||
)
|
||||
)
|
||||
inst.edit_disk(
|
||||
"vda", "/images/vm.img", False, False, "virtio", "", "",
|
||||
"default", "default", "default", "default",
|
||||
)
|
||||
disk = etree.fromstring(inst.instance.updateDeviceFlags.call_args[0][0])
|
||||
self.assertIsNone(disk.find("driver").get("type"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue