Debug Openstack code Local / Remote with Eclipse and PyDev Plug-In
May 30, 2013 3 Comments
This article is a result of my exhaustive search for finding a concrete way to debug Openstack. After referring several places, I have come up with a manual of my own on how to setup eclipse environment to debug and understand openstack code flow. It should be a good read if you have similar questions as posted below in your mind.
- Is it possible to debug openstack code end-to-end?
- Should I debug locally (everything configure inside eclipse)?
- How to debug remotely running openstack services?Or, combination of above two?
- What developer tools/IDEs to use for debugging? (eclipse +pydev, pdb, winpdb, pycharm)?
- What’s the best/easiest/more sophisticated method, to get set everything quickly?
And there’s bunch of other questions, followed by multiple alternatives to chose from.
Here in this post, I have tried debugging using Eclipse with pydev plug-in.
Development Environment:
How to Debug Openstack Services Locally?
To begin with, you can try with keystone in eclipse.
As you have already install keystoneclient by following above link, from terminal execute:
$keystone tenant-list
Voila, You have just got setup for local debugging.
Remote Debugging:
Development Environment:
Configure pydev debug server in eclipse.
http://pydev.org/manual_adv_remote_debugger.html
/pysrc – will be found in eclipse installation plugins/org.python.pydev_<version>/pysrc
Ex: /usr/lib/python2.6/site-packages/pysrc/
Example-1: Remote debug keystone
Function: def get_all_tenants(self, context, **kw): # gives tenant-list
import pydevd;pydevd.settrace(<IP addr of eclipse vm>, port=8765, stdoutToServer=True, stderrToServer=True,suspend=True)
sys.path.append(‘/usr/lib/python2.6/site-packages/pysrc/’)
eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=False)
As, the debug server listen to single thread, above line will take away green threading of thread module.
$keystone tenant-list
You should be able to hit break-point in core.py file, and step through further debug execution.
Example-2: Debugging keystone(get auth-token) + nova-api
$nova flavor-list #will debug this cli
File: /keystone/keystone/service.py
Class: class TokenController
Method:def authenticate(self, context, auth=None):
Add following line:
import pydevd;pydevd.settrace(‘<IP addr of eclipse vm>’, port=8765, stdoutToServer=True, stderrToServer=True,suspend=True)
eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=False)
As, the debug server listen to single thread, above line will take away green threading of thread module.
Restart keystone service
def detail(self, req):
import pydevd;pydevd.settrace((<IP addr of eclipse vm>, port=8765, stdoutToServer=True, stderrToServer=True,suspend=True)
sys.path.append(‘/usr/lib/python2.6/site-packages/pysrc/’)
eventlet.monkey_patch(all=False,socket=True,time=True,os=False,thread=False)
In eclipse, this should hit break-point in service.py for keystone
After keystone token generated, control move to flavors.py
Things observed:
Path resolution:
If python paths and/or openstack code paths different on both VMs, eclipse will not be able to locate correct file to open, and respond with open file dialog, just cancel the dialog and file from remote machine get displayed. This file will get store into prsrc/temporary_file directory.
To avoid this, on server running openstack service, go to pysrc directory, and modify the file, pydevd_file_utils.py.
More info on this: http://pydev.org/manual_adv_remote_debugger.html
Reblogged this on Sutoprise Avenue, A SutoCom Source.
I believe everything said made a great deal of sense.
However, what about this? suppose you were to write a killer headline?
I mean, I don’t want to tell you how to run your website, however suppose you
added a post title that grabbed people’s attention? I mean Debug Openstack code Local / Remote with Eclipse and PyDev Plug-In | iLearnStack is kinda
boring. You should glance at Yahoo’s home page and
watch how they create article headlines to get people to click.
You might add a video or a related pic or two to get people
excited about what you’ve written. In my opinion, it
would make your posts a little bit more interesting.
Hi, the whole thing is going perfectly here and ofcourse every one
is sharing facts, that’s really fine, keep up writing.