cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
485
Views
5
Helpful
2
Replies

Getting everything in a list object without creating a filter

MahdiR
Level 1
Level 1

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"?

 

1 Accepted Solution

Accepted Solutions

yangorelik
Spotlight
Spotlight

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)

 

Yan Gorelik
YDK Solutions

View solution in original post

2 Replies 2

yangorelik
Spotlight
Spotlight

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)

 

Yan Gorelik
YDK Solutions

Thank you Yan!

Your help as always is appreciated.

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 community: