Condition for exec hooks BEFORE or AFTER certain state
In continuation of the discussion:
It seems to me that it would be right to enhance the hook system:
Add additional parameter into hook system: BEFORE and AFTER state. Example I want do like in config:
VM_HOOK = [
name = "my_hook",
on = "CUSTOM",
state = "ACTIVE",
lcm_state = "SAVE_SUSPEND",
condition = "BEFORE"
command = "my_hook.sh",
arguments = "$ID $TEMPLATE" ]
And hook will be executed before suspend state, only after this status of vm will change.
In case AFTER condition, the hook will be executed at once after the change of status, regardless of what status will be after.
This can be implemented as optional feature:
You may set the condition option, and hooks will be executed before or after changing state of vm.
Or not set the condition option, in this case, and hooks will be executed as is.
#1 Updated by Ruben S. Montero over 4 years ago
- Status changed from Pending to Closed
- Resolution set to worksforme
This is actually implemented with the PREV_LCM_STATE and PREV_STATE, If want to execute the hook just after the SAVE_SUSPEND succeeded. Just look for the final state or states you are looking for. For example
VM_HOOK = [
state = "SUSPENDED",
areguments = "$PREV_LCM_STATE",
Then in your hook exists if we are not coming after a SAVE_SUSPEND
#6 = if [ "$1" != "SAVE_SUSPEND" ] ; then exit 0 fi ...
#3 Updated by kvaps kvaps almost 4 years ago
I think we need to enhance opennebula's hook system by adding non-asynchronic hook's too.
You leave no choice except changing default vmm scripts.
In my opinion this is wrong. What if I needed to run some actions before vm will be touched? Before deploy or before suspend...
For to do this at now I need to add this code directly into the vmm script.
This is really wrong, because vmm script will be overridden after update, and I need to track any changes on it.
You do not even consider the possibility of the creation of a vmm script bound to a specific tm driver. (see #5081)
Non-asynchronic hook system would solve all these problems.
In addition I'm convinced that it's quite easy to implement, it is just needed to have check for these hooks before and after every action.
If someone thinks so, please type about it.
I hope for your understanding, thanks!
Opennebula has always been famous for its flexibility.