From 22dcf9685331592b9969cfd4243ddb023d2445cc Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 29 Jul 2026 11:07:46 +0000 Subject: [PATCH] =?UTF-8?q?[IMP]=20script=20todo:=20r=C3=A9duction=20disqu?= =?UTF-8?q?e=20=E2=80=94=20proposer=20de=20red=C3=A9marrer=20la=20VM=20?= =?UTF-8?q?=C3=A9teinte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si la VM a dû être éteinte pour la réduction, on le NOTE (« La VM a été éteinte pour le redimensionnement. ») puis on demande (o/N) si on veut la redémarrer (virsh start sur le nom canonique). Si la VM était déjà éteinte ou n'a pas eu besoin de l'être (agrandissement à chaud), on ne demande rien : drapeau was_shut_down positionné uniquement après un arrêt effectif. Co-Authored-By: Claude Opus 4.8 (1M context) --- script/todo/todo.py | 14 ++++++++++++++ script/todo/todo_i18n.py | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/script/todo/todo.py b/script/todo/todo.py index f79a06b..d487d82 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -1434,6 +1434,7 @@ class TODO: ) # 3) Application selon agrandir/réduire et l'état de la VM. + was_shut_down = False # la VM a-t-elle été éteinte pour l'occasion ? if shrink: # DANGER : qcow2 --shrink ne réduit PAS le FS invité -> perte de # données si le FS dépasse la cible. VM éteinte obligatoire. @@ -1454,6 +1455,7 @@ class TODO: print(t("VM is still not off; aborting.")) return state = "shut off" + was_shut_down = True if not self._is_yes( input(t("Type y to confirm you understand the risk (y/N): ")) ): @@ -1485,6 +1487,18 @@ class TODO: ): self._qemu_grow_guest_fs(name) + # 5) La VM a été éteinte pour l'opération : le noter et proposer de la + # redémarrer (sinon, on ne demande rien). + if was_shut_down: + print(f"\nℹ {t('The VM was shut down for the resize.')}") + if self._is_yes( + input(t("Start the VM now? (y/N): ")) + ): + real = self._qemu_domname(name) + cmd = f"sudo virsh start {shlex.quote(real)}" + print(f"{t('Will execute:')} {cmd}") + self.execute.exec_command_live(cmd, source_erplibre=False) + def _qemu_grow_guest_fs(self, name): """Étend la partition racine + le FS invité via SSH (growpart + resize2fs/xfs_growfs/btrfs). Détecte le device et le type de FS.""" diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index dbf5d5d..c470b0b 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -1436,6 +1436,14 @@ TRANSLATIONS = { "fr": "VM éteinte.", "en": "VM is off.", }, + "The VM was shut down for the resize.": { + "fr": "La VM a été éteinte pour le redimensionnement.", + "en": "The VM was shut down for the resize.", + }, + "Start the VM now? (y/N): ": { + "fr": "Démarrer la VM maintenant ? (o/N) : ", + "en": "Start the VM now? (y/N): ", + }, "Graceful shutdown timed out. Force off (destroy)? (y/N): ": { "fr": "Arrêt gracieux trop long. Forcer l'arrêt (destroy) ? (o/N) : ", "en": "Graceful shutdown timed out. Force off (destroy)? (y/N): ",