DMYTRO SHYTYI

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:

config t
java-vm service-transaction-timeout 12000

Second:

install eclipse and pydev in VM1:

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”:

Window->Perspective->Open Perspective->Other->PyDev

Then you have to activate Debug Server( check the top of the window for tabs “File”,”Edit”, etc.:

PyDev->Start Debug Server

In the console you will find the next information:

Debug Server at port: 5678

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:

import pydevd

pydevd.settrace('10.0.10.100', port=5678, stdoutToServer=True, stderrToServer=True)