Counting entries in a list

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 01:46 PM
Hi,
I'm working on a service that provisions prefix lists for customer services. The prefix-lists are of variable sizes and due to that, I want to know the number of entries in my (yang-) list when running my template.
In my template, the last entry will be treated differently than the previous and I need a hint how to do this. (In IOS-XR the every prefix-set entry is ended with a comma, except for the last one).
TIA.
/Johnny
- Labels:
-
DevOps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 11:41 PM
I would like to take this opportunity to mention that you can troubleshoot this kind of thing by doing commit | debug xpath, which gives insight into what is happening.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 11:56 PM
Without testing it I would assume that the NED handles the comma part automatically? Sounds like something that the NED should be handling..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2018 12:05 AM
It throws a fault if the comma isn’t present.
Also, it doesn’t do very well if I do updates to the prefix-set. NSO attempts to negate outdated entries, while XR requires a complete re-configuration of the prefix-set. I had hoped that “tags=‘replace’” would’ve solved this, but no luck 😐

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 11:59 PM - edited 12-11-2018 11:07 AM
Thanks, the count() function gave me the value I needed.
I did not try the position() function, but used a traditional counter variable in the loop.
