OVF Exports from VMware Products

An OVF is a portable container for VMs that allows for easy import into a virtualization platform, like the VMware suite of products.

It seems like a no-brainer task to make one, you just highlight the VM in vCenter, click on file –> export, easy peasy.

This process is slow, prone to error and isn’t very flexible.  There is a very elegant, if non-gui centric way of accomplishing this seemingly easy task.

OVF Tool

It is a great little command utility that takes a couple arguments (target, destination) and out comes a VM or OVF/OVA file.   It is supported under Windows and Linux and provides reliable functionality for your OVF import/export needs.

Tool Syntax:

c:\Program Files (x86)\VMware\VMware OVF Tool>ovftool –help examples
Source Locator Examples:

c:\ovfs\my_vapp.ovf

c:\vms\my_vm.vmx

vi://username:pass@localhost/my_datacenter/vm/    \
my_vms_folder/my_vm_name

Destination Locator Examples:

c:\ovfs\my_vapp.ovf

c:\vms\my_vm.vmx

vi://username:pass@localhost/my_datacenter/host/    \
esx01.example.com
vi://username:pass@localhost/my_datacenter/host/    \
esx01.example.com/Resources/my_resourcepool

Note: the /host/ and /Resources/ part of the above inventory path are fixed and must be specified when using a vi destination locator.  The /Resources/ part is only used when specifying a resource pool.

Examples:

ovftool -tt=vmx c:\ovfs\my_vapp.ovf c:\vms\
(.ovf file to .vmx file. Result files will
be: c:\vms\my_vapp\my_vapp.[vmx|vmdk])

ovftool c:\vms\my_vm.vmx c:\ovfs\my_vapp.ovf
(.vmx file to .ovf file. Result files will be c:\ovfs\my_vapp.[ovf|vmdk])

ovftool http://my_ovf_server/ovfs/my_vapp.ova c:\vms\my_vm.vmx
(.ova file to .vmx file)

ovftool c:\ovfs\my_vapp.ovf vi://username:pass@my_esx_host
(.ovf file to ESX host using default mappings)

ovftool c:\ovfs\my_vm.vmx vi://username:pass@my_esx_host
(.vmx file to ESX host using default mappings)

ovftool https://my_ovf_server/ovfs/my_vapp.ovf \
vi://username:pass@my_esx_host
(.ovf file from a web server to ESX host using defaults)

ovftool c:\ovfs\my_vapp.ovf \
vi://username:pass@my_vc_server/?ip=10.20.30.40
(.ovf file to vCenter server using managed ESX host ip address)

ovftool “vi://username:pass@my_vc_server/my_datacenter?ds=\
[Storage1] foo/foo.vmx” c:\ovfs\
(VM on ESX/vCenter server to OVF using datastore location query)

ovftool c:\ovfs\my_vapp.ovf \
vi://username:pass@my_vc_server/my_datacenter/host/my_host
(.ovf file to vCenter server using vCenter inventory path)

ovftool vi://username:pass@my_host/my_datacenter/vm/my_vm_folder/my_vm_name \
c:\ovfs\my_vapp.ovf
(VC/ESX vm to .ovf file)

ovftool https://my_ovflib/vm/my_vapp.ovf
(shows summary information about the OVF package [probe mode])

\End Tool Syntax

The syntax for this tool is grueling.  I started out trying to a do a datastore query export and gave up, I ended up using the folder method.  It took me *36* attempts to get it to work.  You can view the folder structure by looking at the VM and Template view in vCenter.  The syntax is case sensitive and you need the “quotes” for when you have a open space in the command, much like other command line entries.  Also, the “\” in the examples seems to be VMwares way of saying you need a space there, putting that in the actual line throws an error.

Good luck!

–Nat

Leave a Reply

Your email address will not be published. Required fields are marked *