VirtEngine provides hooks/triggers which gets invoked when state changes in OpenNebula.
This is needed to suspend or terminate the virtual machine by the administrator due to insufficient funds or deleted upon termination of the contract.
Configure the trigger hook_VirtEngine.rb here.