DaffyDuke
3/4/2017 - 7:20 AM

conversion d'OVA

conversion d'OVA

#!/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)
  "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"
     ]
  }]

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