As a continuation of previous article introducing Cobbler inside VirtualBox, this one will talk about power management.
First of all, as a principle of no reinventing of the wheel, here is the fence agent for VirtualBox. But there are a few bugs which are slightly annoying, so I clone it and make it on Github.
I suppose you already have Perl execution environment, then just follow the steps below:
- Download either from the original repository or from my cloned one;
- Copy
fence_vbox
to/usr/local/sbin
; cobbler sync
or evenservice cobbler restart
andservice apache2 restart
;- Create a file named
fence_vbox.template
under/etc/cobbler/power/
with content:1 2 3 4
vmname=$power_id vboxhost=$power_address login=$power_user action=$power_mode
- In Systems configuration of Cobbler Web UI, fill in following info:
IP address
10.0.2.2
here shows thatNAT
is used and this IP points to your host; - As this Perl script uses simple ssh login to interact with VBoxManage, it will prompt for password, so you need to generate public key for
root
user inside the virtual machine and put it to the user’s home of the host machine, which is$HOME/.ssh/authorized_keys
, and make sure to do an ssh login at least once to accept your host machine as a “known host”; - Then run
cobbler system powerstatus --name=<name of the system>
, you should be able to check the status.
BTW, I do think Cobbler does not respect FenceAgentAPI, because powerstatus
checking should result return value as 2
as specified by the API spec, but Cobbler keeps checking again and again and finally gets timeout, and if I put the return value as 0
, it is then OK.