cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
738
Views
5
Helpful
1
Replies

Reading CDB path value from service main.py

nso20
Level 1
Level 1

Hello,

Generally, I am trying to read a value from CDB, e.g. the description of interface on a device. So, Firstly, in myservice main.py, I used the python code mentioned in development document: Example 102. Setting of operational data using CDB API, but it gives me the blow error, can you help me read CDB records using python ?

Error: badly formatted or nonexistent path (8): Bad path element "operdata" after: /

1 Reply 1

tcragg1
Cisco Employee
Cisco Employee

Example 102 from the development doc (at least in the version I am using) refers to using the low level CDB API. You may find it easier to use the high level python APIs instead. In particular, see the section on the Maagic API within the Python API chapter in the development guide for details.

 

If you are running this code inside a python service callback, it will already have the CDB root defined as a python object, so you should just need to navigate to the correct node in CDB. For example, to find an interface description for a device using the IOS CLI NED would be something like the following:

 

intf_desc = root.devices.device['ce1'].config.interface.GigabitEthernet['0/0/0'].description

 

The exact code you need will depend on the YANG model of the device you are trying to find CDB data from.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: