09-05-2020 02:32 AM
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
# 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
09-06-2020 03:05 PM
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.
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