[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" ?

Cheers,
Sundar

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

Hello,
   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/
     setup.py
     demo_nova_hooks/
         __init__.py
         simple.py

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:
<snip>
#!/bin/python

import setuptools

setuptools.setup(
    name="demo_nova_hooks",
    version=5,
    packages=['demo_nova_hooks'],
    entry_points={
        'nova.hooks': [
            'create_instance=demo_nova_hooks.simple:Simple',
        ]
    },
)
</snip>

Here are the contents of simple.py:
<snip>
#!/usr/bin/python
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()
   a.pre("None")
</snip>

Cheers,
Sundar


________________________________

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