Cloning VMs in ESXi only

Is anyone able to clone VMs using ESX or ESXi only and without any assistance from VC?
I'm calling the VI API to clone a VM on ESXi 3.5.0 U4, but the operation is throwing a NotSupportedFault error. There seems to be some disagreement in the VMWare community if it is or is not possible to clone a VM using only ESX(i) and the VI API. I'm wondering if anybody here knows of a manual or programmatic way to clone VMs without using VC to control ESX(i).
I'm calling the VI API to clone a VM on ESXi 3.5.0 U4, but the operation is throwing a NotSupportedFault error. There seems to be some disagreement in the VMWare community if it is or is not possible to clone a VM using only ESX(i) and the VI API. I'm wondering if anybody here knows of a manual or programmatic way to clone VMs without using VC to control ESX(i).
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Comments
profile: linkedin.com/in/astorrs
There are a lot of blog articles on how to clone VMs by manually copying and modifying the VM's files using VI Client, SSH, or the "unsupported" console. I need to find an automated way to do it through software only and build it myself.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
I am not that knowledgeable about this, but does it fail on the U3 machines? I know that ESXi U3 had the bug that granted access to the cli or somesuch, but was fixed in U4. I doubt thats it, but a possibility. If you resolve this, I would be interested in knowing how.
Thanks!
John
Work In Progress: BSCI, Sharepoint
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Edit: If that won't work for you, you could surely put a script together using the VI Toolkit for Windows plus the Community Extensions, which has useful cmdlets for this such as Copy-TkeDatastoreFile.
http://vitoolkitextensions.codeplex.com/SourceControl/ListDownloadableCommits.aspx
Edit redux: http://powershell.com/cs/media/p/1655.aspx
Cloning requires making a copy of a parent VM's files into a separate folder in a datastore, changing the name of the VM in the .vmx file, removing a few lines from the .vmx file causing a new UUID and MAC address to be auto-generated when the clone is first started, and registering the cloned VM in the ESXi inventory. You also need to make sure that the parent VM is not running or paused during the cloning operation.
For the copy and .vmx file modifications, I wrote a shell script that runs on the ESXi server itself and is run (by a remote client program I also wrote) via an SSH connection. Stopping the parent VM and registering the clone is performed using the VI API called from the same client program.
ESXi runs the very minimal BusyBox Linux, which uses ash for a shell. The scripting language implemented in ash is rather lacking in features one would expect to find in other shells, like bash and ksh. Even performing simple string substitutions is not supported, leaving external programs (like sed) to be used as a workaround. And BusyBox doesn't come with Perl, Python, Java or other shells preinstalled, so you're stuck with ash.
My ESXi VM cloinging solution isn't very elegant, but it works.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
You'd blow through that 32MB limit if you installed any of those because of all the libraries they need.
If you want to just remove a line then you could do it with grep as well. "grep -v" will show you everything except what the pattern matches. The BusyBox implementation of grep supports this option.
They only thing I couldn't figure out how to do in ash was construct a command to rename files as I copied them. I wanted to loop through files in a directory and create the command cp oldfilename.oldextension newfilename.oldextension for each file to copy, but the args were always reversed no matter what I did. Something odd about variable assignment in a loop that's screwy. I didn't have the patience to figure it out; it turned out that the clone's files didn't need to have their names changed anyway.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Possibly. I've hit a few odd bugs in the Busybox ash before which needed an upgrade to the latest BusyBox to fix. Probably not something you really want to be doing though for ESXi.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Guess not.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Well duh.
Also duh.
My point was, that you seem to have to go to pretty lengthy measures (creating scripts, etc) to simply clone a VM for ESX when for Virtual PC, Virtual Server 2005, and Hyper-V you just copy the VHD and prep the guest OS accordingly.
SCVMM allows for ease of tasks for sysprep and cloning (via templates, etc) but even without enterprise level tools its easy enough.
1. Copy entire VM to new directory
2. Change IDs and name
3. Register new VM in the inventory
I don't see that as being particularly lengthy.
Somebody gots to write all the kewl warez for you IT chumps to use.
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray
Yes, I knew there was going to be a thread on this as I have spent the last few days getting all of the updates/patches for the three xp clients and Win 2003 servers in my VMWare environment.
I was thinking, 'there has to be a better way for this.'
Goggling around didn't find anything free Virtual Centers for Linux either.
"Its easier to deceive the masses then to convince the masses that they have been deceived."
-unknown
"Its easier to deceive the masses then to convince the masses that they have been deceived."
-unknown
Do you think you could share your code with everyone? Or send me a copy?
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray