03-12-2020 12:44 PM
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: /
03-13-2020 08:01 AM
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.
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