mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-14 14:01:51 +00:00
stop running VMs before deleting
This commit is contained in:
parent
2693f6f138
commit
431d2279fe
1 changed files with 8 additions and 0 deletions
|
@ -69,6 +69,14 @@ def delete_vm_task(vmid):
|
|||
db = connect_db()
|
||||
starrs = connect_starrs()
|
||||
vm = VM(vmid)
|
||||
if vm.status != 'stopped':
|
||||
vm.stop()
|
||||
retry = 0
|
||||
while retry < 10:
|
||||
time.sleep(3)
|
||||
if vm.status == 'stopped':
|
||||
break
|
||||
retry += 1
|
||||
vm.delete()
|
||||
delete_starrs(starrs, vm.name)
|
||||
delete_vm_expire(db, vmid)
|
||||
|
|
Loading…
Reference in a new issue