From e495861dcd11965851b58a9cbec93f131bf18da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 07:33:53 +0900 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BB=D0=BE=D0=BA=20ISO-=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B1=D1=8B=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D1=80=D1=8F?= =?UTF-8?q?=D0=B4=D0=BE=D0=BC=20=D1=81=20=D0=BF=D0=BE=D1=80=D1=8F=D0=B4?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/patch_existing_vm_iso_mount.py | 112 +++++++++++++++++++++---- 1 file changed, 97 insertions(+), 15 deletions(-) diff --git a/scripts/patch_existing_vm_iso_mount.py b/scripts/patch_existing_vm_iso_mount.py index 3ac1e95..de0a185 100644 --- a/scripts/patch_existing_vm_iso_mount.py +++ b/scripts/patch_existing_vm_iso_mount.py @@ -112,7 +112,6 @@ if '"current_iso": current_vm_iso(name)' not in text: old = '"boot_message": request.query_params.get("boot_message", ""), "boot_error": request.query_params.get("boot_error", "")})' new = '"boot_message": request.query_params.get("boot_message", ""), "boot_error": request.query_params.get("boot_error", ""), "isos": list_iso_files(), "current_iso": current_vm_iso(name), "iso_message": request.query_params.get("iso_message", ""), "iso_error": request.query_params.get("iso_error", "")})' if old not in text: - # Fallback for installations without boot-order patch context yet. old = '"host_ip": system_summary()["ip"]})' new = '"host_ip": system_summary()["ip"], "isos": list_iso_files(), "current_iso": current_vm_iso(name), "iso_message": request.query_params.get("iso_message", ""), "iso_error": request.query_params.get("iso_error", "")})' if old not in text: @@ -157,19 +156,85 @@ else: app_path.write_text(text) +iso_card = r''' +
+
+

ISO-привод

+ cdrom +
+ {% if current_iso %} +
Сейчас подключен ISO: {{ current_iso }}
+ {% else %} +
ISO сейчас не подключён.
+ {% endif %} +
+ + +
+
+ +
+ {% if not isos %} +
ISO-образов пока нет. Сначала загрузи .iso в разделе ISO.
+ {% endif %} +

Для запущенной VM ISO подключается live и сохраняется в конфигурации. Для выключенной VM ISO будет доступен при следующем старте.

+
+''' + +boot_card = r''' +
+
+

Порядок загрузки

+ boot order +
+
+ + +
+

Чтобы загрузиться с ISO, выбери “Сначала ISO/CD-ROM, потом диск”. Если VM запущена, новый порядок сработает после перезапуска.

+
+''' + if template_path.exists(): tpl = template_path.read_text() original = tpl - if 'action="/vm/{{ vm.name }}/iso/mount"' not in tpl: - block = r''' - - {% if iso_message %} -
{{ iso_message }}
- {% endif %} - {% if iso_error %} -
{{ iso_error }}
- {% endif %} + # Normalize legacy separate cards into one two-column settings grid. + legacy_boot = r''' +
+
+

Порядок загрузки

+ boot order +
+
+ + +
+

Настройка меняет XML-конфигурацию VM через virsh define. Если машина сейчас запущена, новый порядок загрузки сработает после перезапуска.

+
+''' + legacy_iso = r'''

ISO-привод

@@ -200,11 +265,28 @@ if template_path.exists():

Для запущенной VM ISO подключается live и сохраняется в конфигурации. Для выключенной VM ISO будет доступен при следующем старте. Чтобы загрузиться с ISO, выставь порядок загрузки “Сначала ISO/CD-ROM, потом диск”.

''' - marker = '\n\n
' - if marker not in tpl: - raise SystemExit('vm detail grid marker not found') - tpl = tpl.replace(marker, block + marker, 1) - changed.append('ISO mount card added to vm_detail.html') + settings_grid = r''' + +
+''' + iso_card + boot_card + r'''
+''' + + if 'vm-boot-iso-grid' not in tpl: + if legacy_boot in tpl or legacy_iso in tpl: + tpl = tpl.replace(legacy_boot, '') + tpl = tpl.replace(legacy_iso, '') + marker = '\n\n
' + if marker not in tpl: + raise SystemExit('vm detail grid marker not found') + tpl = tpl.replace(marker, settings_grid + marker, 1) + changed.append('ISO and boot order cards moved into two-column grid') + elif 'action="/vm/{{ vm.name }}/iso/mount"' not in tpl: + marker = '\n\n
' + if marker not in tpl: + raise SystemExit('vm detail grid marker not found') + tpl = tpl.replace(marker, settings_grid + marker, 1) + changed.append('ISO and boot order two-column grid added') + if tpl != original: template_path.write_text(tpl)