cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1581
Views
0
Helpful
5
Replies

VSCode debugger for NSO Services with Python code

DaSt-1986
Level 1
Level 1

Hi there,

 

After attending the NSO Developer Days in Stockholm I started working on my own services. After a few simple template based services, I started using Python to generate configs based on input from different sources. I love the options NSO offers to create something in Cisco NSO with Python.

 

I love using VSCode to write code; I use the Remote SSH plugin so I can edit the code on my Cisco NSO server without the need to install VSCode on my NSO Server. What I would like next is using the VSCode Python Debugger for Cisco NSO services. I found a manual online to do this with PyCharm, but I never got used to that IDE. I rather use VSCode.

 

Can anybody help me with setting up Python debugging for Cisco NSO in VSCode?

 

Thanks in advance,

Daryl Stark

5 Replies 5

uavsec001
Level 1
Level 1

Hey,

what you will have to do is to install the official MS Python plugin for VS Code.

image.png

Once you have done that and you are connected to your server, you need to enable the python plugin functionality on the remote. If you click on the cog icon for the py plugin you should be able to see "eanble" option. VSC will upload something to the server and at one point you should be able to see "Extension is enabled on.." next to the plugin name (blue round icon with two white arrows).

 

After that you need to select which python version you will be using for you scripts (that is done in the bottol left corner of VSC, next to that green SSH box). You will be prompted to install a py linter on the server in case you don't already have it.

 

Intellisense will work well, debugging is ok for standalone py scripts.

Thank you for your response. I did that and I am able to start Python scripts that way. But what I want is to debug a Python file I wrote for a service.

 

For instance; I have a service called 'new-vpn' which triggers a Python script in it's manifest file. I want to be able to set a breakpoint in VS Code in this Python script to be able to inspect variables when I configure the service in NSO. Is that possible?

Unfortunately the actual service py code can't be debugged like that (to my best knowledge) as it requires the NSO runtime.

The old way of logging and tail -f has to be used.

I use pyCharm from jetBrains.  Their documentation is very clear.  But you may need to 'buy' .  Last time I checked, about 8 months back, the community edition does not let us debug.   Give a shot at it.  Please let me know.  My pyCharm license expires soon.
If you have problems with pyCharm setup, I can help

The community edition of java IntelliJ, can stop at breakfpoints of NSO service.  But Python Pycharm would not let us.  Strange.