cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
425
Views
0
Helpful
1
Replies

Some questions regarding ydk.filters

Hello, 

Can you give me some guidance on ydk.filters ?   

I would like to figure out the principle that how to use ydk.filters ?

Below are some examples from Python YDK API document.

I have some findings from below examples but I am not sure if I am correct and I am sure it is only part of it not full.  Can you please give me full overview how to use ydk.filter.?

Thanks a lot

 

1 if attribute is a leaf we could use   

ins.running = YFilter.read   (running is a leaf)   read one specific leaf

cdp.timer = YFilter.delete   (timeer is a leaf)     delete one specific leaf

2 if attribute is a list or container

bgp.global_.config.yfilter = YFilter.replace   (config is container)  

route.yfilter = YFilter.read (route is list)        

ins.yfilter = YFilter.delete    (ins is list)

 

 

 

from ydk.filters import YFilter

1st

# First create the top-level Isis() object
isis = Cisco_IOS_XR_clns_isis_cfg.Isis()

# Create the list instance
ins = Cisco_IOS_XR_clns_isis_cfg.Isis.Instances.Instance()
ins.instance_name = 'default'

# Set the yfilter attribute of the leaf called 'running' to YFilter.read
ins.running = YFilter.read  

 
2nd

# First create the top-level Isis() object
isis = Cisco_IOS_XR_clns_isis_cfg.Isis()

# Create the list instance
ins = Cisco_IOS_XR_clns_isis_cfg.Isis.Instances.Instance()
ins.instance_name = 'xyz'

# Set the yfilter attribute of the leaf called 'running' to YFilter.delete
ins.yfilter = YFilter.delete

# Append the instance to the parent

 

3rd

# First create the top-level Cdp() object
cdp = Cisco_IOS_XR_cdp_cfg.Cdp()

# Set a dummy value to the leaf
cdp.timer = 5
# Assign YFilter.delete to the 'timer' leaf
cdp.timer = YFilter.delete

 

4th

# First create the top-level Isis() object
isis = Cisco_IOS_XR_clns_isis_cfg.Isis()

# Create the list instance
ins = Cisco_IOS_XR_clns_isis_cfg.Isis.Instances.Instance()
ins.instance_name = 'default'

# Assign YFilter.delete to the 'running' leaf
ins.running = YFilter.delete

# Append the instance to the parent
isis.instances.instance.append(ins)


isis.instances.instance.append(ins)

 

3rd

 

 
 
 

 
 
 
 
 

Jacky Zhang
Global Telecom
1 Reply 1

yangorelik
Spotlight
Spotlight

The ydk.filters used to attach Netconf operations to specific YANG model nodes (leaf, list, container). They are used to read, update, or delete those nodes. Each example in the documentation shows how to apply the filters for different types of nodes. Please run the scripts for better understanding.

Yan Gorelik
YDK Solutions