cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
243
Views
0
Helpful
2
Replies
Highlighted
Beginner

how to use deref inside python

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.

Everyone's tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: how to use deref inside python

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'

2 REPLIES 2
Cisco Employee

Re: how to use deref inside python

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'

Beginner

Re: how to use deref inside python

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

Thanks