Turn on/off VM on VirtualBox using APIs
I have installed on windows10, VirtualBox 6.0.14 where there are VMs:
- Ubuntu 18:04 with FOG server and DHCP server --> server
- Ubuntu 18:04 --> client
I installed on the client the OS through NFS and everything works.
My goal is to turn on/off the client through APIs using WOL.
First, a question that’s not properly of this forum but maybe someone has already encountered this difficulty: Is it possible to do that? I mean, can I turn on/off VM on VBox from FOG server? Reading the forum the function is not enabled by Virtualbox but maybe there is a way to circumvent it.
If it’s not possible: should someone advise me a solution to test the turn on/off machine? LXC? I could move on from VBox because I need just to test this solution and in the future move to physical machines. Nevertheless, I prefer to use VBox if it’s possible.
If it’s possible: I think to create an “empty” snapin using WOL:true (to turn on) or shutdown:true (to turn off). Does it make sense?
I posted a similar question but it had some gaps so I preferred to post it more detailed.
Thanks to the community!
@george1421 ok, could be a way to solve the problem! Thank you!
A quick google-fu check found this link: https://www.techrepublic.com/article/how-to-run-virtualbox-virtual-machines-from-the-command-line/
From that article you will find
VBoxManage startvm "Ubuntu Server" --type headlessto start the VM and
VBoxManage controlvm "Ubuntu Server" poweroff --type headlessto power off the VM.
So all you need to do is have a process to run those commands on the hypervisor host computer when you want them to execute.
First let me say this isn’t a FOG issue, but a hypervisor issue. It is out of scope of the FOG project to support this.
With that said, you need to look at your hypervisor to see if there is a way to start up a virtual machine. For a virtual machine WOL is not an option in almost all cases. What you would need is a way to instruct the hypervisor to start a VM (regardless if FOG has anything to do with the VM or not to start with). What would be helpful is if the VM has a powershell option to start a VM. I know for ESXi there is a VMWare toolbox that can be used to remote start a VM. In this case we are not talking about vmware but virtualbox.