The PR will make machine_type changable using vm_params or vm module.
Implementation detail how to change BIOS VM to UEFI:
first change machine_type to UEFI
shutdown VM
add NVRAM disk
start VM back.
Sorry you are reading this. Touching the shotdown/reboot part exploded. Many functions were returning reboot to signal VM needs to be rebooted (but caller need to know if VM was running before). Before touching implementation I added extra check to (some) integration tests to check value of vm_rebooted. This showed some bugs - (if I remember correctly) modules were returning vm_rebooted as True when VM was not even running initially. Or we tested module only on stopped VM. I think (didn't try to check) we might be also rebooting VM more than once during module invocation. PR extends some of integration tests - not all.
The VM.reboot field was removed from code. Sometimes it was meaning VM needs to be rebooted (but only if it was running), sometimes it was meaning VM was rebooted. It is replaced by flags _was_nice_shutdown_tried, _was_force_shutdown_tried,_was_start_tried`. Makes usage easier, we just need to make sure the same VM object is used all the time.
Some bugs or potential bugs remain - there are about 5 TODOs in PR. I will create a separate issue(s) for them, this PR is already to big. Beside vm and vm_params module also vm_nic module should now work correctly (regarding vm_reboot). The vm_disk and vm_boot_devices were left on TODO list.
Some changes are cosmetic. We had FROM_HYPERCORE_TO_ANSIBLE_POWER_STATE and FROM_ANSIBLE_TO_HYPERCORE_POWER_STATE mappings. But FROM_ANSIBLE_TO_HYPERCORE_POWER_STATE was not about states, it was about state changes - so I renamed it to _ACTIONS.
The module checks VM has all required disks before changing machine_type (UEFI VM is bootable only if NVRAM disk is present). But likely we want also to prevent removing NVRAM disk from UEFI VM - this is not implemented yet.
The PR will make
machine_type
changable usingvm_params
orvm
module.Implementation detail how to change BIOS VM to UEFI:
machine_type
to UEFISorry you are reading this. Touching the shotdown/reboot part exploded. Many functions were returning
reboot
to signal VM needs to be rebooted (but caller need to know if VM was running before). Before touching implementation I added extra check to (some) integration tests to check value ofvm_rebooted
. This showed some bugs - (if I remember correctly) modules were returningvm_rebooted
as True when VM was not even running initially. Or we tested module only on stopped VM. I think (didn't try to check) we might be also rebooting VM more than once during module invocation. PR extends some of integration tests - not all.The
VM.reboot
field was removed from code. Sometimes it was meaning VM needs to be rebooted (but only if it was running), sometimes it was meaning VM was rebooted. It is replaced by flags_was_nice_shutdown_tried
,_was_force_shutdown_tried,
_was_start_tried`. Makes usage easier, we just need to make sure the same VM object is used all the time.Some bugs or potential bugs remain - there are about 5 TODOs in PR. I will create a separate issue(s) for them, this PR is already to big. Beside
vm
andvm_params
module alsovm_nic
module should now work correctly (regardingvm_reboot
). Thevm_disk
andvm_boot_devices
were left on TODO list.Some changes are cosmetic. We had
FROM_HYPERCORE_TO_ANSIBLE_POWER_STATE
andFROM_ANSIBLE_TO_HYPERCORE_POWER_STATE
mappings. ButFROM_ANSIBLE_TO_HYPERCORE_POWER_STATE
was not about states, it was about state changes - so I renamed it to_ACTIONS
.The module checks VM has all required disks before changing
machine_type
(UEFI VM is bootable only if NVRAM disk is present). But likely we want also to prevent removing NVRAM disk from UEFI VM - this is not implemented yet.Fixes #284