Voici un petit script qui permet de convertir une image packer buildée avec VBox en fichier OVA utilisable par VMWare.L'idée est de modifier le XML (le .ovf) pour supprimer les contrôleurs IDEs, la carte son, et surtout de modifier le type de virtualisation, sinon VMWare rejette l'image.Source : https://github.com/asyd
Last active
March 4, 2017 12:40
-
-
Save DaffyDuke/9c8faee53869ba76574a7d10defc89c4 to your computer and use it in GitHub Desktop.
conversion d'OVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"post-processors": [{ | |
"type": "shell-local", | |
"inline": [ | |
"../bin/ovf-postprocess.py output-demo/rhel7-demo.ovf", | |
"ovftool --lax output-demo/rhel7-demo.ovf rhel7-demo.ova", | |
"rm -fr output-demo" | |
] | |
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from lxml import etree | |
import argparse | |
def main(filename): | |
# Load XML | |
ovf = etree.parse(filename) | |
root = ovf.getroot() | |
# Update VirtualSystemType | |
virtual_system_type = root.find('.//{http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData}VirtualSystemType') | |
virtual_system_type.text = 'vmx-11' | |
# Get namespaces dict | |
nsmap = root.nsmap | |
# Remove None | |
nsmap.pop(None) | |
# Remove IDE controllers and sound card | |
for section in ["ideController0", "ideController1", "sound"]: | |
for item in root.xpath('.//rasd:ElementName[text()="%s"]/..' % section, namespaces=nsmap): | |
print("Item %s removed" % section) | |
item.getparent().remove(item) | |
# Finally save the modified XML | |
with open(filename, 'w') as f: | |
f.write(etree.tostring(root)) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument("filename", help='File to modify') | |
args = parser.parse_args() | |
main(args.filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment