Following is the contributed tutorial from @namnh, a member of our Vietnam OpenStack Community. Please ping us if you have any questions.

This tutorial was created based on the last video tutorial "How to setup remote debugging with OpenStack Nova". Please see this video for more details:

https://www.youtube.com/watch?v=Z0PmKyeZjjA

And here is the tutorial for neutron:

In this archive, I will guide configuration to debug Neutron project by Pycharm-Pro5. And configuration with other projects are similar to Neutron project.

Step 1: Setup environment

We need two machines and topology as below:

Untitled

- Machine 1 (called "Pycharm-Pro5"): Installing Pycharm-Pro5.

- Machine 2 (called "VM"): Installing Openstack-AIO by Devstack.

Note:

- We will use Devstack to install Openstack-AIO. This is [local.conf](https://github.com/NguyenHoaiNam/Debuging_Openstack_with_Pycharm-Pro5/blob/master/local.conf) file.

Step 2: Configuration Pycharm on Pycharm-Pro5

Step 2.1: Setup Deverlopment by clicking Tools --> Deployment --> Configuration then click "+" to create a "Devstack".

Untitled

(1): Type of connect to VM. We will choose SFTP.

(2): The address of VM.

(3): The account of VM.

(4): The password of VM.

Note: In this step, we should check to connect to VM by choice "Test SFTP connection..."

Then we jump "Mappings" tab. To configure mapping between Pycharm-Pro5 and VM is like image:

Untitled

(5): This is local path on Pycharm-Pro5.

(6): This is path on VM.

Click OK.

Step 2.2: Setup project by clicking File --> Settings then choose "Project: neutron" (in this case, I am setting debug with neutron project, with other projects are similar.)

Choice "Project Interpreter" to add an interpreter remote by choice "Add remote":

687474703a2f2f692e696d6775722e636f6d2f6a7864374e54382e706e67

After choice "Add remote", we have image:

Untitled

Change to "Deployment configuration" then click "ssh://[email protected]:22" to connect to VM. In this time, we will receive message "Successfully ...."

Untitled

We need to wait for a few time so that Pycharm download packet from VM.

Step 2.3: Configuration Python Debugger. In "Settings", we choose "Build, Execution, Deployment" --> "Python Debugger" then select "Gevent compatible"

Untitled

After done, we click OK.

Step 3: Configuration debug with Neutron prject

In this step, I will configure debug with neutron-server. With other component or other project, they are similar.

Step 3.1: Create tab debug by clicking Run --> Edit Configurations then create a neutron-server debug like that:

Untitled

Step 3.2: Configuration API-worker on VM

Because Pycharm-Pro5 debug only one process so we have to configure on VM so that neutron-server run only one process.

Edit configure file /etc/neutron/neutron.conf. At first line we change api_workers = -1 (note that in nova api configuration, the config for only one process api worker is osapi_worker = 1. The nova API daemon does not accept negative value).

Step 3.3: After changing configuration file, turn off neutron-server process on VM. (Hint: you can use rejoin-stack to do that).

Step 4: Start debugging

After finishing all steps. We can start debug by click "debug" button. Have fun !!!

Optional: If you want to locally debugging your openstack neutron, please apply monkey patch for eventlet for collecting debug information from openstack process. In neutron, edit file __init__.py in neutron/common/eventlet_utils.py and modify line 32 from:

eventlet.monkey_patch()

to:

eventlet.monkey_patch(os=False, thread=False)

 

Happy debugging !

Click here to view this tutorial source on GitHub

04/2016

VietStack team.