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

Add missing media closing

This commit is contained in:
2021-04-11 19:15:53 +02:00
parent 06480daffb
commit ca713375ea

7
box.py
View File

@@ -201,8 +201,10 @@ class VBoxManage:
raise BoxVBoxFailure('Cannot convert image to VDI.')
os.unlink(src)
def closemedium(self, mediumpath):
subprocess.call(['vboxmanage', 'closemedium', 'dvd', mediumpath])
def closemedium(self, type_, mediumpath):
if subprocess.call(['vboxmanage', 'closemedium', type_,
mediumpath]) != 0:
raise BoxVBoxFailure(f'Failed close medium {mediumpath}.')
def create_controller(self, name, type_):
if subprocess.call(['vboxmanage', 'storagectl', self.name_or_uuid,
@@ -398,6 +400,7 @@ def vmcreate(args):
break
# dettach ISO image
vbox.storageattach('IDE', 1, 'dvddrive', 'none')
vbox.closemedium('dvd', path_to_iso)
iso.cleanup()
image.cleanup()
vbox.poweron()