cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
756
Views
0
Helpful
2
Replies

how to use deref inside python

erdemk
Level 1
Level 1

Hello,

 

May someone guide me on how to use deref function within python service code.

I want to fetch the Loopback address of the other end. From within Python service code, I want to address the other end of the lXvpn service, and then fetch the loopback address.

 

THanks and regards.

1 Accepted Solution

Accepted Solutions

yfherzog
Cisco Employee
Cisco Employee

Suppose that your other-end device name is stored in d, loopback ID stored in lo_id and you have access to the root object (one of the arguments of the cb_create() method. Then you should be able to do something like this:

 

ip = root.ncs__devices.device[d].config.ios__interface.Loopback[lo_id].ip.address.primary.address

 

This is for an IOS device. For another kind of device, the config prefix will be different and the config path is also going to be different, but the idea remains the same.

You can get the xpath from CLI with 'show run devices device my-device config my-device-prefix:path to loopback | display xpath | display prefixes'

View solution in original post

2 Replies 2

yfherzog
Cisco Employee
Cisco Employee

Suppose that your other-end device name is stored in d, loopback ID stored in lo_id and you have access to the root object (one of the arguments of the cb_create() method. Then you should be able to do something like this:

 

ip = root.ncs__devices.device[d].config.ios__interface.Loopback[lo_id].ip.address.primary.address

 

This is for an IOS device. For another kind of device, the config prefix will be different and the config path is also going to be different, but the idea remains the same.

You can get the xpath from CLI with 'show run devices device my-device config my-device-prefix:path to loopback | display xpath | display prefixes'

I got it. Somehow, I was concentrated on deref function, I didn't think about fetching loopback from device tree.

Thanks

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: