Skip to content

Instantly share code, notes, and snippets.

@goneri
Created May 3, 2019 20:35
Show Gist options
  • Save goneri/86ad7e9900d3aab269fe30396ae890d4 to your computer and use it in GitHub Desktop.
Save goneri/86ad7e9900d3aab269fe30396ae890d4 to your computer and use it in GitHub Desktop.
vCenter-Server-Appliance.vmdk to qcow2
#!/usr/bin/python3
import subprocess
from pathlib import Path
vmdk_files = [Path("vCenter-Server-Appliance.vmdk")]
while True:
new_file = Path("vCenter-Server-Appliance_%d.vmdk" % len(vmdk_files))
if not new_file.exists():
break
vmdk_files.append(new_file)
subprocess.call(['qemu-img', 'convert', '-f', 'vmdk', '-O', 'qcow2', '-c'] + [i.name for i in vmdk_files] + ['vCenter-Server-Appliance.qcow2'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment