[Openstack] [Nova] Nova Compute hook not called

Sundar Nadathur snadathu at altera.com
Fri Nov 20 20:00:57 UTC 2015

Hello all,
   Please take a look and let me know why the Nova compute hook is not getting invoked. I have turned on debug logging in nova-compute.log, but didn't see any references to hooks being called. Is there anything else I need to do on the Python side beyond running "setup.py install" ?


From: Sundar Nadathur
Sent: Tuesday, November 17, 2015 8:19 PM
To: 'openstack at lists.openstack.org'
Subject: Nova Compute hook not called

   I am trying to get Nova Compute create_instance hook to be called. However, although the VM gets started from Horizon properly,  the print statement in the hook script simple.py do not get printed and there is no reference in /var/log/nova/nova-compute.log to the strings "hook", "demo", "simple", etc. When I run the hook script from the command line, it runs fine.

Please let me know what I am missing. Thanks!

Details:  I have created a directory with the following structure:

Nova-Hooks is in $PYTHONPATH. Both setup.py and simple.py have execute permissions for all.

I ran "setup.py install", restarted nova-compute service, verified that nova-compute is running, and then started the instance. Here are the contents of setup.py:

import setuptools

        'nova.hooks': [

Here are the contents of simple.py:
import sys

class Simple(object):
   logfile = '/tmp/simple-nova-hook.log'
   with open(logfile, 'a+') as log:
       print >>log, 'Begin Simple'

   def pre(self, *args, **kwargs):
       with open(self.logfile, 'a+') as log:
           print >>log, 'Begin Pre'
           for i, arg in enumerate(args):
                print >>log, '%d: %s' % (i, arg)
           for k, v in kwargs.items():
                print >>log, '%s=%s' % (k, v)
           print >>log, 'END PRE'

   def post(self, rv, *args, **kwargs):
       with open(self.logfile, 'a+') as log:
           print >>log, 'Begin Post'

if __name__ == "__main__":
   print "Started"
   a = Simple()



Confidentiality Notice.
This message may contain information that is confidential or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution, or copying of this message, or any attachments, is strictly prohibited. If you have received this message in error, please advise the sender by reply e-mail, and delete the message and any attachments. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20151120/76e17d6b/attachment.html>

More information about the Openstack mailing list