mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
fix(instances): boot order, root password and NIC changes say what they did
A boot device moved up or down was rebuilt without its click handler, so unticking it afterwards left it in the boot order that was applied; the moved label now keeps its checkbox. An empty root password did nothing and said nothing; it is refused with a message. Changing a NIC of a shut-off VM gave no confirmation; it now says the device changed.
This commit is contained in:
parent
d696820120
commit
c26e9a49c4
4 changed files with 22 additions and 8 deletions
|
|
@ -290,10 +290,9 @@
|
|||
var label = $(this).parent();
|
||||
var newPos = label.index() - 1;
|
||||
if (newPos > -1) {
|
||||
$('#b_order label').eq(newPos).before("<label><input type='checkbox' value='"+$(this).val()+"' name='"+$(this).val()+"' checked>"+$(this).parent().text()+"</label>");
|
||||
label.remove();
|
||||
// moved, not rebuilt: the checkbox keeps its handler
|
||||
$('#b_order label').eq(newPos).before(label);
|
||||
}
|
||||
$(".multiselect").multiselect();
|
||||
});
|
||||
set_orderlist($("#bootorder"));
|
||||
});
|
||||
|
|
@ -305,10 +304,8 @@
|
|||
var label = $(this).parent();
|
||||
var newPos = label.index() + countSelected;
|
||||
if (newPos < countOptions) {
|
||||
$('#b_order label').eq(newPos).after("<label><input type='checkbox' value='"+$(this).val()+"' name='"+$(this).val()+"' checked>"+$(this).parent().text()+"</label>");
|
||||
label.remove();
|
||||
$('#b_order label').eq(newPos).after(label);
|
||||
}
|
||||
$(".multiselect").multiselect();
|
||||
});
|
||||
set_orderlist($("#bootorder"));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from unittest.mock import patch
|
|||
|
||||
from computes.models import Compute
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.messages import get_messages
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from instances.models import Instance
|
||||
|
|
@ -33,6 +34,13 @@ class ChangeNetworkViewTestCase(TestCase):
|
|||
})
|
||||
change.assert_called_once_with("52:54:00:00:00:02", "52:54:00:00:00:03", "default", "net", "e1000", "")
|
||||
|
||||
def test_a_shut_off_vm_is_told_the_change_is_made(self):
|
||||
with patch("instances.models.wvmInstance") as wvm:
|
||||
wvm.return_value.get_status.return_value = 5
|
||||
response = self.client.post(self.url, {"net-old-mac-1": "52:54:00:00:00:02", "net-source-1": "net:default",
|
||||
"net-model-1": "virtio"}, HTTP_REFERER="/instances/%d/" % self.instance.id)
|
||||
self.assertEqual([str(m) for m in get_messages(response.wsgi_request)], ["Network device changed"])
|
||||
|
||||
def test_invalid_mac_is_rejected(self):
|
||||
change = self.post({
|
||||
"net-old-mac-0": "52:54:00:00:00:01",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from unittest.mock import patch
|
|||
import libvirt
|
||||
from computes.models import Compute
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.messages import get_messages
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from instances.models import Instance
|
||||
|
|
@ -62,6 +63,11 @@ class VMRowTests(TestCase):
|
|||
self.post("poweron")
|
||||
self.assertEqual(self.rows(), [])
|
||||
|
||||
def test_an_empty_root_password_is_refused_with_a_message(self):
|
||||
response = self.post("rootpasswd", {"passwd": ""})
|
||||
self.assertEqual([str(m) for m in get_messages(response.wsgi_request)], ["Enter a password"])
|
||||
self.assertEqual(self.rows(), [])
|
||||
|
||||
def test_qos_is_logged(self):
|
||||
self.post("set_qos", {"qos_direction": "inbound", "net-mac-0": "52:54:00:00:00:01", "qos_average": "100"})
|
||||
self.post("unset_qos", {"qos_direction": "inbound", "net-mac": "52:54:00:00:00:01"})
|
||||
|
|
|
|||
|
|
@ -911,6 +911,8 @@ def set_root_pass(request, pk):
|
|||
messages.success(request, _("Reset root password"))
|
||||
else:
|
||||
messages.error(request, AGENT_OR_SHUT_OFF)
|
||||
else:
|
||||
messages.error(request, _("Enter a password"))
|
||||
return get_safe_redirect(
|
||||
request, default=reverse("instances:instance", args=[instance.id]) + "#access"
|
||||
)
|
||||
|
|
@ -1727,9 +1729,10 @@ def change_network(request, pk):
|
|||
messages.error(request, err)
|
||||
return redirect(back)
|
||||
|
||||
msg = _("Network Device Config is changed. Please shutdown instance to activate.")
|
||||
if instance.proxy.get_status() != 5:
|
||||
messages.success(request, msg)
|
||||
messages.success(request, _("Network Device Config is changed. Please shutdown instance to activate."))
|
||||
else:
|
||||
messages.success(request, _("Network device changed"))
|
||||
return redirect(back)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue