Difference between revisions of "Barbican/Barbican-IDE-Debugging"
(→Troubleshooting) |
(→Troubleshooting) |
||
Line 84: | Line 84: | ||
2014-04-16 14:13:16.540 19741 TRACE barbican File "/home/atiwari/.pyenv/versions/barbican27/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj | 2014-04-16 14:13:16.540 19741 TRACE barbican File "/home/atiwari/.pyenv/versions/barbican27/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj | ||
2014-04-16 14:13:16.540 19741 TRACE barbican return context.create() | 2014-04-16 14:13:16.540 19741 TRACE barbican return context.create() | ||
− | |||
'''Solution''' | '''Solution''' | ||
− | |||
Make sure 'pydev' libraries are properly configured. Follow the instruction at "Python Setup" given above. | Make sure 'pydev' libraries are properly configured. Follow the instruction at "Python Setup" given above. | ||
Revision as of 22:20, 16 April 2014
This page describes how to setup and debug Barbican code using your favorite IDE (Eclipse or PyCharm) debugger. This instruction can be used for local or remote debugging scenarios.
Contents
Assumptions
1. Barbican is installed as per instruction. 2. IDE (PyCharm/Eclipse) installed and Barbican project is configured. 3. In case of 'Eclipse', PyDev plug-in is installed. 4. Barbican can be installed locally or remotely. In case of local installation 'IDE' and Barbican must be co-located on same host.
Python Setup
The pydev libraries must be installed into the python environment which will run the OpenStack Barbican services.
PyCharm
Find the file pycharm-debug.egg under the directory where you installed pycharm. It should be in the top-level directory. Now do the following:
cd <python installation that will run barbican>/lib/python2.7/site-packages unzip <installation of pycharm>/pycharm-debug.egg
Eclipse
Under <ECLIPSE_HOME>/plugins/
folder find the pysrc directory which contains the pydev libraries.
e.g. <ECLIPSE_HOME>/plugins/org.python.pydev_2.8.2.2013090511/pysrc
Update the 'PYTHONPATH' environment variable which will run the 'OpenStack Barbican' services with path to the 'pydev' libraries.
e.g. if Barbican service is started from Linux shell then export PYTHONPATH=<ECLIPSE_HOME>/plugins/org.python.pydev_<version>/pysrc Note: for remote debugging, copy 'pysrc' folder to the remote machine and set the 'PYTHONPATH' as above.
Start debug server in IDE
PyCharm
Follow the instructions from this post to setup and start the debug server on particular host and port.
Assuming 'localhost' and '5678' is configured for debugger, you will see following message on console.
Starting debug server at port 5678 Waiting for connection...
Eclipse
Go to 'Window > Preferences > PyDev > Debug' and change the debug server port (Default 5678) if needed. Click "PyDev > Start Debug server" to start eclipse debug server.
Start Barbican service in debug mode
To start Barbican in debug mode
1. If Barbican and 'IDE' are running on same host and debugger process is listening on default port (e.g. 5678).
cd <barbican_home>/bin ./barbican.sh debug
2. If Barbican and 'IDE' are not running on same host. Run following command on remote host which is hosting Barbican service.
cd <barbican_home on the remote host>/bin ./barbican.sh debug --pydev-debug-host localhost --pydev-debug-port 5678
Note: By default 'pydevd.settrace' (debug break point) is set in 'setup_remote_pydev_debug()' method of 'barbican/common/config.py'. Don't get surprised if barbican process seems blocked, press "F8" or "Resume" button on IDE to proceed.
Troubleshooting
ImportError: No module named pydevd
2014-04-16 14:13:16.539 19741 ERROR barbican.common.config [-] Unable to join debugger, please make sure that the debugger processes is listening on debug-host 'localhost' debug-port '5678'. 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config Traceback (most recent call last): 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config File "/home/atiwari/cloudDev/barbicanDev/barbican-master/barbican/common/config.py", line 109, in setup_remote_pydev_debug 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config import pydevd 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config ImportError: No module named pydevd 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config 2014-04-16 14:13:16.540 19741 CRITICAL barbican [-] ImportError: No module named pydevd 2014-04-16 14:13:16.540 19741 TRACE barbican Traceback (most recent call last): 2014-04-16 14:13:16.540 19741 TRACE barbican File "/home/atiwari/.pyenv/versions/barbican27/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp 2014-04-16 14:13:16.540 19741 TRACE barbican return loadobj(APP, uri, name=name, **kw) 2014-04-16 14:13:16.540 19741 TRACE barbican File "/home/atiwari/.pyenv/versions/barbican27/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj 2014-04-16 14:13:16.540 19741 TRACE barbican return context.create()
Solution Make sure 'pydev' libraries are properly configured. Follow the instruction at "Python Setup" given above.
error: [Errno 111] Connection refused
Loading paste environment: config:/etc/barbican/barbican-api-paste.ini 2014-04-16 14:27:46.205 20635 ERROR barbican.common.config [-] Unable to join debugger, please make sure that the debugger processes is listening on debug-host 'localhost' debug-port '567'. 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config Traceback (most recent call last): 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/cloudDev/barbicanDev/barbican-master/barbican/common/config.py", line 114, in setup_remote_pydev_debug 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config stderrToServer=True) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/eclipse4py/plugins/org.python.pydev_2.8.2.2013090511/pysrc/pydevd.py", line 1247, in settrace 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config _locked_settrace(host, stdoutToServer, stderrToServer, port, suspend, trace_only_current_thread) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/eclipse4py/plugins/org.python.pydev_2.8.2.2013090511/pysrc/pydevd.py", line 1272, in _locked_settrace 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config debugger.connect(host, port) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/eclipse4py/plugins/org.python.pydev_2.8.2.2013090511/pysrc/pydevd.py", line 300, in connect 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config s = StartClient(host, port) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/eclipse4py/plugins/org.python.pydev_2.8.2.2013090511/pysrc/pydevd_comm.py", line 365, in StartClient 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config s.connect((host, port)) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config File "/home/atiwari/.pyenv/versions/2.7.5/lib/python2.7/socket.py", line 224, in meth 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config return getattr(self._sock,name)(*args) 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config error: [Errno 111] Connection refused
Solution
Debugger server process is not listening on debug-host 'localhost' debug-port '567'. Make sure you have started it on correct port.