Create VMs on hold
|Assignee:||Carlos Martín||% Done:|
|Category:||Core & System|
|Target version:||Release 4.0|
VMs can be put 'on hold' with the 'onevm hold' command. The scheduler ignores VMs in this state, until the VM is released.
It should be possible to create VMs directly in this hold state, either with an optional parameter in the xml-rcp api, or a template attribute.
Feature #1103: Add hold param to ruby & java oca, and cli.
onetemplate instantiate needs to be done also
#3 Updated by Simon Boulet over 8 years ago
- File submit-on-hold.patch added
This patch adds a VM_SUBMIT_ON_HOLD option to oned.conf.
It allows administrators to set VM_SUBMIT_ON_HOLD = "YES" in their oned.conf to force the submission of VM on HOLD instead of PENDING.
It can be very useful for administrators that want to prevent VMs from being automatically deployed. It allows for further deployment workflow customizations by using a CREATE VM HOOK that does different validations before placing the VM PENDING for the scheduler to deploy it.
For example, if you want VMs that have an even ID to be scheduled, but keep VMs that have a odd ID on hold. You could set VM_SUBMIT_ON_HOLD = "YES" in oned.conf, and have the following CREATE VM HOOK script:
if [ "`expr $VM_ID % 2`" = "0" ]; then
onevm release $VM_ID
Please note I have modified the VirtualMachinePool::allocate method, removing the on_hold parameter, which I found wasn't really useful. Also added a Template::get method to retrieve a bool. I found it useful instead of carrying the string value and comparing to "YES". It treats "1", "true" and "YES" attribute value as True, everything else as False. I've found several occurrence of string == "YES" around the code, perhaps they could be changed to bool.
#4 Updated by Carlos Martín over 8 years ago
We wanted users to be able to set it for each new VM, so we added a new param. --hold in the CLI.
This is an alternative to your approach, where all VM creations are changed, so we merged both to allow users to decide which one is best for their use case.