Cisco NSO debug service python PyDev pydevd
This post presents NSO python service debugging.
To debug you will need:
- PyDev plugin for eclipse
- pydevd python module
There two VMs configured in this case:
VM1: eclipse+pydev is installed
VM2: NSO+pydevd is installed (NSO service with pydevd initialized that is connecting to the Eclipse/PyDev Debugger.)
First configure NSO to increase the transaction timeout:
Second:
install eclipse and pydev in VM1:
- Link to install Eclipse https://www.eclipse.org/downloads/packages/installer
- Link to install the Pydev https://www.pydev.org/manual_101_install.html
install “pydevd” with pip/pip3 in VM2.
In VM1 Eclipse/PyDev has a debugger. To start the debugger you will need to perform the actions decribed below.
You have to open tab “Pydev”. To make visible tab Pydev you need to chose Pydev “Perspective”:
Then you have to activate Debug Server( check the top of the window for tabs “File”,”Edit”, etc.:
In the console you will find the next information:
So Pydevd from NSO service will connect to Eclipce PyDev Debugger via port [5678] and ip address of machine where Debug server is Running.
The last thing left is to initialize the pydevd python module in the service:
to apply the modification in the NSO you have to do
When the service will be activated the pydevd module will connect the Eclipse/PyDev Debugger.
The Eclipse/PyDev Debugger will open an window and propose to open a file with the code of the service saved locally in the VM1.
It should be the same as the file in the NSO VM2.
Open in the appeared window the python file located in the NSO service: “/rfs/service_dmytro_shytyi_net/python/dmytro_shytyi_net/dmytro_shytyi_net.py”
Now you may debug your service. This is free opensource analog to PyCharm (in the PyCharm commynity edition the remote debuggin is not available).
In the figure below you may see the value ” Hello from Dmytro” of the variable “helloworld” of the NSO service.