cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1307
Views
10
Helpful
2
Replies

Using a Python IDE to develop services in NSO

Siliano
Level 1
Level 1

Hi all,

I'm new at NSO and I'm trying to set up PyCharm (Community Edition) to use Python API for develop services.
I'm a Junior Dev. and it would be useful to have an IDE that helps me in the development by suggesting the methods I can use; I recovered the Python APIs for NSO from a system installation in a Lab Environment. However, when I try to use the libraries, the IDE does not give me suggestions when I use "services."  . 
I give a basic example on a service that processes only the name of the devices with Python logic, I'll omit the auto-generated code:

 

def cb_create(self, tctx, root, service, proplist):
self.log.info('Service create(service=', service._path, ')')

 

for device_obj in service.device_name:

vars = ncs.template.Variables()
vars.add('DEVICE', device_obj.device)
template = ncs.template.Template(service)
template.apply('stub-juniper-config-vrf-template', vars)

 

The logic works, I followed the guide at this link, example 89

Tips on how I can set up the IDE correctly? Thank you in advance

1 Accepted Solution

Accepted Solutions

Rodolphe Trujillo
Cisco Employee
Cisco Employee

Hi @Siliano ,
I don't know if it works in the Community Edition but here is how it can be done in the Pro version.
In your project go to "Preferences" => "Project [Something]" => "Project Structure", click on "Add Content Root".
Point to the path of a NSO local install on your computer , the api is in "src/ncs/pyapi" of the local installScreenshot 2022-02-09 at 15.18.09.png

 

Screenshot 2022-02-09 at 15.39.38.png

View solution in original post

2 Replies 2

@Siliano have you looked at installing Tabnine in your IDE?

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Rodolphe Trujillo
Cisco Employee
Cisco Employee

Hi @Siliano ,
I don't know if it works in the Community Edition but here is how it can be done in the Pro version.
In your project go to "Preferences" => "Project [Something]" => "Project Structure", click on "Add Content Root".
Point to the path of a NSO local install on your computer , the api is in "src/ncs/pyapi" of the local installScreenshot 2022-02-09 at 15.18.09.png

 

Screenshot 2022-02-09 at 15.39.38.png

Polls
AI-powered tools for network troubleshooting are likely to be part of everyone’s workflow sooner or later. What is the single biggest challenge or concern you see with adopting these tools in your organization?