POC Scope: The goal of this POC is to evaluate automation to clone and apply changes to VM images. So that users from other teams or external customers can apply their changes directly to the VMs and save them for later use.
POC Architecture:
POC is built on top of Powershell snapin called “VMware vSphere PowerCLI” for automated communications with VMware infrastructure that is hosting VMs.
POC UI is developed in PowerGUI editor to simplify the communication between UI to the backend operations and presenting back their results to the user.
A vanilla Windows Server 2008 R2 standalone server is used as a base image to evaluate the automation functionality of saving changes to Windows VMs.
For auto login to RDP session of Selected VM, use of MSRDP ActiveX code is used.
How it works?
In PowerGUI interface you’ll link context menu options to equivalent “VMware vSphere PowerCLI” automation commands that run on VMs and presents results back to the user.
This POC covers supporting below operations via automation
- Convert a base image into active VM: In this operation, a clone of base image is created, the VM is renamed in both VM and Guest OS
- Launch RDP session to the VM: In the operation, an RDP session to the cloned VM will be given to the user so that they can make the required changes to it
- Convert the updated VM into base image: In the operation, save the changes to the active VM by gracefully shutting it down and moving the VM to base images location
POC Setup Details:
Backend Server Infrastructure:
· VMware Software versions:
Host Server |
VMware ESXi 5.1.0 |
vCenter Server |
VMware vCenter Server 5.1.0 |
vSphere Client |
VMware vSphere Client 5.1.0 |
All are run in Evaluation Mode & are latest version available as of this writing.
Scripting Automation Infrastructure:
VMware API |
VMware vSphere PowerCLI 5.1.0 |
Quest PowerGUI |
Quest PowerGUI 3.6.0 |
POC VMware Setup: Create two folders to categorize the base images and Active VMs as shown below:
Implementing POC Operations via automation:
1. Convert a base image into active VM
In this operation, a clone of base image is created, the VM is renamed in both VM and Guest OS
Sequence of Automation Commands to be used:
- Read-Host: Prompt user for a name to the cloned VM
- New-VM: Parameters (This command clones the VM from the base image)
- –Name <name of selected VM object>
- –VM <new name provided by the user>
- –Location <specify VM folder created to host the active VMs>
- Start-VM: To bring the cloned VM into active State
- Start-Sleep: Wait till the VM and it’s guest OS Windows comes up
- Rename Windows: Then run WMIC or Registry commands to change the Windows VM name to avoid conflicts on the network
- Restart-VMGuest: Restart VM in order for Windows system rename action to take affect
2. Launch RDP session to the VM:
In the operation, an RDP session to the cloned VM will be given to the user so that they can make the required changes to it
Sequence of Automation Commands to be used:
- Guest.IPAddress: Retrieve the IP-address of the VM selected
- Guest.OSFullName: Retrieve the Full Operating System name of the VM selected
- Match “Windows”: Ensure the choosen VM is running Windows OS
- Copy the MSRDP ActiveX source files for the loggedin user session
- Update the ActiveX rdp configuration file with IP-Address of the choosen VM
- Launch Start-Menu.hta to auto login to the selected VM via MSRDP ActiveX code
3. Convert the updated VM into base image
In the operation, save the changes to the active VM by gracefully shutting it down and moving the VM to base images location
Sequence of Automation Commands to be used:
- Read-Host: Prompt user for a name to the Base Image
- Set-VM: Parameters (This command renames the VM)
- –VM <name of selected VM object>
- –Name <new image name provided by the user>
- Move-VM: Parameters
- –Destination <specify VM folder created to host the Base Images>
- Stop-VM: This will PowerOff the VM as base Images do not run actively