Using the OVFTOOL

OVFTOOL is a command line tool that lets you import / export vm from any product / format to any (almost). It supports vsphere, vCD, vmware workstation, vmware fusion, ovf, ova and some more. It can also convert formats.

It is also very useful and easy to move vm’s across vCenter servers without the need to do it in 2 phases and having some kind of storage in between (this is my most useful scenario).

The syntax is simple, just add the source and destination of the vm, and if needed some options.

For example, to export a vm from vsphere to ovf format:

ovftool vi://vcenter/datacenter/vm/vmname c:\ovfs\vmname.ovf 

One thing to remember, ovftool is case sensitive, so when typing the locators they have to much to what is configured in vsphere. It can be tricky when having complex inventory tree.

When deploying into vsphere we need to configure the datastore where the vm will reside and disk mode and also the network it will be connected to (if it has 1 nic). Here is an example of copying a vm from vcenter to vcenter:

ovftool -dm=thin -ds=vol1 -nw=net1 vi://vcenter1/datacenter1/vm/vmname vi://vcenter2/datacenter2/host/cluster/ 

-dm – the disk mode , can be thin, thick, etc..

-ds – the datastore target for the vm.

-nw – the network the vm will be connected to.

The ovftool will prompt for credentials to login to the vcenters (can be injected in the command line for scripting) so the user that uses that must have access to the resources used.

Another interesting option is the –net , when the vm has 2 nics, the ovftool needs to know which nic goes to which network so we have to assign them both:

ovftool -dm=thick -ds=vol1 –net:sourcenet1=targetnet1 –net:sourcenet2=targetnet2  vi://vcenter1/datacenter1/vm/vmname

Where, “sourcenet1” is the original network, and “targetnet1” is the network that nic will be connected to in the target location.

There are alot more options like powering on the vm after deploying, changing the memory size, cpu count etc…

The user guide and bits are here.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: