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:
parent
3308a75557
commit
534782fdda
14 changed files with 314 additions and 183 deletions
|
|
@ -55,6 +55,8 @@ class AddNetPool(forms.Form):
|
|||
raise forms.ValidationError(
|
||||
_("The pool name must not contain any special characters")
|
||||
)
|
||||
if not name.strip("."): # "." and ".." would be no page address of their own
|
||||
raise forms.ValidationError(_("The name must have a character other than '.'"))
|
||||
if any(net["name"] == name for net in self.networks):
|
||||
raise forms.ValidationError(_("This host has a network of that name"), code="taken")
|
||||
return name
|
||||
|
|
|
|||
|
|
@ -71,3 +71,12 @@ class ModeTests(SimpleTestCase):
|
|||
self.assertEqual(errors(forward="nat", subnet="192.0.2.0/24"), [])
|
||||
f = AddNetPool({"name": "default", "forward": "none"}, networks=NETWORKS)
|
||||
self.assertTrue(f.has_error("name", "taken"))
|
||||
|
||||
|
||||
class NameTests(SimpleTestCase):
|
||||
def test_a_name_of_dots_only_is_refused(self):
|
||||
# its page address /network/../ would be another page
|
||||
for name in (".", "..", "..."):
|
||||
with self.subTest(name=name):
|
||||
self.assertIn("other than '.'", form(name=name, subnet="192.0.2.0/24").errors["name"][0])
|
||||
self.assertTrue(form(name=".lab", subnet="192.0.2.0/24").is_valid())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue