mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): a running VM's QoS edit keeps the pending QoS changes
The QoS table showed the running VM's bandwidth while an edit changes the definition for the next start. Each row posts average, peak and burst, so an edit wrote the running values back over a pending change, and a direction added while the VM ran had no row. The table shows the persistent definition now. An edit also kept only the posted values and dropped an inbound floor; it now updates them and keeps the rest.
This commit is contained in:
parent
8d2c9b1217
commit
ea9424ee1f
8 changed files with 62 additions and 22 deletions
|
|
@ -26,7 +26,7 @@ class PendingEditsTestCase(TestCase):
|
|||
compute = Compute.objects.create(name="pe", hostname="127.0.0.1:1", login="root", password="", type=1)
|
||||
self.instance = Instance.objects.create(compute=compute, name="pe-vm", uuid="aaaaaaaa-1111-2222-3333-444444444444")
|
||||
|
||||
def page(self, live, config): # disks of the live and the persistent definition
|
||||
def page(self, live=(), config=(), qos=({}, {})): # disks and QoS of the live and the persistent definition
|
||||
with patch("instances.models.wvmInstance") as wvm, patch.object(
|
||||
Compute, "status", new_callable=PropertyMock, return_value=True
|
||||
):
|
||||
|
|
@ -41,6 +41,7 @@ class PendingEditsTestCase(TestCase):
|
|||
"get_snapshot", "get_external_snapshots"):
|
||||
getattr(proxy, getter).return_value = []
|
||||
proxy.get_disk_devices.side_effect = lambda **kw: config if kw.get("config") else live
|
||||
proxy.get_all_qos.side_effect = lambda **kw: qos[1] if kw.get("config") else qos[0]
|
||||
proxy.get_console_type.return_value = "vnc"
|
||||
proxy.get_cache_modes.return_value = {"default": "Default", "none": "Disabled"}
|
||||
response = self.client.get(reverse("instances:instance", args=[self.instance.id]))
|
||||
|
|
@ -59,6 +60,15 @@ class PendingEditsTestCase(TestCase):
|
|||
self.assertEqual(vda.xpath(".//select[@name='vol_cache']/option[@selected]/@value"), ["none"])
|
||||
self.assertEqual(vda.xpath("string(.//input[@name='vol_serial']/@value)"), "")
|
||||
|
||||
def test_the_qos_form_shows_the_pending_definition(self):
|
||||
mac = "52:54:10:00:00:01"
|
||||
inbound = {"direction": "inbound", "average": "500", "peak": "0", "burst": "0", "floor": None}
|
||||
doc = self.page(qos=({mac: [inbound]}, {mac: [{**inbound, "average": "1000"}, {**inbound, "direction": "outbound"}]}))
|
||||
self.assertEqual(doc.xpath("//input[@name='qos_average']/@value"), ["1000", "500"])
|
||||
# the pending outbound has a row
|
||||
self.assertEqual([" ".join(t.split()) for t in doc.xpath("//label[@class='col-form-label']/text()")],
|
||||
[f"{mac} Inbound", f"{mac} Outbound"])
|
||||
|
||||
def test_a_disk_with_a_pending_source_is_not_deleted(self):
|
||||
# running: vda is A, its definition for the next start uses B
|
||||
with patch("instances.models.wvmInstance") as wvm, patch("instances.views.wvmStorage") as storage:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue