diff --git a/computes/templates/computes/balance.html b/computes/templates/computes/balance.html index cef80e9d..12b7a3fd 100644 --- a/computes/templates/computes/balance.html +++ b/computes/templates/computes/balance.html @@ -2,124 +2,132 @@ {% load i18n %} {% load static %} {% load operations %} +{% load bootstrap_icons %} {% block title %}{% trans "Balance" %}{% endblock %} -{% block page_heading %}{% trans "Balance" %}{% endblock page_heading %} {% block content %} -

{% trans "Migrations of running VMs that even out the memory, then the vCPUs, the hosts give their running VMs. Each VM migrates live in a job of its own; one that fails or stops meanwhile stays where it is." %}

+ +

{% trans "Migrations that share the memory, then the vCPUs, of running VMs evenly among the hosts." %}

{% if unreachable %}
{% trans "These hosts cannot be read and are left out:" %} {{ unreachable|join:", " }}
{% endif %} -
- - - - - - - - - - {% for host in hosts %} - - - - - - {% endfor %} - -
{% trans "Host" %}{% trans "Memory" %}{% trans "VCPU" %}
{{ host.name }}{% widthratio host.before.0 1048576 1 %} GiB{% if host.after.0 != host.before.0 %} → {% widthratio host.after.0 1048576 1 %} GiB{% endif %}{{ host.before.1 }}{% if host.after.1 != host.before.1 %} → {{ host.after.1 }}{% endif %}
+ +{# each host's running VMs: memory now and, light to dark, after the migrations; all bars on one scale #} +
+ {% for host in hosts %} +
+
+
{{ host.name }}
+ {% for bar in host.bars %}{% if forloop.first or moves %} + {% if forloop.first %}{% with memory=host.before.0 vcpus=host.before.1 %} +
{% if moves %}{% trans "Now" %}{% else %}{% trans "Running VMs" %}{% endif %} + {% widthratio memory 1 1024 as bytes %}{{ bytes|filesizeformat }}, {% blocktrans count counter=vcpus %}{{ counter }} vCPU{% plural %}{{ counter }} vCPUs{% endblocktrans %}
+ {% endwith %}{% else %}{% with memory=host.after.0 vcpus=host.after.1 %} +
{% trans "After" %} + {% widthratio memory 1 1024 as bytes %}{{ bytes|filesizeformat }}, {% blocktrans count counter=vcpus %}{{ counter }} vCPU{% plural %}{{ counter }} vCPUs{% endblocktrans %}
+ {% endwith %}{% endif %} +
+
+
+ {% endif %}{% endfor %} +
+
+ {% endfor %}
-

{% trans "After: if every migration below succeeds." %}

{# unticking a VM keeps it where it is and makes the proposal again #}
{% for instance in moves %}{% endfor %} {% for instance in pinned %}{% endfor %} - {% if moves %} +
+{% if moves %} +
{% csrf_token %}{% submission_key %} +
{% blocktrans count counter=moves|length %}Proposed migration ({{ counter }}){% plural %}Proposed migrations ({{ counter }}){% endblocktrans %}
- +
- + - - - + + {% for instance in moves %} - - - - - - + + + + + {% endfor %}
{% trans "Name" %}{% trans "VCPU" %} {% trans "Memory" %}{% trans "Host" %}{% trans "Destination" %}vCPU{% trans "Migration" %}
{{ instance.info.3 }}{% widthratio instance.info.2 1024 1 %} MiB{{ instance.compute.name }}{{ instance.target.name }} + + + {% widthratio instance.info.2 1 1024 as bytes %}{{ bytes|filesizeformat }}{{ instance.info.3 }}{{ instance.compute.name }} {% bs_icon 'arrow-right' %} {{ instance.target.name }}
- {% else %} -
{% trans "No migration would even out the hosts more." %}
- {% endif %} - {% if pinned %} -
{% trans "Stay where they are" %}
+ +
+{% else %} +
{% trans "The hosts are balanced: no migration would even them out more." %}
+{% endif %} + +{% if pinned or unmovable %} +
+
{% trans "Stay where they are" %}
- +
+ + + + + + + + {% for instance in pinned %} - + + + + {% endfor %} + {% for instance in unmovable %} + + + + + {% endfor %}
{% trans "Let it move" %}{% trans "Name" %}{% trans "Host" %}{% trans "Why" %}
{{ instance.compute.name }}{% trans "You kept it here: tick it to let it move" %}
{{ instance.name }}{{ instance.compute.name }}{% for refusal in instance.refusals %}{{ refusal }}{% if not forloop.last %}
{% endif %}{% endfor %}
- {% endif %} - -{% if unmovable %} -
{% trans "Cannot move" %}
-
- - - {% for instance in unmovable %} - - - - - - {% endfor %} - -
{{ instance.name }}{{ instance.compute.name }}{% for refusal in instance.refusals %}{{ refusal }}{% if not forloop.last %}
{% endif %}{% endfor %}
{% endif %} - -{% if moves %} -{% if not parallel %} -
{% trans "The worker runs one job at a time: set Worker Concurrency to 2 or more on the Settings page." %}
-{% else %} -
{% csrf_token %}{% submission_key %} - {% for instance in moves %} - - - - {% endfor %} -
- - -
- -
-{% endif %} -{% endif %} {% endblock %} {% block script %} diff --git a/computes/tests/test_balance.py b/computes/tests/test_balance.py index 4b05fc46..47e6a6b7 100644 --- a/computes/tests/test_balance.py +++ b/computes/tests/test_balance.py @@ -106,7 +106,8 @@ class BalancePageTests(TestCase): def test_a_vm_with_a_disk_the_hosts_do_not_share_cannot_move_and_still_counts(self): page = self.page() - self.assertIn("ba-local", page.xpath("//h5[.='Cannot move']/following-sibling::div[1]")[0].text_content()) + (row,) = [row for row in page.xpath("//tr") if "ba-local" in row.text_content()] + self.assertIn("not on storage both hosts share", row.text_content()) host = next(host for host in self.response.context["hosts"] if host == self.compute) self.assertEqual(host.before, [3 * 128 * 1024, 3]) # the shut-off VM is not counted self.assertNotIn(str(self.vms["ba-off"].pk), page.xpath("//input[@name='vm' or @name='instance']/@value")) diff --git a/computes/tests/test_balance_js.py b/computes/tests/test_balance_js.py index 5095f1e7..2cd13f61 100644 --- a/computes/tests/test_balance_js.py +++ b/computes/tests/test_balance_js.py @@ -12,18 +12,18 @@ SCRIPT = Path(__file__).resolve().parents[2] / "static" / "js" / "balance.js" RUN = """ const vm = require("vm"); -const boxes = [{name: "moves", checked: true}, {name: "stays", checked: false}]; +const boxes = [{name: "vm", id: "moves", checked: true}, {name: "vm", id: "stays", checked: false}]; let handler, submitted = 0; -const form = { +const form = {elements: boxes, submit: () => { submitted += 1; }}; +const other = {elements: [], submit: () => { throw new Error("another form"); }}; +vm.runInNewContext(SCRIPT, vm.createContext({document: { + getElementById: () => form, addEventListener: (name, fn) => { handler = fn; }, - querySelectorAll: () => boxes, - submit: () => { submitted += 1; }, -}; -vm.runInNewContext(SCRIPT, vm.createContext({document: {getElementById: () => form}})); +}})); const seen = []; -for (const [id, checked] of STEPS) { - handler({target: {id, checked}}); - seen.push(boxes.filter((b) => b.checked).map((b) => b.name)); +for (const [id, checked, owner] of STEPS) { + handler({target: {id, checked, form: owner === "other" ? other : form}}); + seen.push(boxes.filter((b) => b.checked).map((b) => b.id)); } console.log(JSON.stringify({seen, submitted})); """ @@ -40,6 +40,9 @@ class BalanceScriptTests(unittest.TestCase): def test_a_vm_box_makes_the_proposal_again(self): self.assertEqual(self.run_script([["balance-7", False]]), {"seen": [["moves"]], "submitted": 1}) + def test_a_change_outside_the_proposal_does_not_reload_it(self): + self.assertEqual(self.run_script([["balance-parallel", True, "other"]])["submitted"], 0) + def test_select_all_ticks_or_unticks_every_vm_and_makes_the_proposal_again(self): result = self.run_script([["balance-all", True], ["balance-all", False]]) self.assertEqual(result, {"seen": [["moves", "stays"], []], "submitted": 2}) diff --git a/computes/views.py b/computes/views.py index 05465261..7cf1ce17 100644 --- a/computes/views.py +++ b/computes/views.py @@ -341,8 +341,11 @@ def balance(request): room = {pk: (compute.shown_capacity["memory"] - compute.shown_capacity["assigned"]["running"]) // 1024 for pk, compute in hosts.items()} moves, after = propose(loads, movable, room) + # the bars of each host's memory before and after, on the scale of the largest + scale = max([load[0] for load in (*loads.values(), *after.values())] + [1]) for pk, compute in hosts.items(): compute.before, compute.after = loads[pk], after[pk] + compute.bars = [load[0] * 100 / scale for load in (loads[pk], after[pk])] by_pk = {instance.pk: instance for instance in running} for vm, _source, target in moves: by_pk[vm].target = hosts[target] diff --git a/locale/tr/LC_MESSAGES/django.mo b/locale/tr/LC_MESSAGES/django.mo index 942366e8..597329e4 100644 Binary files a/locale/tr/LC_MESSAGES/django.mo and b/locale/tr/LC_MESSAGES/django.mo differ diff --git a/locale/tr/LC_MESSAGES/django.po b/locale/tr/LC_MESSAGES/django.po index 417273f0..591244ad 100644 --- a/locale/tr/LC_MESSAGES/django.po +++ b/locale/tr/LC_MESSAGES/django.po @@ -11,7 +11,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-16 04:31+0000\n" +"POT-Creation-Date: 2026-11-16 05:10+0000\n" "PO-Revision-Date: 2020-11-04 12:00+0000\n" "Last-Translator: catborise , 2020\n" "Language-Team: Turkish (https://www.transifex.com/catborise/teams/110663/tr/)\n" @@ -64,7 +64,8 @@ msgstr "Açık anahtar zaten mevcut" msgid "Invalid key" msgstr "Geçersiz anahtar" -#: accounts/forms.py:95 computes/templates/computes/balance.html:45 +#: accounts/forms.py:95 computes/templates/computes/balance.html:57 +#: computes/templates/computes/balance.html:104 #: computes/templates/computes/bulk_migrate.html:45 #: computes/templates/computes/instances.html:46 #: instances/templates/add_instance_volume.html:39 @@ -237,7 +238,7 @@ msgid "Add VM" msgstr "Sanal makine ekle" #: accounts/templates/account.html:68 admin/templates/admin/logs.html:40 -#: computes/templates/computes/balance.html:17 +#: computes/templates/computes/balance.html:105 #: computes/templates/computes/list.html:59 #: instances/templates/allinstances.html:108 #: instances/templates/allinstances_index_nongrouped.html:8 @@ -770,8 +771,7 @@ msgstr "" msgid "vCPUs" msgstr "vCPU" -#: admin/forms.py:209 computes/templates/computes/balance.html:18 -#: computes/templates/computes/balance.html:47 +#: admin/forms.py:209 computes/templates/computes/balance.html:58 #: computes/templates/computes/bulk_migrate.html:48 #: computes/templates/computes/instances.html:50 #: computes/templates/computes/list.html:62 computes/templates/overview.html:66 @@ -1985,8 +1985,8 @@ msgstr "" msgid "Bulk migrate" msgstr "Toplu taşıma" -#: computes/jobs.py:171 computes/templates/computes/balance.html:5 -#: computes/templates/computes/balance.html:6 +#: computes/jobs.py:171 computes/templates/computes/balance.html:6 +#: computes/templates/computes/balance.html:12 #: computes/templates/computes/list.html:12 msgid "Balance" msgstr "Dengele" @@ -2064,65 +2064,87 @@ msgstr "" "Bu, VM'lerinin bulunduğu sunucudan başka bir sunucu: yeni bir sunucu olarak " "ekleyin" -#: computes/templates/computes/balance.html:9 -msgid "" -"Migrations of running VMs that even out the memory, then the vCPUs, the hosts" -" give their running VMs. Each VM migrates live in a job of its own; one that " -"fails or stops meanwhile stays where it is." -msgstr "" -"Sunucuların çalışan sanal makinelere verdiği belleği, ardından vCPU'ları " -"eşitleyen taşımalar. Her sanal makine kendi işinde canlı taşınır; başarısız " -"olan ya da bu arada duran sanal makine olduğu yerde kalır." - #: computes/templates/computes/balance.html:11 +#: computes/templates/computes/list.html:6 +#: computes/templates/computes/list.html:14 templates/navbar.html:18 +msgid "Computes" +msgstr "Sunucular" + +#: computes/templates/computes/balance.html:15 +msgid "" +"Migrations that share the memory, then the vCPUs, of running VMs evenly among" +" the hosts." +msgstr "" +"Çalışan sanal makinelerin belleğini, ardından vCPU'larını sunuculara eşit " +"dağıtan taşımalar." + +#: computes/templates/computes/balance.html:17 msgid "These hosts cannot be read and are left out:" msgstr "Bu sunucular okunamıyor ve hesaba katılmadı:" -#: computes/templates/computes/balance.html:19 -#: computes/templates/computes/balance.html:46 -#: computes/templates/computes/bulk_migrate.html:47 -#: computes/templates/computes/instances.html:49 -msgid "VCPU" -msgstr "VCPU" +#: computes/templates/computes/balance.html:28 +#: instances/templates/instances/snapshots_tab.html:18 +msgid "Now" +msgstr "Şimdi" -#: computes/templates/computes/balance.html:33 -msgid "After: if every migration below succeeds." -msgstr "Sonrası: aşağıdaki taşımaların hepsi başarılı olursa." +#: computes/templates/computes/balance.html:28 +msgid "Running VMs" +msgstr "Çalışan sanal makineler" -#: computes/templates/computes/balance.html:44 +#: computes/templates/computes/balance.html:29 +#: computes/templates/computes/balance.html:32 +#: computes/templates/computes/capacity_vcpus.html:4 +#, python-format +msgid "%(counter)s vCPU" +msgid_plural "%(counter)s vCPUs" +msgstr[0] "%(counter)s vCPU" +msgstr[1] "%(counter)s vCPU" + +#: computes/templates/computes/balance.html:31 +msgid "After" +msgstr "Sonra" + +#: computes/templates/computes/balance.html:34 +msgid "Memory now" +msgstr "Şimdiki bellek" + +#: computes/templates/computes/balance.html:34 +msgid "Memory after" +msgstr "Sonraki bellek" + +#: computes/templates/computes/balance.html:51 +#, python-format +msgid "Proposed migration (%(counter)s)" +msgid_plural "Proposed migrations (%(counter)s)" +msgstr[0] "Önerilen taşımalar (%(counter)s)" +msgstr[1] "Önerilen taşımalar (%(counter)s)" + +#: computes/templates/computes/balance.html:56 #: computes/templates/computes/bulk_migrate.html:44 msgid "Select all" msgstr "Tümünü seç" -#: computes/templates/computes/balance.html:48 -#: instances/templates/instances/settings_tab.html:527 -#: networks/templates/network.html:396 -msgid "From" -msgstr "Başlangıç" +#: computes/templates/computes/balance.html:60 +msgid "Migration" +msgstr "Taşıma" -#: computes/templates/computes/balance.html:49 -#: instances/templates/instances/settings_tab.html:532 -#: networks/templates/network.html:400 -msgid "To" -msgstr "Bitiş" +#: computes/templates/computes/balance.html:81 +#: computes/templates/computes/bulk_migrate.html:70 +msgid "Migrations at once" +msgstr "Aynı anda taşıma" -#: computes/templates/computes/balance.html:67 -msgid "No migration would even out the hosts more." -msgstr "Sunucuları daha fazla dengeleyecek bir taşıma yok." +#: computes/templates/computes/balance.html:85 +#, python-format +msgid "Migrate %(counter)s VM" +msgid_plural "Migrate %(counter)s VMs" +msgstr[0] "%(counter)s sanal makineyi taşı" +msgstr[1] "%(counter)s sanal makineyi taşı" -#: computes/templates/computes/balance.html:70 -msgid "Stay where they are" -msgstr "Yerinde kalanlar" +#: computes/templates/computes/balance.html:86 +msgid "Migrate the VMs listed?" +msgstr "Listelenen sanal makineler taşınsın mı?" -#: computes/templates/computes/balance.html:76 -msgid "Let it move" -msgstr "Taşınabilsin" - -#: computes/templates/computes/balance.html:87 -msgid "Cannot move" -msgstr "Taşınamayanlar" - -#: computes/templates/computes/balance.html:105 +#: computes/templates/computes/balance.html:88 #: computes/templates/computes/bulk_migrate.html:30 msgid "" "The worker runs one job at a time: set Worker Concurrency to 2 or more on the" @@ -2131,22 +2153,26 @@ msgstr "" "İş yürütücü aynı anda tek iş çalıştırıyor: Ayarlar sayfasında Eş zamanlı iş " "sayısı değerini 2 veya daha fazla yapın." -#: computes/templates/computes/balance.html:114 -#: computes/templates/computes/bulk_migrate.html:70 -msgid "Migrations at once" -msgstr "Aynı anda taşıma" +#: computes/templates/computes/balance.html:93 +msgid "The hosts are balanced: no migration would even them out more." +msgstr "Sunucular dengeli: onları daha fazla dengeleyecek bir taşıma yok." -#: computes/templates/computes/balance.html:119 -msgid "Migrate the VMs listed?" -msgstr "Listelenen sanal makineler taşınsın mı?" +#: computes/templates/computes/balance.html:98 +msgid "Stay where they are" +msgstr "Yerinde kalanlar" -#: computes/templates/computes/balance.html:119 -#: computes/templates/computes/bulk_migrate.html:76 -#: instances/templates/instances/settings_tab.html:60 -#: instances/templates/instances/settings_tab.html:617 -#: instances/templates/instances/settings_tab.html:620 -msgid "Migrate" -msgstr "Taşı" +#: computes/templates/computes/balance.html:103 +#: computes/templates/computes/balance.html:112 +msgid "Let it move" +msgstr "Taşınabilsin" + +#: computes/templates/computes/balance.html:106 +msgid "Why" +msgstr "Neden" + +#: computes/templates/computes/balance.html:115 +msgid "You kept it here: tick it to let it move" +msgstr "Yerinde tuttunuz: taşınabilmesi için işaretleyin" #: computes/templates/computes/bulk_migrate.html:5 #: computes/templates/computes/bulk_migrate.html:6 @@ -2186,6 +2212,11 @@ msgstr "Kapalı sanal makineleri de taşı" msgid "Status" msgstr "Durum" +#: computes/templates/computes/bulk_migrate.html:47 +#: computes/templates/computes/instances.html:49 +msgid "VCPU" +msgstr "VCPU" + #: computes/templates/computes/bulk_migrate.html:75 #, python-format msgid "Migrate the chosen VMs from %(source)s to %(dest)s?" @@ -2193,6 +2224,13 @@ msgstr "" "Seçilen sanal makineler %(source)s sunucusundan %(dest)s sunucusuna taşınsın " "mı?" +#: computes/templates/computes/bulk_migrate.html:76 +#: instances/templates/instances/settings_tab.html:60 +#: instances/templates/instances/settings_tab.html:617 +#: instances/templates/instances/settings_tab.html:620 +msgid "Migrate" +msgstr "Taşı" + #: computes/templates/computes/capacity_line.txt:2 #, python-format msgid "Given to VMs: %(counter)s vCPU (%(ratio)s:1), %(assigned)s memory." @@ -2258,13 +2296,6 @@ msgid_plural "%(counter)s more pools" msgstr[0] "%(counter)s havuz daha" msgstr[1] "%(counter)s havuz daha" -#: computes/templates/computes/capacity_vcpus.html:4 -#, python-format -msgid "%(counter)s vCPU" -msgid_plural "%(counter)s vCPUs" -msgstr[0] "%(counter)s vCPU" -msgstr[1] "%(counter)s vCPU" - #: computes/templates/computes/capacity_vcpus.html:4 #: computes/templates/computes/list.html:42 #, python-format @@ -2455,11 +2486,6 @@ msgstr "Hipervizör üzerinde hiç sanal makine yok" msgid "Actions" msgstr "Eylemler" -#: computes/templates/computes/list.html:6 -#: computes/templates/computes/list.html:14 templates/navbar.html:18 -msgid "Computes" -msgstr "Sunucular" - #: computes/templates/computes/list.html:19 msgid "You don't have any computes" msgstr "Hiç sunucunuz yok" @@ -2698,12 +2724,12 @@ msgstr "" "Bir disk dosyası iki sunucunun paylaştığı depolamada değil: sanal makineyi " "kendi sayfasından taşıyın" -#: computes/views.py:359 +#: computes/views.py:366 #, python-format msgid "The host was saved, but the panel cannot connect to it: %(error)s" msgstr "Sunucu kaydedildi, ancak panel ona bağlanamıyor: %(error)s" -#: computes/views.py:415 +#: computes/views.py:422 #, python-format msgid "" "Its VMs keep running on the host and leave the panel; their owners are kept " @@ -5617,6 +5643,16 @@ msgstr "Sanal makinenin sunucu aygıtı yok." msgid "Migration route" msgstr "Taşıma yolu" +#: instances/templates/instances/settings_tab.html:527 +#: networks/templates/network.html:396 +msgid "From" +msgstr "Başlangıç" + +#: instances/templates/instances/settings_tab.html:532 +#: networks/templates/network.html:400 +msgid "To" +msgstr "Bitiş" + #: instances/templates/instances/settings_tab.html:541 msgid "" "The VM is running: it migrates live, or paused for the transfer when Live " @@ -6042,10 +6078,6 @@ msgstr "" "Bu sanal makinede bir disk işi çalışıyor; bitene kadar anlık görüntü " "işlemleri kullanılamaz." -#: instances/templates/instances/snapshots_tab.html:18 -msgid "Now" -msgstr "Şimdi" - #: instances/templates/instances/snapshots_tab.html:20 #: instances/templates/instances/snapshots_tab.html:31 msgid "Take a snapshot" diff --git a/locale/zh/LC_MESSAGES/django.mo b/locale/zh/LC_MESSAGES/django.mo index 81d93899..189afc2c 100644 Binary files a/locale/zh/LC_MESSAGES/django.mo and b/locale/zh/LC_MESSAGES/django.mo differ diff --git a/locale/zh/LC_MESSAGES/django.po b/locale/zh/LC_MESSAGES/django.po index 0688116d..ab4d7a45 100644 --- a/locale/zh/LC_MESSAGES/django.po +++ b/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-16 04:31+0000\n" +"POT-Creation-Date: 2026-11-16 05:10+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -61,7 +61,8 @@ msgstr "公钥已存在" msgid "Invalid key" msgstr "无效的密钥" -#: accounts/forms.py:95 computes/templates/computes/balance.html:45 +#: accounts/forms.py:95 computes/templates/computes/balance.html:57 +#: computes/templates/computes/balance.html:104 #: computes/templates/computes/bulk_migrate.html:45 #: computes/templates/computes/instances.html:46 #: instances/templates/add_instance_volume.html:39 @@ -232,7 +233,7 @@ msgid "Add VM" msgstr "添加虚拟机" #: accounts/templates/account.html:68 admin/templates/admin/logs.html:40 -#: computes/templates/computes/balance.html:17 +#: computes/templates/computes/balance.html:105 #: computes/templates/computes/list.html:59 #: instances/templates/allinstances.html:108 #: instances/templates/allinstances_index_nongrouped.html:8 @@ -747,8 +748,7 @@ msgstr "NEW_USER_DEFAULT_INSTANCES:%(name)s 已有所有者,且只允许一 msgid "vCPUs" msgstr "vCPU" -#: admin/forms.py:209 computes/templates/computes/balance.html:18 -#: computes/templates/computes/balance.html:47 +#: admin/forms.py:209 computes/templates/computes/balance.html:58 #: computes/templates/computes/bulk_migrate.html:48 #: computes/templates/computes/instances.html:50 #: computes/templates/computes/list.html:62 computes/templates/overview.html:66 @@ -1916,8 +1916,8 @@ msgstr "批量迁移已停止:已启动的迁移作为各自的任务继续进 msgid "Bulk migrate" msgstr "批量迁移" -#: computes/jobs.py:171 computes/templates/computes/balance.html:5 -#: computes/templates/computes/balance.html:6 +#: computes/jobs.py:171 computes/templates/computes/balance.html:6 +#: computes/templates/computes/balance.html:12 #: computes/templates/computes/list.html:12 msgid "Balance" msgstr "均衡" @@ -1986,85 +1986,108 @@ msgstr "其虚拟机所在的主机尚不明确:请在面板通过当前连接 msgid "This is another host than the one its VMs are on: add it as a new host" msgstr "这不是其虚拟机所在的主机:请将其添加为新主机" -#: computes/templates/computes/balance.html:9 -msgid "" -"Migrations of running VMs that even out the memory, then the vCPUs, the hosts" -" give their running VMs. Each VM migrates live in a job of its own; one that " -"fails or stops meanwhile stays where it is." -msgstr "" -"迁移正在运行的虚拟机,使各主机分配给运行中虚拟机的内存(其次是 vCPU)趋于均衡。每台虚拟机在各自的任务中在线迁移;失败或期间停止的虚拟机留在原处。" - #: computes/templates/computes/balance.html:11 +#: computes/templates/computes/list.html:6 +#: computes/templates/computes/list.html:14 templates/navbar.html:18 +msgid "Computes" +msgstr "计算节点" + +#: computes/templates/computes/balance.html:15 +msgid "" +"Migrations that share the memory, then the vCPUs, of running VMs evenly among" +" the hosts." +msgstr "在各主机之间均衡分配运行中虚拟机的内存(其次是 vCPU)的迁移。" + +#: computes/templates/computes/balance.html:17 msgid "These hosts cannot be read and are left out:" msgstr "以下主机无法读取,已排除:" -#: computes/templates/computes/balance.html:19 -#: computes/templates/computes/balance.html:46 -#: computes/templates/computes/bulk_migrate.html:47 -#: computes/templates/computes/instances.html:49 -msgid "VCPU" -msgstr "VCPU" +#: computes/templates/computes/balance.html:28 +#: instances/templates/instances/snapshots_tab.html:18 +msgid "Now" +msgstr "现在" -#: computes/templates/computes/balance.html:33 -msgid "After: if every migration below succeeds." -msgstr "之后:假设下面的每次迁移都成功。" +#: computes/templates/computes/balance.html:28 +msgid "Running VMs" +msgstr "运行中的虚拟机" -#: computes/templates/computes/balance.html:44 +#: computes/templates/computes/balance.html:29 +#: computes/templates/computes/balance.html:32 +#: computes/templates/computes/capacity_vcpus.html:4 +#, python-format +msgid "%(counter)s vCPU" +msgid_plural "%(counter)s vCPUs" +msgstr[0] "%(counter)s 个 vCPU" + +#: computes/templates/computes/balance.html:31 +msgid "After" +msgstr "之后" + +#: computes/templates/computes/balance.html:34 +msgid "Memory now" +msgstr "当前内存" + +#: computes/templates/computes/balance.html:34 +msgid "Memory after" +msgstr "迁移后内存" + +#: computes/templates/computes/balance.html:51 +#, python-format +msgid "Proposed migration (%(counter)s)" +msgid_plural "Proposed migrations (%(counter)s)" +msgstr[0] "建议的迁移(%(counter)s)" + +#: computes/templates/computes/balance.html:56 #: computes/templates/computes/bulk_migrate.html:44 msgid "Select all" msgstr "全选" -#: computes/templates/computes/balance.html:48 -#: instances/templates/instances/settings_tab.html:527 -#: networks/templates/network.html:396 -msgid "From" -msgstr "源" +#: computes/templates/computes/balance.html:60 +msgid "Migration" +msgstr "迁移" -#: computes/templates/computes/balance.html:49 -#: instances/templates/instances/settings_tab.html:532 -#: networks/templates/network.html:400 -msgid "To" -msgstr "目标" +#: computes/templates/computes/balance.html:81 +#: computes/templates/computes/bulk_migrate.html:70 +msgid "Migrations at once" +msgstr "同时迁移数" -#: computes/templates/computes/balance.html:67 -msgid "No migration would even out the hosts more." -msgstr "没有能让主机更均衡的迁移。" +#: computes/templates/computes/balance.html:85 +#, python-format +msgid "Migrate %(counter)s VM" +msgid_plural "Migrate %(counter)s VMs" +msgstr[0] "迁移 %(counter)s 台虚拟机" -#: computes/templates/computes/balance.html:70 -msgid "Stay where they are" -msgstr "留在原处" +#: computes/templates/computes/balance.html:86 +msgid "Migrate the VMs listed?" +msgstr "迁移列出的虚拟机?" -#: computes/templates/computes/balance.html:76 -msgid "Let it move" -msgstr "允许迁移" - -#: computes/templates/computes/balance.html:87 -msgid "Cannot move" -msgstr "无法迁移" - -#: computes/templates/computes/balance.html:105 +#: computes/templates/computes/balance.html:88 #: computes/templates/computes/bulk_migrate.html:30 msgid "" "The worker runs one job at a time: set Worker Concurrency to 2 or more on the" " Settings page." msgstr "任务执行器一次只运行一个任务:请在设置页面将工作进程并发数设为 2 或更大。" -#: computes/templates/computes/balance.html:114 -#: computes/templates/computes/bulk_migrate.html:70 -msgid "Migrations at once" -msgstr "同时迁移数" +#: computes/templates/computes/balance.html:93 +msgid "The hosts are balanced: no migration would even them out more." +msgstr "主机已均衡:没有能使其更均衡的迁移。" -#: computes/templates/computes/balance.html:119 -msgid "Migrate the VMs listed?" -msgstr "迁移列出的虚拟机?" +#: computes/templates/computes/balance.html:98 +msgid "Stay where they are" +msgstr "留在原处" -#: computes/templates/computes/balance.html:119 -#: computes/templates/computes/bulk_migrate.html:76 -#: instances/templates/instances/settings_tab.html:60 -#: instances/templates/instances/settings_tab.html:617 -#: instances/templates/instances/settings_tab.html:620 -msgid "Migrate" -msgstr "迁移" +#: computes/templates/computes/balance.html:103 +#: computes/templates/computes/balance.html:112 +msgid "Let it move" +msgstr "允许迁移" + +#: computes/templates/computes/balance.html:106 +msgid "Why" +msgstr "原因" + +#: computes/templates/computes/balance.html:115 +msgid "You kept it here: tick it to let it move" +msgstr "您将其保留在原处:勾选后即可迁移" #: computes/templates/computes/bulk_migrate.html:5 #: computes/templates/computes/bulk_migrate.html:6 @@ -2102,11 +2125,23 @@ msgstr "同时迁移已关机的虚拟机" msgid "Status" msgstr "状态" +#: computes/templates/computes/bulk_migrate.html:47 +#: computes/templates/computes/instances.html:49 +msgid "VCPU" +msgstr "VCPU" + #: computes/templates/computes/bulk_migrate.html:75 #, python-format msgid "Migrate the chosen VMs from %(source)s to %(dest)s?" msgstr "将选中的虚拟机从 %(source)s 迁移到 %(dest)s?" +#: computes/templates/computes/bulk_migrate.html:76 +#: instances/templates/instances/settings_tab.html:60 +#: instances/templates/instances/settings_tab.html:617 +#: instances/templates/instances/settings_tab.html:620 +msgid "Migrate" +msgstr "迁移" + #: computes/templates/computes/capacity_line.txt:2 #, python-format msgid "Given to VMs: %(counter)s vCPU (%(ratio)s:1), %(assigned)s memory." @@ -2164,12 +2199,6 @@ msgid "%(counter)s more pool" msgid_plural "%(counter)s more pools" msgstr[0] "另有 %(counter)s 个存储池" -#: computes/templates/computes/capacity_vcpus.html:4 -#, python-format -msgid "%(counter)s vCPU" -msgid_plural "%(counter)s vCPUs" -msgstr[0] "%(counter)s 个 vCPU" - #: computes/templates/computes/capacity_vcpus.html:4 #: computes/templates/computes/list.html:42 #, python-format @@ -2357,11 +2386,6 @@ msgstr "虚拟机管理程序中没有任何虚拟机" msgid "Actions" msgstr "操作" -#: computes/templates/computes/list.html:6 -#: computes/templates/computes/list.html:14 templates/navbar.html:18 -msgid "Computes" -msgstr "计算节点" - #: computes/templates/computes/list.html:19 msgid "You don't have any computes" msgstr "您还没有任何计算节点" @@ -2590,12 +2614,12 @@ msgid "" "A disk file is not on storage both hosts share: migrate it from its page" msgstr "有磁盘文件不在两台主机共享的存储上:请在该虚拟机的页面上迁移它" -#: computes/views.py:359 +#: computes/views.py:366 #, python-format msgid "The host was saved, but the panel cannot connect to it: %(error)s" msgstr "主机已保存,但面板无法连接到它:%(error)s" -#: computes/views.py:415 +#: computes/views.py:422 #, python-format msgid "" "Its VMs keep running on the host and leave the panel; their owners are kept " @@ -5333,6 +5357,16 @@ msgstr "该虚拟机没有主机设备。" msgid "Migration route" msgstr "迁移路径" +#: instances/templates/instances/settings_tab.html:527 +#: networks/templates/network.html:396 +msgid "From" +msgstr "源" + +#: instances/templates/instances/settings_tab.html:532 +#: networks/templates/network.html:400 +msgid "To" +msgstr "目标" + #: instances/templates/instances/settings_tab.html:541 msgid "" "The VM is running: it migrates live, or paused for the transfer when Live " @@ -5720,10 +5754,6 @@ msgid "" "ends." msgstr "此虚拟机正在运行磁盘任务;任务结束前快照操作不可用。" -#: instances/templates/instances/snapshots_tab.html:18 -msgid "Now" -msgstr "现在" - #: instances/templates/instances/snapshots_tab.html:20 #: instances/templates/instances/snapshots_tab.html:31 msgid "Take a snapshot" diff --git a/static/icon_cache/arrow-right_None_None_None.svg b/static/icon_cache/arrow-right_None_None_None.svg new file mode 100644 index 00000000..ccbf30f2 --- /dev/null +++ b/static/icon_cache/arrow-right_None_None_None.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/static/js/balance.js b/static/js/balance.js index 106dba41..e07875e2 100644 --- a/static/js/balance.js +++ b/static/js/balance.js @@ -1,12 +1,18 @@ // The Balance page: unticking a VM keeps it where it is, ticking it again // lets it move; either makes the proposal again. The header box ticks or -// unticks every VM listed. +// unticks every VM listed. The boxes sit in the page's tables and belong +// to the proposal's form by their form attribute. const form = document.getElementById("balance-form"); -form?.addEventListener("change", function (event) { +document.addEventListener("change", function (event) { + if (!form || event.target.form !== form) { + return; + } if (event.target.id === "balance-all") { - form.querySelectorAll("input[name=vm]").forEach(function (box) { - box.checked = event.target.checked; - }); + for (const box of form.elements) { + if (box.name === "vm") { + box.checked = event.target.checked; + } + } } form.submit(); });