mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(nwfilters): two changes at once do not undo each other
A rule or reference change reads a filter and defines it again whole: two admins changing one filter at once each defined their copy, and the second removed the first's rule. Changes to a host's filters (create, clone, delete, rules, references, XML) now run one at a time; one that finds another running is told to try again. A VM's NIC form sends back its source, model, filter and MAC whole: a form opened before another admin changed the NIC's filter put the old filter back. The form now sends a fingerprint of the NIC as it showed it, and a NIC changed meanwhile is refused.
This commit is contained in:
parent
2f7516b7f9
commit
b664e34161
12 changed files with 714 additions and 631 deletions
|
|
@ -931,6 +931,8 @@ class wvmInstance(wvmConnect):
|
|||
"filterref": filterref_inst,
|
||||
"inbound": inbound,
|
||||
"outbound": outbound,
|
||||
# the NIC as a form shows it: a form shown before another change is refused
|
||||
"seen": util.digest(etree.tostring(net, encoding="unicode", with_tail=False)),
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -117,6 +117,16 @@ class TestAddNetworkXml(unittest.TestCase):
|
|||
iface = self.attached(mac_address="", source="default")
|
||||
self.assertIsNone(iface.find("mac"))
|
||||
|
||||
def test_a_nic_is_seen_as_its_definition_reads(self):
|
||||
# the fingerprint a form sends back: another change to the NIC gives another
|
||||
inst = stopped_instance()
|
||||
before = {nic["mac"]: nic["seen"] for nic in inst.get_net_devices(config=True)}
|
||||
inst._XMLDesc.return_value = DOMAIN_XML.replace("<model type='virtio'/>\n<bandwidth>",
|
||||
"<model type='virtio'/><filterref filter='clean-traffic'/>\n<bandwidth>")
|
||||
after = {nic["mac"]: nic["seen"] for nic in inst.get_net_devices(config=True)}
|
||||
self.assertNotEqual(before["52:54:00:00:00:02"], after["52:54:00:00:00:02"])
|
||||
self.assertEqual(before["52:54:00:00:00:01"], after["52:54:00:00:00:01"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue