[Openstack] Nova Compute hook not called
Sundar Nadathur
snadathu at altera.com
Wed Nov 18 04:19:25 UTC 2015
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/20151118/4696991d/attachment.html>
More information about the Openstack
mailing list