Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
a script that can help import VMs into VMware ESXi from VirtualBox. tested vbox 4.2.18 and ESXi 5.1.
#!/usr/bin/env python
# usage:
# some-vm.ovf
# ref:
import sys
fn = sys.argv[1]
fp = open(fn).read()
if hasattr(fp,'decode'):
fp = fp.decode('utf-8')
fp = fp.replace('<OperatingSystemSection ovf:id="80">', '<OperatingSystemSection ovf:id="101">')
fp = fp.replace('<vssd:VirtualSystemType>virtualbox-2.2', '<vssd:VirtualSystemType>vmx-7')
fp = fp.replace('<rasd:Caption>sataController', '<rasd:Caption>scsiController')
fp = fp.replace('<rasd:Description>SATA Controller', '<rasd:Description>SCSI Controller')
fp = fp.replace('<rasd:ElementName>sataController', '<rasd:ElementName>scsiController')
fp = fp.replace('<rasd:ResourceSubType>AHCI', '<rasd:ResourceSubType>lsilogic')
fp = fp.replace('<rasd:ResourceType>20', '<rasd:ResourceType>6')
end = fp.find('<rasd:Caption>sound')
start = fp.rfind('<Item>', 0, end)
fp = fp[:start] + '<Item ovf:required="false">' + fp[start+len('<Item>'):]
nfp = open('vmx_' + fn, 'wb')
Copy link

gotvach commented Aug 6, 2015

It really helped me out today for importing into vSphere 5.1. Thanks for sharing this!

Copy link

nbolton commented Mar 3, 2016

C:\Users\Nick\Documents> ws1-vm1.ova
Traceback (most recent call last):
  File "C:\Users\Nick\Documents\", line 13, in <module>
    fp = fp.decode('utf-8')
  File "C:\Python26\lib\encodings\", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 13948: inval
id start byte

Copy link

nbolton commented Mar 3, 2016

Ah, terrible UI...


Copy link

Drx51 commented Apr 10, 2017

Hy nbolton, How to fix your error you've got above ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment