1
0
mirror of https://github.com/gryf/boxpy.git synced 2025-12-19 21:47:59 +01:00

Wait for VM to truly power off.

Added small sleep to wait for the machine to be truly down before
detaching ISO image.
This commit is contained in:
2021-05-06 20:37:32 +02:00
parent 30b7f1ab59
commit 1bded7f75c

4
box.py
View File

@@ -658,6 +658,7 @@ def vmcreate(args):
time.sleep(3) time.sleep(3)
def _cleanup(vbox, iso, image, path_to_iso): def _cleanup(vbox, iso, image, path_to_iso):
time.sleep(1) # wait a bit, for VM shutdown to complete
vbox.storageattach('IDE', 1, 'dvddrive', 'none') vbox.storageattach('IDE', 1, 'dvddrive', 'none')
vbox.closemedium('dvd', path_to_iso) vbox.closemedium('dvd', path_to_iso)
iso.cleanup() iso.cleanup()
@@ -677,7 +678,6 @@ def vmcreate(args):
except KeyboardInterrupt: except KeyboardInterrupt:
print('\nIterrupted, cleaning up.') print('\nIterrupted, cleaning up.')
vbox.poweroff(silent=True) vbox.poweroff(silent=True)
time.sleep(1) # give some time to turn it off
_cleanup(vbox, iso, image, path_to_iso) _cleanup(vbox, iso, image, path_to_iso)
vbox.destroy() vbox.destroy()
return 1 return 1
@@ -686,7 +686,7 @@ def vmcreate(args):
_cleanup(vbox, iso, image, path_to_iso) _cleanup(vbox, iso, image, path_to_iso)
vbox.poweron() vbox.poweron()
print('You can access your VM by issuing:') print('You can access your VM by issuing:')
print(f'ssh -p {args.port} -i {iso.ssh_key_path[:-4]} ubuntu@localhost') print(f'ssh -p {conf.port} -i {iso.ssh_key_path[:-4]} ubuntu@localhost')
return 0 return 0