ā03-11-2021 12:31 AM
Is there a way to get everything that a list contains without having to provide the keys for all elements in the list and getting them individually?
I.e. "ydk.models.ietf.ietf_diffserv_policy" contains a class "Policies" which again contains a list "PolicyEntry". Can I get all data from this list all at once? or do I have to get them one by one by creating a filter and providing their corresponding key "policy_name"?
Solved! Go to Solution.
ā03-12-2021 11:11 AM
Yes, you can get the entire content of the list in YDK-0.8.5. The examples for such CRUD Service operations are present in the online documentation. In short, you need instantiate one list element without configuring any key and set a read filter operation on it. Here is a peace from the documented example, where we try to get route table from deeply rooted YANG model Cisco_IOS_XR_ip_rib_ipv4_oper.yang:
# Create the list member instance Route() route = Cisco_IOS_XR_ip_rib_ipv4_oper.Rib.Vrfs.Vrf.Afs.Af.Safs.Saf.IpRibRouteTableNames.IpRibRouteTableName.Routes.Route()
# Set the yfilter attribute for the route instance route.yfilter = YFilter.read # Append the list element instance to its respective parent
# (all the parent classes up to the top level container must be instantiated!!)
table_name = Cisco_IOS_XR_ip_rib_ipv4_oper.Rib.Vrfs.Vrf.Afs.Af.Safs.Saf.IpRibRouteTableNames.IpRibRouteTableName() table_name.route_table_name = 'default'
table_name.routes.route.append(route)
# Read the list
route_table = crud.read(provider, table_names)
ā03-12-2021 11:11 AM
Yes, you can get the entire content of the list in YDK-0.8.5. The examples for such CRUD Service operations are present in the online documentation. In short, you need instantiate one list element without configuring any key and set a read filter operation on it. Here is a peace from the documented example, where we try to get route table from deeply rooted YANG model Cisco_IOS_XR_ip_rib_ipv4_oper.yang:
# Create the list member instance Route() route = Cisco_IOS_XR_ip_rib_ipv4_oper.Rib.Vrfs.Vrf.Afs.Af.Safs.Saf.IpRibRouteTableNames.IpRibRouteTableName.Routes.Route()
# Set the yfilter attribute for the route instance route.yfilter = YFilter.read # Append the list element instance to its respective parent
# (all the parent classes up to the top level container must be instantiated!!)
table_name = Cisco_IOS_XR_ip_rib_ipv4_oper.Rib.Vrfs.Vrf.Afs.Af.Safs.Saf.IpRibRouteTableNames.IpRibRouteTableName() table_name.route_table_name = 'default'
table_name.routes.route.append(route)
# Read the list
route_table = crud.read(provider, table_names)
ā03-15-2021 02:14 AM
Thank you Yan!
Your help as always is appreciated.
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