07-26-2019 02:56 PM
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
07-30-2019 01:39 AM - edited 07-30-2019 01:40 AM
Hey,
what you will have to do is to install the official MS Python plugin for VS Code.
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.
07-30-2019 04:37 AM
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?
07-30-2019 07:14 AM
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.
09-17-2023 11:32 AM - edited 09-17-2023 11:33 AM
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.
09-18-2023 12:40 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide