Bug 619783 - Add hooks mechanism to VDSM
Add hooks mechanism to VDSM
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: vdsm (Show other bugs)
6.1
All Linux
low Severity medium
: rc
: ---
Assigned To: Dan Kenigsberg
Oded Ramraz
: FutureFeature
Depends On: 620951
Blocks: 655920 588854 620097 682791
  Show dependency treegraph
 
Reported: 2010-07-30 10:28 EDT by Barak
Modified: 2011-08-19 11:10 EDT (History)
5 users (show)

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


Attachments (Terms of Use)

  None (edit)
Description Barak 2010-07-30 10:28:04 EDT
Taken from the relevant mail correspondence.
 
Requirements:
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 11:08:08 EDT
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 00:43:10 EDT
(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 17:31:33 EDT
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 05:16:34 EST
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.