Bug 619783 - Add hooks mechanism to VDSM
Summary: Add hooks mechanism to VDSM
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: vdsm   
(Show other bugs)
Version: 6.1
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Dan Kenigsberg
QA Contact: Oded Ramraz
Keywords: FutureFeature
Depends On: 620951
Blocks: 655920 588854 620097 682791
TreeView+ depends on / blocked
Reported: 2010-07-30 14:28 UTC by Barak
Modified: 2011-08-19 15:10 UTC (History)
5 users (show)

Fixed In Version: vdsm-4.9-14.el6
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
: 620951 (view as bug list)
Last Closed: 2011-08-19 15:10:50 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Barak 2010-07-30 14:28:04 UTC
Taken from the relevant mail correspondence.
1 - Support the folowing hooks:
  - vdsmd start
  - vdsmd stop
  - before VM start, should allow xml manipulation
  - after VM start
  - before migration/hibernation at source
  - after migration/hibernation at source
  - before migration/hibernation at destination
  - after migration/hibernation at destination
  - on pause
  - after continue
2. Each hook should support running multiple scripts

Comment 1 Barak 2010-07-30 15:08:08 UTC
The plan
1. The VDSM hold a hook directory per hook
2. These directories will reside under /usr/share/vdsm/hooks dir 
3. Each time a hook should be called the vdsm will:
   - iterate through the hook directory's files (hence order of hook 
     executionis order by name order)
   - check  whether the file is executable + the right permissions [1]
   - executes the script and passes it all params required [2]
   - block on the before* hooks
   - script should support standard exit codes
   - vdms collects stdout and stderr and logs accordingly
   - on err of before* hook execution [3]
4. The vdsm assumes the VM_START hook can alter the xml passed to it
   and assume that some params are not changed by the hook (e.g. vmid)[4]    

open issues:
[1] what if the hook requires root permissions - we can simply rely on the vdsm sudo include file and instruct the user to add the specific script there, or ...
[2] The exact paramss will be specified according to the hook type:
    - should rhevm send additional custom params per action?
    - should the vdsm save the initial params sent in the create hook and pass 
      them to the rest of the hooks?
[3] Should we prevent the action ???? 
    use standard err exits code to enable indication to continue or to stop?
[4] specific list will be provided

Comment 2 Itamar Heim 2010-07-31 04:43:10 UTC
(In reply to comment #1)
>    - block on the before* hooks
I think that if you run multiple hooks in the post, you should block on them as well if possible, to make sure they are serialized.

Comment 3 Barak 2010-07-31 21:31:33 UTC
Updated hook list:

- vdsm_start
- vdsm_stop
- vm_before_start
- vm_after_start
- vm_before_source_migration
- vm_after_source_migration
- vm_before_dest_migration
- vm_after_dest_migration
- vm_before_pause
- vm_after_pause
- vm_before_continue
- vm_after_continue

Comment 4 Rami Vaknin 2011-02-20 10:16:34 UTC
Verified with vdsm-4.9-49.el6.x86_64.
All hooks were entered into /usr/share/vdsm/hooks.py, although not in the directory mentioned above (/usr/share/vdsm/hooks) and not in the exact names (the vm string is not the first in the hook's name).

[root@rhev-i24c-01 vdsm]# cat hooks.py | grep def
def _scriptsPerDir(dir):
def _runHooksDir(domxml, dir, vmconf={}, raiseError=True):
def before_vm_start(domxml, vmconf={}):
def after_vm_start(domxml, vmconf={}):
def before_vm_cont(domxml, vmconf={}):
def after_vm_cont(domxml, vmconf={}):
def before_vm_pause(domxml, vmconf={}):
def after_vm_pause(domxml, vmconf={}):
def before_vm_migrate_source(domxml, vmconf={}):
def after_vm_migrate_source(domxml, vmconf={}):
def before_vm_migrate_destination(domxml, vmconf={}):
def after_vm_migrate_destination(domxml, vmconf={}):
def before_vm_hibernate(domxml, vmconf={}):
def after_vm_hibernate(domxml, vmconf={}):
def before_vm_dehibernate(domxml, vmconf={}):
def after_vm_dehibernate(domxml, vmconf={}):
def after_vm_destroy(domxml, vmconf={}):
def before_vdsm_start():
def after_vdsm_stop():
def _getScriptInfo(path):
def _getHookInfo(dir):
    def scripthead(script):
def installed():
    def usage():
[root@rhev-i24c-01 vdsm]#

Note You need to log in before you can comment on or make changes to this bug.