Difference between revisions of "Barbican/Barbican-IDE-Debugging"
(→Eclipse) |
|||
(35 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | This page describes how to setup and debug | + | 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. |
== Assumptions == | == Assumptions == | ||
− | + | # Barbican is installed as per instruction. | |
− | + | # IDE (PyCharm/Eclipse) installed and Barbican project is configured. | |
− | + | # In case of 'Eclipse', PyDev plug-in is installed. | |
− | + | # Barbican can be installed locally or remotely. In case of local installation IDE and Barbican must be co-located on same host. | |
== Python Setup == | == Python Setup == | ||
− | The | + | The 'pydev' libraries must be installed into the python environment which will run the OpenStack Barbican services. |
=== PyCharm === | === 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: | 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: | ||
− | + | <!--T:1--> | |
− | |||
cd <python installation that will run barbican>/lib/python2.7/site-packages | cd <python installation that will run barbican>/lib/python2.7/site-packages | ||
unzip <installation of pycharm>/pycharm-debug.egg | unzip <installation of pycharm>/pycharm-debug.egg | ||
− | |||
=== Eclipse === | === Eclipse === | ||
− | Under | + | Under '<ECLIPSE_HOME>/plugins/' folder find the 'pysrc' directory which contains the pydev libraries. |
− | + | <!--T:2--> | |
e.g. <ECLIPSE_HOME>/plugins/org.python.pydev_2.8.2.2013090511/pysrc | e.g. <ECLIPSE_HOME>/plugins/org.python.pydev_2.8.2.2013090511/pysrc | ||
− | |||
− | Update the | + | Update the 'PYTHONPATH' environment variable which will run the 'OpenStack Barbican' services with path to the 'pydev' libraries. |
− | + | <!--T:3--> | |
e.g. if Barbican service is started from Linux shell then | e.g. if Barbican service is started from Linux shell then | ||
export PYTHONPATH=<ECLIPSE_HOME>/plugins/org.python.pydev_<version>/pysrc | export PYTHONPATH=<ECLIPSE_HOME>/plugins/org.python.pydev_<version>/pysrc | ||
− | Note: for remote debugging, copy | + | Note: for remote debugging, copy 'pysrc' folder to the remote machine and set the 'PYTHONPATH' as above. |
− | |||
== Start debug server in IDE == | == Start debug server in IDE == | ||
Line 42: | Line 38: | ||
=== PyCharm === | === PyCharm === | ||
− | Follow the instructions from [ | + | Follow the instructions from [http://tropicaldevel.wordpress.com/2013/01/24/debugging-openstack-with-pycharm-and-pydevd/ this post] to setup and start the debug server on particular host and port. |
− | Assuming | + | Assuming 'localhost' and '5678' is configured for debugger, you will see following message on console. |
− | + | <!--T:4--> | |
Starting debug server at port 5678 | Starting debug server at port 5678 | ||
Waiting for connection... | Waiting for connection... | ||
− | |||
=== Eclipse === | === Eclipse === | ||
Line 55: | Line 50: | ||
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. | 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 | + | == 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). | |
+ | <!--T:5--> | ||
cd <barbican_home>/bin | cd <barbican_home>/bin | ||
./barbican.sh debug | ./barbican.sh debug | ||
− | |||
− | 2. If | + | 2. If Barbican and IDE are not running on same host. Run following command on remote host which is hosting Barbican service. |
− | + | <!--T:6--> | |
cd <barbican_home on the remote host>/bin | cd <barbican_home on the remote host>/bin | ||
./barbican.sh debug --pydev-debug-host localhost --pydev-debug-port 5678 | ./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. | 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. | ||
Line 77: | Line 69: | ||
== Troubleshooting == | == Troubleshooting == | ||
− | + | '''ImportError: No module named pydevd''' | |
− | + | <!--T:7--> | |
− | 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 ERROR barbican.common.config [-] Unable to join debugger, please make sure that the debugger processes is listening on debug-host 'localhost' debug-port '5678'.<br /> |
− | 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 Traceback (most recent call last):<br /> |
− | 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 File "/home/atiwari/cloudDev/barbicanDev/barbican-master/barbican/common/config.py", line 109, in setup_remote_pydev_debug<br /> |
− | 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 import pydevd<br /> |
− | 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 ImportError: No module named pydevd<br /> |
− | 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config | + | 2014-04-16 14:13:16.539 19741 TRACE barbican.common.config <br /> |
− | 2014-04-16 14:13:16.540 19741 CRITICAL barbican [-] ImportError: No module named pydevd | + | 2014-04-16 14:13:16.540 19741 CRITICAL barbican [-] ImportError: No module named pydevd<br /> |
− | 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 Traceback (most recent call last):v |
− | 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 File "/home/atiwari/.pyenv/versions/barbican27/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp<br /> |
− | 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 return loadobj(APP, uri, name=name, **kw)<br /> |
− | 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 | + | 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 loadobjv |
− | 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()v |
− | |||
'''Solution''' | '''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<br /> | ||
+ | 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'.<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config Traceback (most recent call last):<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config stderrToServer=True)<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config _locked_settrace(host, stdoutToServer, stderrToServer, port, suspend, trace_only_current_thread)<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config debugger.connect(host, port)<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config s = StartClient(host, port)<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config s.connect((host, port))<br /> | ||
+ | 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<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config return getattr(self._sock,name)(*args)<br /> | ||
+ | 2014-04-16 14:27:46.205 20635 TRACE barbican.common.config error: [Errno 111] Connection refused<br /> | ||
'''Solution''' | '''Solution''' | ||
Line 126: | Line 113: | ||
== Reference == | == Reference == | ||
− | + | * [http://tropicaldevel.wordpress.com/2013/01/24/debugging-openstack-with-pycharm-and-pydevd/ Debugging OpenStack with pycharm and pydevd] | |
− | + | * [http://brianfisher.name/content/remote-debugging-python-eclipse-and-pydev Remote Debugging Python with Eclipse and PyDev] |
Latest revision as of 22:57, 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
- Barbican is installed as per instruction.
- IDE (PyCharm/Eclipse) installed and Barbican project is configured.
- In case of 'Eclipse', PyDev plug-in is installed.
- 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):v
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 loadobjv
2014-04-16 14:13:16.540 19741 TRACE barbican return context.create()v
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.