[ovirt-users] vdsm hook issues
Dan Yasny
dyasny at gmail.com
Tue Jan 12 10:48:00 EST 2016
OK, so the hooking module is included in the vdsm package itself. Please
make sure you have /usr/share/vdsm/hooking.py on the host.
The manual run fails, because it is not running in the vdsm context, and so
the modules imported are the python site-packages and not the submodules
under vdsm.
To make a hook work, you need to place it on the host, make it accessible
to vdsm:kvm, and maybe define a custom property, if you don't want the hook
to just run on every started VM.
On Tue, Jan 12, 2016 at 10:35 AM, Jean-Pierre Ribeauville <
jpribeauville at axway.com> wrote:
> Hi,
>
>
>
> 1° It’s a full RHEL7 OS.
> 2°
> vdsm-python-zombiereaper-4.16.27-0.el7.centos.noarch
>
> vdsm-python-4.16.27-0.el7.centos.noarch
>
> vdsm-yajsonrpc-4.16.27-0.el7.centos.noarch
>
> vdsm-xmlrpc-4.16.27-0.el7.centos.noarch
>
> vdsm-cli-4.16.27-0.el7.centos.noarch
>
> vdsm-jsonrpc-java-1.0.15-1.el7.noarch
>
> vdsm-jsonrpc-4.16.27-0.el7.centos.noarch
>
> vdsm-4.16.27-0.el7.centos.x86_64
>
> 3°
>
> #!/usr/bin/python
>
> 1)
>
> 2) import os
>
> 3) import sys
>
> 4) import grp
>
> 5) import pwd
>
> 6) import traceback
>
> 7)
>
> 8) import hooking
>
> 9)
>
> 10) def createChannelElement(domxml):
>
> 11) '''
>
> 12) <channel type='unix'>
>
> 13) <source mode='bind'
> path='//var/lib/libvirt/qemu/VM_RHEL7-1_omnivision_1.agent'/>
>
> 14) <target type='virtio' name='omnivision_1.agent'/>
>
> 15) </channel>
>
> 16) '''
>
> 17)
>
> 18) channel = domxml.createElement('channel')
>
> 19) disk.setAttribute('type', 'unix')
>
> 20)
>
> 21) source = domxml.createElement('source')
>
> 22) source.setAttribute('mode', 'bind')
>
> 23)
>
> 24) # find domain name
>
> 25) domainame = domxml.getElementsByTagName('name')
>
> 26)
>
> 27) source.setAttribute('path', '//var/lib/libvirt/qemu/' +
> domainame + '_omnivision_1.agent')
>
> 28) disk.appendChild(source)
>
> 29)
>
> 30) target = domxml.createElement('target')
>
> 31) target.setAttribute('type', 'virtio')
>
> 32) target.setAttribute('name', 'omnivision_1.agent')
>
> 33) disk.appendChild(target)
>
> 34)
>
> 35) return channel
>
> 36)
>
> 37) try:
>
> 38) domxml = hooking.read_domxml()
>
> 39) devices = domxml.getElementsByTagName('devices')[0]
>
> 40) channeldev = createChannelElement(domxml)
>
> 41) sys.stderr.write('createChannel: adding xml: %s\n' %
> channeldev.toxml())
>
> 42) devices.appendChild(channeldev)
>
> 43)
>
> 44) hooking.write_domxml(domxml)
>
> 45) except:
>
> 46) sys.stderr.write('createChannel: [unexpected error]: %s\n' %
>
> 47) traceback.format_exc())
>
> 48) sys.exit(2)
>
>
>
>
>
>
>
> Thx for help.
>
>
>
> Regards,
>
>
>
> J.P.
>
>
>
>
>
> *De :* Dan Yasny [mailto:dyasny at gmail.com]
> *Envoyé :* mardi 12 janvier 2016 16:23
> *À :* Jean-Pierre Ribeauville
> *Cc :* users at ovirt.org
> *Objet :* Re: [ovirt-users] vdsm hook issues
>
>
>
> 1. Are you using a full OS or a node?
>
> 2. rpm -qa |grep vdsm
>
> 3. if possible, post the hook code
>
>
>
> Thanks
>
>
>
> On Tue, Jan 12, 2016 at 10:17 AM, Jean-Pierre Ribeauville <
> jpribeauville at axway.com> wrote:
>
>
>
> Hi,
>
>
>
> 1) is it enough to add a hook.py in
> /usr/libexec/vdsm/hooks/before_vm_start directory , and then shut down and
> reboot a guest to
>
> see this hook.py invoked ?
>
>
>
> 2) when running manually my hook.py, I got following error :
>
> ImportError: No module named hooking
>
>
>
> Do I have to install anything to solve this issue ?
>
>
>
> Thanks for help.
>
>
>
>
>
> Regards,
>
>
>
>
>
>
>
> *J.P. Ribeauville*
>
>
>
> P: +33.(0).1.47.17.20.49
>
> .
>
> Puteaux 3 Etage 5 Bureau 4
>
>
>
> *jpribeauville at axway.com <jpribeauville at axway.com>*
> http://www.axway.com
>
>
>
>
>
> P Pensez à l’environnement avant d’imprimer.
>
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20160112/8c98ea03/attachment-0001.html>
More information about the Users
mailing list