VMware

This Question is Answered

2 "helpful" answers available (6 pts)
11 Replies Last post: Nov 4, 2009 7:08 PM by cpope  

Creating multiple VMs from same base image posted: May 13, 2009 4:22 AM

Click to view atrockz's profile Novice 11 posts since
Dec 9, 2008

HI all,

Is there any vi sdk api by which i can create multiple VMs form same base vmdk file?

All the VM create from the base VMDK file will have their own delta vmdk file which will refer the same base VMDK file. Only the changes that are done on individual VM will be saved on their respective delta vmdk files.

Thanks in advance......

Re: Creating multiple VMs from same base image

1. May 13, 2009 8:39 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
Hi,

What you're referring to is called Linked Clones, in the current VI API, there are no methods that supports this functionality. You can take a look at CloneVM_Task() http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.VirtualMachine.html#clone if you want to implement a full clone and this will require you to have vCenter access.

In the next release of vSphere, the vSphere SDK will provide a way of implementing Linked Clones and this will be a parameter that can be specify to CloneVM_Task() specifically in the VirtualMachineRelocateSpec where you'll specify diskMoveType to createNewChildDiskBacking

You can find more information once vSphere GA's and the new VI API reference documents are released, though if you're looking to implement Linked Clones today, you can take a look at VMware View 3 product which provides support for Linked Clones or you can take a look at two scripts I wrote that creates Linked Clones similar to that of View:

Linked Clones for ESX
Linked CLones for ESXi


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

2. May 13, 2009 11:03 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
Check this script out for the process: vGhettoLinkedClones.pl

This is using the new vSphere API and modification of vmclone.pl that is part of the current VI Perl Toolkit Utilities

You can use the script if you have access to vSphere BETA, else you'll need to wait until vSphere GA's.

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

4. May 19, 2009 6:04 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
1) Generally with Linked Clones you'll have a single gold/master image and then you'll create few dozen or so Linked Clones, you will not be able to merge the deltas back to the base as you can see there will be a problem since each LC will map back to the master. With VMware View the two use cases are (non-persistent and persistent LC's).

With non-persistent you will not be keeping the user's state of the OS, this is great for a lab environment where each night or morning user's will always get a fresh OS and changes on the system will not persist and in VMware View this operation is called "Recompose" and it's similar to that of our script where we take an additional snapshot on the Linked Clone and the VM is reverted back to the original Linked Clone via the pristine snapshot that was taken after the LC was created.

persistent on the other hand is achieved by adding a user disk which uses application redirection to store all changes from the user to their respective data disk and the OS disk continues to reference the gold/master image.

You'll need to write some logic for the second case but that's generally how it works and how VMware View 3 provides Linked Clones support.

2) There are no VI API support for Linked Clones on a standalone ESX/ESXi host, you'll need to vCenter instance and the only available method that supports this is the one I've described in an earlier post.


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

6. May 20, 2009 6:44 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
I don't think you completely understand how Linked Clones work, you will not be able to merge the individual LC's into the base image as each LC uses the base image as an OS references and all differentials of each VM is written to it's individual delta file. The commonality between all the LC's is the common base OS, if you try to merge you'll probably lock the rest of the LC's out from functioning.

You may want to go through some of the VMware View 3 documents that describe Linked Clones in greater detail to get a better understanding and here is a quick snippet when View 3 was released that gives you some high level information: http://vmetc.com/2008/12/07/vmware-view-30-perspective-from-the-implementation-angle/

From my previous post you have 2 options, If you're looking to preserve user's data you'll need to create a second data disk that is attached to each VM OR you use full clones and not Linked Clones, remember LC's aren't for everyone, depending on your use case. Non-persistent LC's are great in a lab environment and this is something that I've worked on with my colleague Tuan at UCSB ResNet: http://communities.vmware.com/docs/DOC-9201

When creating Linked Clones, the base image must be off this is the same exact requirement in VMware View 3, you will not be able to Link from a running VM as the disk is locked and you'll need to take a snapshot. One big question that comes up is how do you patch Linked Clones, currently if you have a master image of WinXP-SP2 and you have 20 LC's linking off that base image, if you want to go to WinXP-SP3, you'll need to update your master and redeploy the 20 LC's again as the changes to the base are different from when you created the LC's originally. In VMware View 3, you provide a master image, that master image is actually fully cloned into what they call a replica, from this replica your LC's are then linked. This then allows you to keep sort of a master template in a sense because your image is not being linked, it's cloned and then linked.

Here is another page of diagrams that might have with the concept: http://rodos.haywood.org/2008/12/storage-analysis-of-vmware-view.html

View 3 will automatically help with this process and there is a recompose operation that aids in this when you need to create a new pool based on a new base/parent image.

Hopefully this answered your question and I do suggest going over some of the documentation on how LC's work and that should give you a better idea on how you potentially might implement this in code using the VI API


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

8. May 20, 2009 9:00 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
First off, you will NOT be able to create Linked Clones from a VMware template, it has to be a powered off VM with a base snapshot. Secondly, it's fine that you delete your LC(s) after a user logsoff or what not, but again you will not be able to merge the deltas from your LC(s) to your base image. You need to understand that the base image is to be left alone, if there are changes in the LC(s), then you need to store that in an external user data disk. It sounds like your use case may be more suited if you look into full clones but if you're hosting a lab type environment, then you'll get more bang for your buck and some storage savings by using Linked Clones, you just need to know that since this works off of a snapshot, as user's are modifying the system the snapshot will continue to grow and you need to monitor this. That's why in View 3, there's an option that will refresh or revert all changes a user has made and spin up a new LC. We do that currently today, by running a nightly revert on the snapshot to bring it back to a pristine state and all user data is stored on a remote drive as user's are authenticated in through AD and they have their personal drive mounted automatically.

If the above is not what you're looking for, then perhaps full clones can be leverage. Full clones is basically full copies of an image and IF you have vCenter, you can deploy clones from a template or from live running VM(s). State is preserved unless you set the disks to be non-persistent and upon a shutdown/startup the changes will disappear, a reboot will not delete the changes.

It might also help explain your exact use case for deleting the VM(s) after a user has signed off, it sounds like you want to keep a pristine image each time but you also want to preserve some state? Again, if you want user's to be able to save some state, you'll need an additional user data disk or some type of mapped drive based on AD permissions. Hopefully this clears up a few things and again VMware View 3 implements the solutions I've discussed through a user friendly interface and if you're looking to manage a significant amount of desktops, you may want to look into that tool vs. trying to write your own. (Remember Linked Clone functionality through the VI API is ONLY available in the new vSphere product) so with today's vCenter 2.5 and ESX(i) 3.5 you'll need to look into VMware View 3 for Linked Cloning

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

10. May 21, 2009 6:51 AM in response to: atrockz
Click to view lamw's profile Champion 2,813 posts since
Nov 27, 2007
Its out today: http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/index.html

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: Creating multiple VMs from same base image

11. Nov 4, 2009 7:08 PM in response to: lamw
Click to view cpope's profile Novice 17 posts since
Aug 1, 2005

Hey lamw,

Thanks for the great information here. I have read through the document you referenced and had a couple questions I was hoping you could help me with. I ran across the following statement in the guide:

You can have up to eight virtual machines in a linked virtual machine group. The virtual machines in the group
cannot be part of a VMware HA cluster.

Is this information still true? Only 8 linked clones off of a base image seems pretty low. I know with View you can have many more than that.

Next, the same statement says that linked clone VMs cannot be part of an HA cluster. This also is not true for View...your View virtual machines can indeed be part of an HA/DRS cluster.

So, the question is...is this old information that has now been changed?

Are these just guidelines and not hard rules?

Any insight you can give would be appreciated.

Thanks!


Developer Social Media

Communities