Using Hooks 2.2
The Hook Manager present in OpenNebula enables the triggering of custom scripts tied to a change in state in a particular resource, being that a Host or a Virtual Machine. This opens a wide area of automation for system administrators to tailor their cloud infrastructures.
Hook Manager configuration is set in $ONE_LOCATION/etc/oned.conf
. Hooks can be tied to changes in host or virtual machine states, and they can be executed locally to the OpenNebula front-end and remotely in the relevant worker node.
In general, hook definition in$ONE_LOCATION/etc/oned.conf
has two paremeters:
$ONE_LOCATION/lib/mads
(or /usr/lib/one/mads/
if OpenNebula was installed in /
)In the case of VirtualMachine hooks, the following can be defined:
$ONE_LOCATION/share/hooks
case of self-contained installation or relative to /usr/share/one/hooks
in case of system-wide installation The following is an example of a hook tied to the DONE state of a VM:
<xterm> #——————————– Image Hook ———————————– # This hook is used to handle image saving and overwriting when virtual machines # reach the DONE state after being shutdown.
VM_HOOK = [
name = "image", on = "DONE", command = "image.rb", arguments = "$VMID" ]
#——————————————————————————- </xterm>
In the case of Host hooks, the following can be defined:
$ONE_LOCATION/share/hooks
case of self-contained installation or relative to /usr/share/one/hooks
in case of system-wide installationThe following is an example of a hook tied to the ERROR state of a Host:
<xterm> #——————————– Host Hook ———————————– # This hook is used to perform recovery actions when a host fails. The VMs # running in the host can be deleted (use -d option) or resubmitted (-r) in # other host # Last argument (force) can be “y”, so suspended VMs in the host will be # resubmitted/deleted, or “n”, so suspended VMs in the host will be ignored
HOST_HOOK = [
name = "error", on = "ERROR", command = "host_error.rb", arguments = "$HID -r n", remote = no ]
#——————————————————————————- </xterm>