<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hello all,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">   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” ? <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Sundar<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Sundar Nadathur
<br>
<b>Sent:</b> Tuesday, November 17, 2015 8:19 PM<br>
<b>To:</b> 'openstack@lists.openstack.org'<br>
<b>Subject:</b> Nova Compute hook not called <o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal">   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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Please let me know what I am missing. Thanks!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Details:  I have created a directory with the following structure:<o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Nova-Hooks/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     setup.py<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">     demo_nova_hooks/<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">         __init__.py<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">         simple.py</span>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Nova-Hooks is in $PYTHONPATH. Both setup.py and simple.py have execute permissions for all.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><snip><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">#!/bin/python<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">import setuptools<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">setuptools.setup(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    name="demo_nova_hooks",<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    version=5,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    packages=['demo_nova_hooks'],<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    entry_points={<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">        'nova.hooks': [<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">            'create_instance=demo_nova_hooks.simple:Simple',<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">        ]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">    },<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">)<o:p></o:p></span></p>
<p class="MsoNormal"></snip><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Here are the contents of simple.py:<o:p></o:p></p>
<p class="MsoNormal"><snip><o:p></o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">#!/usr/bin/python<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">import sys<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">class Simple(object):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   logfile = '/tmp/simple-nova-hook.log'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   with open(logfile, 'a+') as log:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">       print >>log, 'Begin Simple'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   def pre(self, *args, **kwargs):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">       with open(self.logfile, 'a+') as log:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">           print >>log, 'Begin Pre'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">           for i, arg in enumerate(args):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                print >>log, '%d: %s' % (i, arg)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">           for k, v in kwargs.items():<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                print >>log, '%s=%s' % (k, v)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">           print >>log, 'END PRE'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   def post(self, rv, *args, **kwargs):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">       with open(self.logfile, 'a+') as log:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">           print >>log, 'Begin Post'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">if __name__ == "__main__":<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   print "Started"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   a = Simple()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   a.pre("None")<o:p></o:p></span></p>
<p class="MsoNormal"></snip><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
<p class="MsoNormal">Sundar<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<hr>
<font face="Arial" color="Black" size="2"><br>
Confidentiality Notice.<br>
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.<br>
</font>
</body>
</html>