mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): a network device keeps its source unless another is chosen
The Edit dialog of a VM's network device selected the listed network or interface whose name matched the device's source, and the first one when none did: saving only a new model moved a macvtap device or a bridge the host's lists did not show onto the first network, a bridge named like a network became that network, and a macvtap device chosen again lost its mode. The dialog now offers the device's own source first, "<name>, as it is", and posts nothing for it; the view passes no source and the device's source element is left as it is. Choosing another source changes it as before.
This commit is contained in:
parent
3d69dfe5d9
commit
2e17661390
6 changed files with 44 additions and 15 deletions
|
|
@ -14,6 +14,7 @@ DOMAIN_XML = """<domain><devices>
|
|||
<interface type='network'><mac address='52:54:00:00:00:02'/><source network='default'/><model type='virtio'/>
|
||||
<bandwidth><outbound average='1000'/></bandwidth><link state='down'/>
|
||||
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/></interface>
|
||||
<interface type='direct'><mac address='52:54:00:00:00:04'/><source dev='eth0' mode='vepa'/><model type='virtio'/></interface>
|
||||
</devices></domain>"""
|
||||
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ class TestChangeNetwork(unittest.TestCase):
|
|||
inst.change_network("52:54:00:00:00:02", "52:54:00:00:00:03", "br0", "bridge", "e1000", "clean-traffic")
|
||||
|
||||
defined = etree.fromstring(inst.wvm.defineXML.call_args[0][0])
|
||||
first, second = defined.findall("devices/interface")
|
||||
first, second, _direct = defined.findall("devices/interface")
|
||||
self.assertEqual(first.find("mac").get("address"), "52:54:00:00:00:01")
|
||||
self.assertEqual(second.get("type"), "bridge")
|
||||
self.assertEqual(second.find("mac").get("address"), "52:54:00:00:00:03")
|
||||
|
|
@ -46,6 +47,18 @@ class TestChangeNetwork(unittest.TestCase):
|
|||
self.assertEqual(second.find("link").get("state"), "down")
|
||||
self.assertEqual(second.find("address").get("bus"), "0x02")
|
||||
|
||||
def defined_nic(self, *args):
|
||||
from lxml import etree
|
||||
|
||||
inst = stopped_instance()
|
||||
inst.change_network(*args)
|
||||
return etree.fromstring(inst.wvm.defineXML.call_args[0][0]).findall("devices/interface")[2]
|
||||
|
||||
def test_no_source_keeps_the_one_the_nic_has(self):
|
||||
nic = self.defined_nic("52:54:00:00:00:04", "52:54:00:00:00:04", None, None, "e1000", "")
|
||||
self.assertEqual((nic.get("type"), nic.find("source").attrib), ("direct", {"dev": "eth0", "mode": "vepa"}))
|
||||
self.assertEqual(nic.find("model").get("type"), "e1000")
|
||||
|
||||
def test_unknown_old_mac_changes_nothing(self):
|
||||
inst = stopped_instance()
|
||||
with self.assertRaises(libvirtError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue