Taking a snapshot from the command line is trivial. Restoring the snapshot is not. From the XenCenter GUI application it’s easy of course, but sometimes you need to automate things. In this case I have an environment for testing which needs to be reverted to the same state after each test.
Each VM has only a single snapshot. Matching the snapshot UUID with the UUID of the virtual machine isn’t easy, but can be done by extracting the parameter called “children” from the snapshot.
To list the snapshots with their respective VM UUID’s, I use the following (i and j variables for snapshot UUID and VM UUID respectively):
To restore the snapshots:
NOTE: This works if there’s only ONE snapshot per VM and you want to restore them all. Otherwise more complex scripting is required to filter out the ones you need. It’s more than enough for our test systems though.
List some VMs we care about:
Take snapshot of the VMs
Start the VMs
Stop the VMs
Shutdown – Take snapshot – Start sequence:
On one line:
For use in a short shell script (prettier formatting):
Import VMs from directory:
Export VMs to current directory:
When trying to launch the vSphere6.0 appliance installer I just got the following “The file D:\vcsa-setup.html is not in a folder shared with the host and cannot be opened by the host.”
After having tried and received the same error after copying the ISO locally, emptying the contents into a folder, mounting it via vCenter5.5 to my VM, etc I simply dragged and dropped the file onto Firefox. That was it – it works.
Funny how these simple things can end up wasting time …