From edae9da4db0d7678f85b6f9d1a165585fe76c936 Mon Sep 17 00:00:00 2001 From: Paul Laffitte Date: Thu, 14 Nov 2024 12:43:19 +0100 Subject: [PATCH] feat(node): nodeevacuate add --wait flag --- src/pvecontrol/__init__.py | 1 + src/pvecontrol/actions/node.py | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/pvecontrol/__init__.py b/src/pvecontrol/__init__.py index 84091a9..0b020b8 100644 --- a/src/pvecontrol/__init__.py +++ b/src/pvecontrol/__init__.py @@ -37,6 +37,7 @@ def _parser(): parser_nodeevacuate.add_argument('--node', action='store', required=True, help="Node to evacuate") parser_nodeevacuate.add_argument('--target', action='append', required=False, help="Destination Proxmox VE node, you can specify multiple target options") parser_nodeevacuate.add_argument('-f', '--follow', action='store_true', help="Follow task log output") + parser_nodeevacuate.add_argument('-w', '--wait', action='store_true', help="Wait task end") parser_nodeevacuate.add_argument('--online', action='store_true', help="Online migrate the VM, default True", default=True) parser_nodeevacuate.add_argument('--no-skip-stopped', action='store_true', help="Don't skip VMs that are stopped") parser_nodeevacuate.add_argument('--dry-run', action='store_true', help="Dry run, do not execute migration") diff --git a/src/pvecontrol/actions/node.py b/src/pvecontrol/actions/node.py index a46c99b..e4ad046 100644 --- a/src/pvecontrol/actions/node.py +++ b/src/pvecontrol/actions/node.py @@ -96,16 +96,9 @@ def action_nodeevacuate(proxmox, args): logging.debug("Migration UPID: %s"%upid) proxmox.refresh() task = proxmox.find_task(upid) - if args.follow: - print_task(proxmox, upid, args.follow) + if args.follow or args.wait: + print_task(proxmox, upid, args.follow, args.wait) else: print_taskstatus(task) - # wait for task completion - while task.running(): - logging.debug("Task status: %s", task.runningstatus) - task.refresh() - time.sleep(1) - print_taskstatus(task) - else: print("Dry run, skipping migration")