02-08-2022 03:38 AM
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
Solved! Go to Solution.
02-09-2022 06:40 AM - edited 02-09-2022 06:43 AM
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 install
02-08-2022 09:59 AM
@Siliano have you looked at installing Tabnine in your IDE?
02-09-2022 06:40 AM - edited 02-09-2022 06:43 AM
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 install
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