I was tasked to build a reusable, portable vSphere 5 lab to mimic a production environment. The idea was to use it as a repeatable demo customers can interact with.
I built the environment on my 2-year old Lenovo W510 15.6″ laptop with an i7 x920 and 16GB RAM. The C: drive is SSD but the data drive (where Workstation and all the VMs live) is a 300GB WD Black 7200RPM drive.
I already had Windows 7 64-bit and Workstation installed (tho Workstation needed an upgrade to 8.0.4) so I just needed to tweak the networking and build in some shared storage.
Planning and build
I knew I’d need two ESXi servers, a domain controller, vCenter server, VUM server, vMA appliance and some demo VMs. I opted to avoid the exact reproduction of the environment in favor of running the management VMs directly under Workstation where in the production environment they are all under ESXi. (see final build graphic below)
The first real decision was to forgo the NetApp and Equallogic simulators I have access to in favor of something that avoids the pesky EULA/partner requirements and has more space available. To that end I leveraged the NFS-for-Windows service as well as the iSCSI Target software Microsoft released sometime back to run on my Windows 2008 R2 domain controller.
The second was VCSA vs vCenter installed. I opted for installing it on Win2k3 as that matches the client environment and has a lower installed/running footprint than VCSA or Win2k8. VUM is also present on it’s own Win2k3 VM as that mimics production.
Getting vMA added to Workstation was a bit of a trick – the OVL won’t load cleanly on Workstation – the required EULA screen can’t be cleared. I installed to one of the embedded ESXi hosts and then moved it out as seen here.
Once the whole environment was built I was left wondering how to quickly launch it in the state I wanted as well as return it to a pre-launch state between demos. I was assuming I would be using Powershell when I came across a nifty commandline tool for Workstation that (as it so happens) also works with vCenter, ESXi even VMware Server! Why use Powershell when I can use something historic as a batch file and obscure as vmrun?
With the automation mostly taken care of, I opted to use Workstation’s Independent / non-persistent VMDK setting (works just like in vSphere) to guarantee the client could do anything they wanted to the VMs and a quick power cycle would put the kit back to the known good state. This also gave me the ability to hard power off all VMs for extra speed with no downside.
I ended up with one script that has three phases – stop all Workstation VMs (hard power off), start all Workstation VMs with time delays including waiting for machines to reply to pings before returning, and startng VMs inside of the ESXi hosts after they started responding to SDK requests
Note that vmrun installs in the Workstation directory by default, it’s also available with the SDK download.
There are enough blogs and website about batch automation out there already. If you have a question about one of these snipits just drop me a line.
To kill a running Workstation VM (no need to kill the VMs on the hosts – I’ll just kill the hosts!)
vmrun.exe stop "D:Virtual Machinesvcvc.vmx" hard
(repeat listing all Workstation VMs)
To power on VMs:
vmrun.exe start "D:Virtual Machinesdcdc.vmx"
To wait 5 seconds between starting VMs:
timeout /t 5
To wait until the VM returns a ping:
:Wait1 ping 192.168.176.14 |find "bytes=32 time" IF NOT ERRORLEVEL 1 goto :Continue1 IF ERRORLEVEL 1 goto :Wait1 :Continue1
To only start a virtual machine on a particular date:
echo %DATE% |find "30" IF ERRORLEVEL 1 goto :NotThursday vmrun start "D:Virtual Machinesvmavma.vmx" :NotThursday
Make sure the ESXi host is up before launching a VM on it
:LookBatch vmrun -T esx -h https://ESXi/sdk -u root -p password listRegisteredVM | find "Batch/Batch.vmx" IF NOT ERRORLEVEL 1 goto :RunBatch IF ERRORLEVEL 1 goto :LookBatch :RunBatch vmrun -T esx -h https://ESXi/sdk -u root -p password start "[Shared] Batch/Batch.vmx"
Running it off an internal SSD drive is blazing fast. I can recycle the environment in about 6 minutes (about 5min of that is booting the ESXi hosts)
Running it off an internal or eSATA 7200RPM drive isn’t bad: 7.5min for a recycle.
Running it off an USB3 external SSD drive boots super fast – but the hard power off alone takes 7min! Total recycle time 12min! No idea. I tried it on 3 systems.
Note that this is also the environment that got the broadcast generator.
The Network isn’t that interesting otherwise – three networks (VMnet6, VMnet7, VMnet8) with only one (8) connecting to the host laptop and four NICs for each ESXi server (two to VMnet7). This lets me run all the interesting traffic while closely mimicing the live environment (tho production has FCP instead of my iSCSI implementation – but block level is block level… any my iSCSI is backed by SSD on the final demo machine )