Monday, April 19, 2010

Import virtual appliance without vSphere client


Since I don't have a Windows or even a non-Mac GUI machine at home, I have been looking for an easy way to import/export VMs and virtual appliances to/from my Whitebox ESXi server without VMware vSphere/Virtual Infrastructure (VI) client or Standalone Converter.

The solution came in the form of VMware Open Virtualization Format Tool, ovftool for short. This command line utility comes in Windows or Linux flavours and allows you to quickly probe, convert, compress, export and import virtual machines. Here are some of its feature highlights:

  • Supports both import and generation of OVA packages
  • Directly converts between any VI, VMX, or OVF source format to any VI, VMX, or OVF target format
  • Accesses OVF sources using HTTP, HTTPS, or FTP, or from a local file
  • Deploys and exports vApp configurations on vSphere 4 targets
  • Provides options to power on a VM after deployment, and to power off a virtual machine before exporting
  • Show information about the content of any source in probe mode
  • Provides context sensitive error messages for vSphere sources and targets, showing possible completions for common errors, such as an incomplete vCenter inventory path or missing datastore and network mappings
  • Provides an optional output format to support scripting when another program calls OVF Tool

Exactly what I need. I downloaded and installed Linux version to my headless Ubuntu server and was able to quickly deploy a sample virtual appliance to my ESXi server with the following command:

$ ovftool /path/to/test.ova vi://root@esxi.lan

For a slightly more interesting test I renamed the VM and told it to power on after import:

$ ovftool –-name=NewNameForVM –-powerOn /path/to/test.ova vi://root@esxi.lan

Now to power off a VM and export it as a Virtual Appliance:

$ ovftool –-powerOffSource vi://root@esxi.lan/ResourcePoolA/someVM01 /path/to/template.ova

For more documentation see VMware site.