feat: add deletion of existing VMs

Allow for faster iterations while testing.
This commit is contained in:
Александр Степченко 2023-10-24 21:12:38 +03:00
parent f1b0e6d177
commit cae0731f7b

15
main.py
View File

@ -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,