From cae0731f7b7314361664870aa9b22db3c9a88102 Mon Sep 17 00:00:00 2001 From: Alexander Stepchenko Date: Tue, 24 Oct 2023 21:12:38 +0300 Subject: [PATCH] feat: add deletion of existing VMs Allow for faster iterations while testing. --- main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 4cc67f0..33a4e55 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ from pathlib import Path import yaml from proxmoxer import ProxmoxAPI -from functions import clone_template, get_vm_ip +from functions import clone_template, delete_vm, get_vm_ip urllib3.disable_warnings() @@ -53,6 +53,19 @@ def main(): 'worker2': 502, } + delete = True + if delete: + logger.info('Stopping VMs %s...', vm_ids) + proxmox.nodes(node).qemu(vm_ids['master']).status.stop.post() + proxmox.nodes(node).qemu(vm_ids['worker1']).status.stop.post() + proxmox.nodes(node).qemu(vm_ids['worker2']).status.stop.post() + sleep(15) + logger.info('Deleting VMs %s...', vm_ids) + delete_vm(proxmox, node, vm_ids['master']) + delete_vm(proxmox, node, vm_ids['worker1']) + delete_vm(proxmox, node, vm_ids['worker2']) + sleep(15) + vm_id_master, upid_master = clone_template( proxmox, node,