Creating a virtual machine template as a snapshot image of VMware instances

A VMware virtual machine (VM) template is a master copy of a virtual machine, which is widely used by VMware to create new virtual machines. The VMware driver of IBM® Cloud Manager with OpenStack allows you to create instances from a VM template and create a VM template image from a running instance.

About this task

The following example depicts a typical use case.
  1. Import VMDK images or vCenter templates into Glance.
  2. Start VMware instances from the imported images in Glance.
  3. Take a snapshot of the running VMware instances into VM templates, which are represented by new images in Glance.
  4. Start the Nova VMware instances from the new images in Glance, which were created in step 3.

To accomplish step 3, the IBM Cloud Manager with OpenStack VMware driver introduces a new configuration option named vmware.snapshot_image_format. If the value of this option is "template", the IBM Cloud Manager with OpenStack VMware driver creates a VM template in vCenter when you take a snapshot. Otherwise, the VMware driver creates a VMDK file when it takes a snapshot. The default value of snapshot_image_format is "vmdk".

The Nova createImage API metadata can override the configuration option. You can specify "vmware_template": "True" in the metadata of the Nova createImage API to create a VM template, even if "vmware.snapshot_image_format" in nova.conf is "vmdk". The following example is a sample API request body to create a VM template image.

{
    "createImage": {
        "name": "zhaoqin-snap",
        "metadata": {"vmware_template" : "True"}
    }
}

The name of the new VM template in vCenter consists of two parts. The first part is the Glance image display name. The second part is the Glance image uuid. A '-' links the two parts. If the Glance image display name is empty, the name of new template is the same as the Glance image uuid. The template vmtx file URL is regarded as the Glance image location. The disk_format of the Glance image is 'vmdk'. Other extra property formats of the Glance image that represents the template are identical to the template images discovered from vCenter.

The new VM template in vCenter side is placed under the same folder and same data store in which the VM is located. No Nova configuration or API parameter is defined to relocate the template storage during creating image procedure.

If a Nova instance is created from a discovered VMware template image, IBM Cloud Manager with OpenStack VMware driver does not support creating a VMDK image from this running instance. Any Nova instance that is created from a VMware template image can be only snapshotted into the new template image. A Nova instance that is created from a VMDK image can be snapshotted into the VMDK image or the VM template image.