VMware PowerCLI Instant Clone Lab

0

Most of you have probably already heard quite some time ago about VMware project Fargo which has now matured into VMware Instant Fork technology that allows rapid deployment via rapid cloning of an already running virtual machine.  This is especially a tremendously beneficial technology in the VDI environment especially with Horizon 7.  With a VMware fling, you can also utilize this instant clone technology in a regular vSphere environment if you are in need of multiple clones of running virtual machines.  For me a particularly interesting use case is in a lab or testing environment.  Let’s take a look at a VMware PowerCLI Instant Clone Lab and some of the things that I learned in playing around with this technology.

Check out Duncan Epping’s great explanation of how VMForks work.

VMware PowerCLI Instant Clone Lab

First of all, I want to detail a few of the resources that I used in putting the knowledge and information together for my VMware PowerCLI Instant Clone lab. They are:

These steps are already pretty well documented in the links above as well as in other blog posts, however, I want to detail these a bit more as when I read through some of the documentation, I was unclear on a few of the concepts here.  Also, I wanted to pass along a few of the errors that I received along the way which will no doubt help you if you see some of the similar errors that I ran into.

Get the right Module

One of the mistakes that I made off the start was that I pulled down the wrong PowerCLI module.  If you navigate to the PowerCLI fling for Instant Forking, you may not recognize the combo box which also has the option for VMware.VimAutomation.Extensions_for_PCLI_63R1_and_above.zip which is what you need if like most of you, you are running the latest and greatest version of PowerCLI.   Be sure to get the right version as I didn’t, the first go around.  Follow the instructions after you download to get the module installed into the right location.

Here are the steps I used to get a working PowerCLI session up and running.  First things first, you need to connect to your vCenter enviroment.  Many of the blogs have you to import the module and then connect, but I have found that it didn’t make any difference.

connect-viserver yourvcenterserver

Now we want to import the module that we downloaded above for the PowerCLI fling:

import-module vmware.vimautomation.extensions

Next, we actually start working the magic of getting the parent VM setup which will be the parent for our instant cloned VMs.  Here we are simply setting a variable value with the name of the VM that will be the parent.

$parentvm = get-vm yourparentVM

Next, we actually setup the parentVM that we have defined above with the following Posh code:

$parentForkVM = Enable-InstantCloneVM -VM $parentVM -guestUser “administrator” -GuestPassword '[email protected]$$w0rd' -postclonescript C:\myscripts\postconfig.bat
  • Note the postclonescript path is a path on your workstation that you are running the command on, not the parent VM.  This was unclear in the documentation I read or at least that I found

***Note*** after you run the script above, you will lose connectivity to your parentVM, so don’t be surprised about this.  None of the blog posts I read really detailed that.  Basically your parentVM is quieced though to be the parent for your instant cloned VMs.

Errors received

At this point I want to detail a few errors that I saw to hopefully shed light on these if you get similar errors in your environment.  Make sure to enclose your guestpassword in single quotes as you can see below what happens if you do not do this, especially if your password contains reserved characters.

instant02 VMware PowerCLI Instant Clone Lab

Also, I received this error when using the postclonescript with my enable-instantclonevm commandlet.  The weird thing was I only received this on a particular VM so I think it is environmental to that VM.  The script was indeed copied over to c:\windows\TEMP however, it was having issues executing for some reason.  I simply copied the postconfig.bat file to the workstation that failed and ran it manually on the instant cloned VM which worked.

instant03 VMware PowerCLI Instant Clone Lab

Next, we prepare the $ConfigSettings parameter which sets the network settings in the advanced configuration parameters of our resulting instant cloned VM.

$ConfigSettings = @{
‘ipaddress’ = '192.168.85.36';
‘netmask’ = ‘255.255.255.0’;
‘gateway’ = ‘192.168.85.2’;
‘dns’ = ‘192.168.85.2’;
}

Finally, we actually create our $childForkVM with variables that we have pieced together above:

$childForkVM = New-InstantCloneVM -ParentVM $parentForkVM -Name MyInstantCloneVM -ConfigParams $ConfigSettings

When you run the above command, you will actually see your instant cloned VM appear in your inventory.

Last but not least, you need to start the resulting instant clone VM:

$childForkVM | start-vm

***Note*** You will not be able to access the resulting instant cloned VMs by the vSphere client, only the web client.  Also, I was not able to access them with the Remote Console.  I was able to access by simply double clicking the little preview box that launches the console in a web browser tab.

A few things I noted about the Instant Clones

A few things to note:

  • Your parent VM is not useable in this process, so you would essentially have to clone two instant clone VMs to regain what you had in the parent, and then have an additional machine to work with
  • You can have your instant clones attached to different networks.  I didn’t see anything about this listed or tested by others, so I tested it in my lab.  I was able to connect one instant clone to one network and attach the other to another network.
  • You can’t migrate your instant cloned virtual machines to another host.  They are bound to the parent VM wherever it is located and on that particular host.

To tear down your instant clone, you can run the following two commands in powercli

stop-vm yourinstantclone

remove-instantclonevm yourinstantclone

The above commands will power off and remove the instant clone.

To bring your parentVM back to a useable state, simply power off the parent VM as there is no option to shutdown.  Keep in mind the parentVM is in a quieced state, so it should be safe to simply power off.  Once you boot it back up, it returns to normal VM operational state.

Thoughts

Instant clones are way cool and definitely have some really neat use cases.  Hopefully this VMware PowerCLI Instant Clone Lab will help any who are interested in giving this new technology a test drive or even use it in certain lab situations.

Vembu BDR Suite