RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 619783 - Add hooks mechanism to VDSM
Summary: Add hooks mechanism to VDSM
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: vdsm
Version: 6.1
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Dan Kenigsberg
QA Contact: Oded Ramraz
URL:
Whiteboard:
Depends On: 620951
Blocks: 588854 620097 655920 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:
Clone Of:
: 620951 (view as bug list)
Environment:
Last Closed: 2011-08-19 15:10:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Barak 2010-07-30 14:28:04 UTC
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 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.