1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

fix(networks): a network or interface in use is not stopped, and a new one is whole

An interface was stopped from the Interfaces page while running VMs had
cards on it, directly or through a network using it, and they were cut
off; a network in the same case was already refused. Stopping it is now
refused the same way, naming the VMs.

A new network whose autostart could not be set stayed defined and
running while the page said it failed; it is now stopped and undefined
like one that does not start, and a rollback that fails is said with the
first error. A network named "." or ".." is refused: its page address
was another page.

A VM create checks when it is asked and again when its job starts that
the host has the networks and the filter it names, and that no card is
left without a network: one deleted meanwhile, or an empty name in the
list, left a VM that does not start once its disks were made.
This commit is contained in:
catborise 2026-11-12 13:00:56 +03:00
parent 3308a75557
commit 534782fdda
14 changed files with 314 additions and 183 deletions

View file

@ -192,6 +192,22 @@ class NetworkChangeTests(SimpleTestCase):
"n1", "nat", True, gateway, mask, dhcp, False, None, None, None, "", False)
self.assertNotIn("n1", self.conn.listDefinedNetworks() + self.conn.listNetworks())
def test_a_rollback_that_fails_is_said_with_the_first_error(self):
gateway, mask, dhcp = network_size("192.0.2.0/24", True)
with patch.object(libvirt.virNetwork, "setAutostart", side_effect=libvirt.libvirtError("cannot create symlink")), \
patch.object(libvirt.virNetwork, "destroy", side_effect=libvirt.libvirtError("device busy")):
with self.assertRaisesRegex(OperationError, "cannot create symlink; rolling the change back failed too.*device busy"):
wvmNetworks("localhost", "", "", 4).create_network(
"n1", "nat", True, gateway, mask, dhcp, False, None, None, None, "", False)
def test_a_network_whose_autostart_fails_is_not_left_running(self):
gateway, mask, dhcp = network_size("192.0.2.0/24", True)
with patch.object(libvirt.virNetwork, "setAutostart", side_effect=libvirt.libvirtError("cannot create symlink")):
with self.assertRaises(libvirt.libvirtError):
wvmNetworks("localhost", "", "", 4).create_network(
"n1", "nat", True, gateway, mask, dhcp, False, None, None, None, "", False)
self.assertNotIn("n1", self.conn.listDefinedNetworks() + self.conn.listNetworks())
class LeasesTests(SimpleTestCase):
def network(self, leases, active=True):