First, install Eclipse, Pydev plug-in
official eclipse:https://www.eclipse.org/downloads/
This is not described in detail here, first install the Java operating environment, then install Eclipse is right.
Install the Pydev plugin: Turn on Eclipse---help--and install New software; details refer to this (http://www.pydev.org/manual_101_install.html)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/B5/wKioL1buWELgJBzEAAFe7b24DYM749.png "title=" 7bd67320-842f-4622-bb2d-0bd21721f427.png "alt=" Wkiol1buwelgjbzeaafe7b24dym749.png "/>
Second, configuration Pydev debug
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7D/B6/wKioL1buW0eiDklEAACzsGCMUg8427.png "title=" 8e499721-4427-4382-a652-9a75b4c353ca.png "alt=" Wkiol1buw0eidkleaaczsgcmug8427.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/B9/wKiom1buW3jjvFffAAEqRJYrOD8592.png "title=" 94957a37-a413-4a7f-91c6-75f0f2de80fe.png "alt=" Wkiom1buw3jjvfffaaeqrjyrod8592.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7D/B9/wKiom1buXW6DJpDPAACiXMuiE4g651.png "title=" 0ac8b033-3ade-4ba8-9449-8e841c4afc53.png "alt=" Wkiom1buxw6djpdpaacixmuie4g651.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/B6/wKioL1buXqGyudGiAADPl1oqaaE128.png "style=" float: none; "title=" 744162a4-9193-4557-8b02-21cbe4d3286a.png "alt=" Wkiol1buxqgyudgiaadpl1oqaae128.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/B9/wKiom1buXg6T5ns_AABou3P4s0w638.png "style=" float: none; "title=" B2d80ab0-1c7b-4cc6-a749-267343cfed73.png "alt=" Wkiom1buxg6t5ns_aabou3p4s0w638.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7D/B6/wKioL1buXvCAuZeUAAEk_nPG8_g006.png "title=" 21e820f3-ef43-4cad-a0b6-2d5a687758f4.png "alt=" Wkiol1buxvcauzeuaaek_npg8_g006.png "/>
Configuring Debug Server Information
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/B9/wKiom1buYL7CFf3qAAGn-OYR-VQ680.png "title=" 87d6ade9-0296-4860-b7f6-fc4ee59f3e51.png "alt=" Wkiom1buyl7cff3qaagn-oyr-vq680.png "/>
Third, remote debugging OpenStack Nova API (Nova stop instance API call)
1. Make sure the Nova API server is running remotely, and can be found from the Pydev plugin directory where eclipse is installed locally (the directory may vary under different environments) pydevd.py
Then copy to the Python path running the Nova API server
ices-macbook-air:~ iceyao$ ls-l/users/iceyao/.p2/pool/plugins/org.python.pydev_4.5.4.201601292234/pysrc/ pydevd.py-rw-r--r--1 Iceyao staff 60901 Jan 20:32/users/iceyao/.p2/pool/plugins/org.python.pydev_4.5.4.2016012922 34/pysrc/pydevd.py
2, next to ensure that the local eclipse side also has a copy of the same code, if in a different directory, you can use to modify the pydevd_file_utils.py file to achieve
# file locations may vary in different environments ices-macbook-air:~ iceyao$ ls-l/users/iceyao/.p2/pool/plugins/org.python.pydev_ 4.5.4.201601292234/pysrc/pydevd_file_utils.py-rw-r--r--1 Iceyao staff 14343 Mar 14:50/users/iceyao/.p2/pool/plugi ns/org.python.pydev_4.5.4.201601292234/pysrc/pydevd_file_utils.pyices-macbook-air:~ iceyao$ VIM/USERS/ICEYAO/.P2 /pool/plugins/org.python.pydev_4.5.4.201601292234/pysrc/pydevd_file_utils.py # Find Paths_from_eclipse_to_ Pythonpaths_from_eclipse_to_python = [(R '/opt/stack/a/nova ', # Local path R '/opt/stack/nova ') # Remote PYTHON process path ]
Import a local/opt/stack/a/nova project
File-to-Existing Projects into Workspace
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/B6/wKioL1buZ3vD4PYRAADKu5hDBuk793.png "title=" A2e7cbf2-4652-4a69-bb14-0ab4969c585d.png "alt=" Wkiol1buz3vd4pyraadku5hdbuk793.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7D/BA/wKiom1buZ6jARGwrAAEMugTE53c702.png "title=" Ca6ef5d1-d805-41e5-8963-65cce091dd41.png "alt=" Wkiom1buz6jargwraaemugte53c702.png "/>
3. remotely run the Nova API server set breakpoints
Local eclipse machine turns on debug monitoring
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/BA/wKiom1buatuD4BvEAACrAVOiwwo636.png "title=" Dc30b0b3-caf5-41dd-9079-659469922c54.png "alt=" Wkiom1buatud4bveaacravoiwwo636.png "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/BA/wKiom1buaxLhUuj-AAEi3AG6HR4691.png "title=" 90759640-e822-423d-947b-78313138cb50.png "alt=" Wkiom1buaxlhuuj-aaei3ag6hr4691.png "/>
Log in to the remote Devstack environment, enter screen, add--remote_debug-host 172.16.1.10--remote_debug-port 12306, restart the service
172.16.1.10: Install Eclipse's machine IP locally
[Email protected]:/opt/devstack$/usr/local/bin/nova-api--remote_debug-host 172.16.1.10--remote_debug-port 12306 & Echo $! >/opt/stack/status/stack/n-api.pid; FG | | echo "N-api failed to start" | Tee "/opt/stack/status/stack/n-api.failure"
[Email protected]:~/nova$ cat nova/cmd/__init__.py # The meaning of the above parameters import eventletfrom Nova import Debuggerif debugger.enabled ( ): # Turn off thread patching to enable the remote debugger Eventlet.monkey_patch (Os=false, Thread=false) # Plus above Debu After the G parameter, the automatic Eventlet turns off multi-threading, otherwise the Code Else:eventlet.monkey_patch (Os=false) that cannot capture the power-off debug will appear.
Set breakpoints
[email protected]:~/nova$ vim nova/compute/api.py @check_ instance_lock @check_instance_host @check_instance_cell @check_instance_state (vm_state=[vm_states. Active, vm_states. ERROR]) def stop (self, context, instance, do_cast=true, clean_ shutdown=true): "" "Stop an instance" "" " import pydevd;pydevd.settrace (host= ' 172.16.1.10 ', Port=12306, stdouttoserver=true, stderrtoserver=true,suspend=true) # break point self.force_stop (Context, instance, do_cast, clean_shutdown) [email protected]:~/nova$ nova list+----------------- ---------------------+------+--------+------------+-------------+--------------------------------+| id | name | status | task state | Power State | Networks |+------------------------------------ --+------+--------+------------+-------------+--------------------------------+| c04f9a2f-36b3-4104-8c75-5461491aca97 | test | active | - | running | public=2001:db8::3, 172.24.4.3 |+--------------------------------------+------+--------+------------+-------------+---- ----------------------------+[email proteCted]:~/nova$[email protected]:~/nova$ nova stop c04f9a2f-36b3-4104-8c75-5461491aca97 # nova Client initiated Request
The local eclipse machine is captured, and then it's ready to be debugged.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/B6/wKioL1bubU-y82CqAANMOpWVTz8148.png "title=" Caaf737f-b4e6-4cbe-b509-7aae55975ab0.png "alt=" Wkiol1bubu-y82cqaanmopwvtz8148.png "/>
Reference links
Http://www.pydev.org/manual_101_install.html (Pydev installation)
http://zhaozhiming.github.io/blog/2014/04/13/python-remote-debug-setting-by-pycharm-and-eclipse-in-ubuntu/
http://blog.csdn.net/tantexian/article/details/47003385
http://blog.csdn.net/quqi99/article/details/18404807
http://yikun.github.io/2016/02/23/%E4%BC%98%E9%9B%85%E5%9C%B0%E8%B0%83%E8%AF%95OpenStack/( Pycharm remote Debugging OpenStack)
This article is from the "The-way-to-cloud" blog, make sure to keep this source http://iceyao.blog.51cto.com/9426658/1753169
Eclipse + Pydev Remote Debugging OpenStack