What would you do if you could instantiate hundreds of VMs that are booted up and ready-to-use in just a few seconds? We present VMFork-- a new technology in VMware ESX Hypervisor-- that lets you do just that. VMFork enables "forking" instances of a live, powered-on VM, each with its own unique identity. By leveraging the existing linked-clone technology for disks and extending the hypervisor to enable Copy-on-Write memory and VM state, VMFork fosters instant creation of VMs with little CPU overhead.
VMFork for pyVmomi enables seamless integration of vSphere VMFork APIs into a customer's existing vSphere environment regardless of the platform it is running on. Previously this functionality was only available to PowerCLI, but now everyone can take advantage of VMFork without any extra overhead. All you have to do is import the module into an existing pyVmomi-enabled vSphere environment, and you'll be on your way to instantly clone virtual machines in no time. The examples also demonstrate the use of the primitive APIs in a full Linux workflow so that forking Linux VMs is just a button click away.
Brian would like to give a shoutout to the other VMfork engineers: Gabriel Tarasuk-Levin, Li Zheng, Rohan Shah, Derek Beard, Janitha Karunaratne and Shruthi Rajashekar
- Python 2.7.x
- pyVmomi version >= 6.0.0
- paramiko >= 1.16.0
- vCenter and ESX 6.0
On the surface, the workflow is straightforward. First, a parent must be enabled for forking. This can be accomplished via the vim.VirtualMachine.EnableForkParent call. To reverse the process, call DisableForkParent.
Once the parent is enabled for forking, the next step is to quiesce the VM. Quiescing consists of the guest letting ESX know that it is in a stable state and is ready to be forked. When the "vmfork begin -1 -1" call is issued through vmware-rpctool from within the guest, ESX will stop running guest instructions, halt all IO, and mark the parent's memory pages copy-on-write. At this point the VM is considered quiesced. VMware suggests that the admin execute a script on the guest that sandwiches the quiesce call between any pre-customization and post-customization, such as NIC management. A simple example of customization is provided with the code.
Finally, the VI admin can now call vim.VirtualMachine.CreateForkChild with the appropriate parameters on the VM in order to create fork children. At this point, fork children will be created almost instantly. When the VI admin powers on a fork child, the VM will resume running guest instructions from the point the parent called vmfork-begin instead of the normal power on workflow.
For more complete documentation and examples view the README and inline code examples and comments.
- Fixed a bug that prevented CreateChildSpec from being referenced in versions of 6.5 of pyVmomi
- Updated the requirement to include pyVmomi 6.5 only, up from 6.0, due to a dependency issue
- Bug fixes & Improvements