mirror of
https://github.com/gryf/boxpy.git
synced 2025-12-19 13:37:58 +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:
4
box.py
4
box.py
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user