1
0
mirror of https://github.com/gryf/boxpy.git synced 2026-02-02 22:25:53 +01:00

Guard against interruption during invalid cloud config.

This commit is contained in:
2021-05-05 17:25:59 +02:00
parent 9da0e3f6ff
commit ed5535cd4e

22
box.py
View File

@@ -578,14 +578,20 @@ def vmcreate(args):
# than, let's try to see if boostraping process has finished
print('Waiting for cloud init to finish ', end='')
while True:
if vbox.vm_info['uuid'] in vbox.get_running_vms():
print('.', end='')
sys.stdout.flush()
time.sleep(3)
else:
print(' done.')
break
try:
while True:
if vbox.vm_info['uuid'] in vbox.get_running_vms():
print('.', end='')
sys.stdout.flush()
time.sleep(3)
else:
print(' done.')
break
except KeyboardInterrupt:
print('\nIterrupted, cleaning up.')
VBoxManage(args.name).destroy()
return 1
# dettach ISO image
vbox.storageattach('IDE', 1, 'dvddrive', 'none')
vbox.closemedium('dvd', path_to_iso)