Ask Your Question

How do I debug Nova service with eclipse and pydev

asked 2013-05-07 02:14:08 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I am trying to debug nova api and my breakpoints are ignored. I have eclipse, pydev and have rub devstack to get all the services. I kill the nova service and then I got to file nova-all > debug > python run, but no luck.

I have commented out eventlet.monkey_patch(os=False) and replaced it with eventlet.monkey_patch(all=False,socket=True,time=True,os=False) and added import sys;sys.path.append(r'/home/dev/.eclipse/org.eclipse.platform_3.7.0_155965261/plugins/org.python.pydev_2.7.3.2013031601/pysrc/') for file /nova/nova/cmd/ and I have then added import pydevd;pydevd.settrace() to the function I am interested in stepping into (above the breakpoint), again no luck...

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-01-24 11:09:04 -0500

smaffulli gravatar image

Here is a link to documentation on how to debug openstack using eclipse:

edit flag offensive delete link more

answered 2013-05-18 11:58:29 -0500

Sagar Ratnakara Nikam gravatar image

updated 2014-01-24 11:05:09 -0500

smaffulli gravatar image

I use devstack and eclipse pydev to debug openstack services using the remote debugging feature of pydev. I first install openstack using devstack. Then create a new project in eclipse pydev using the code available at /opt/stack/. Once that is done, all openstack code is available in eclipse pydev.

All openstack services are available as screens and can be checked using the command screen -r

Now let us understand how to debug nova API service.

First check the location of for the directory "pysrc". Generally it is available in /opt/eclipse/plugins/org.python.pydev_2.7.4.2013051601/pysrc

Add this to the python path. This can be done by modifing /nova/nova/cmd/

search for the line import sys and then the following line below it

sys.path.append("path to pysrc on your machine")

Next search for line


Comment this line and add the following line

 eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=False)

Once this is done, modify the python file which you want to debug and add the following line where you want the breakpoint

  import pydevd;pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True,suspend=True)

Open the debug perspective in eclipse pydev and start the debug server. Check the port on which debug server started. If the port is not 5678, replace the port in the above line of code with the port number on which debug server started

Now you need to restart the nova api service from screen. Enter screen -r and then goto to nova-api screen (which is screen 5) by entering CTRL+A followed by 5.

Once you are in nova-api screen, kill the nova-api service(CTRL+C) and the restart it by pressing "up" arrow and enter. Once nova-api service is started, try to execute an api which will call the code which has the debug point, and the debug point will be hit.

I tried to debug the nova api stop instance by adding the debug code in the /nova/compute/, definition stop as shown below

def stop(self, context, instance, do_cast=True):

"""Stop an instance."""

        LOG.debug(_("Going to try to stop instance"), instance=instance)
        import pydevd;pydevd.settrace('localhost', port=5678, stdoutToServer=True, stderrToServer=True,suspend=True)

When I tried to stop an instance, I could get the debug point.

Hope this helps and answer your question. I have not tried local debugging, Ie starting nova-api service from eclipse. I find remote debuging more easy as all services are already started by devstack.

edit flag offensive delete link more


Assuming that eclipse is installed on the other machine (not the openstack one), how would it be possible to access the source code in the opt directory?

spoilt gravatar imagespoilt ( 2013-07-11 01:20:00 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools



Asked: 2013-05-07 02:14:08 -0500

Seen: 3,389 times

Last updated: Jan 24 '14