It then puts all the interface into a Dictionary, each interface in a row, and does a search of the interface number, using the interface "name" of 1/1/1 (or any other interface number found in the query).
During testing on a Cat9300-48UXM with an NM-8X Network Module, I noticed that, searching for interface 1/1/1, there are actually four potential ports to choose from:
This is an issue, as in my case the TenGig1/1/1 interface is configured and is in use, so I should NOT be able to change interface GigabitEthernet1/1/1.
For the script logic, I suppose I can create a temporary IF statement to see if my dictionary has multiple Interface Types for a given interface name (that will be interesting itself), but it would be better if we could remove the unneeded, not-programmed Interfaces.
Is there another Netconf Filter I could leverage to get the information I'm looking for without the Interface redundancy?
I came across your post battling a similar issue. Dealing with the several interface type names is an extremely painful. For you particular issue, you could use a XPath filter to only get the interfaces you are interested in. For example, here's an xpath filter that only returns interface names that have a particular ACL configured: "/native/interface//name[../ip/access-group/in/acl[acl-name='DEFAULT-ACCESS']]"
For you problem, looks like you are looking for interfaces that do not have any configuration. You could create a filter that matches on any interface that is missing some or all configuration. Not exactly sure what the xpath query would look like.
Thanks for the reply. Part of being a Beginner is figuring out which trail to follow, especially when the existing trails are rough-cut with some leading to nowhere. I'm writing all sorts of scripts to do various things in my lab for testing, failing more than succeeding, but that's part of the fun!
For this scenario, I figured out that a combination of Models did the trick. The initial Read query to the device uses the "Cisco-IOS-XE-interfaces-oper" Model, which exposes the "oper-status" data to the script. I then filter out any non-viable Interface via:
if interface["oper-status"] != "if-oper-state-not-present":
This handles the scenario where a single port can be either Gig, TenGig, FortyGig, etc., as they only "become" that interface once a suitable SFP has been installed, but are otherwise "not-present".
To write updated data back to the switch, I use the "Cisco-IOS-XE-native" Model, which makes for more fun, as THAT Model demands to know the InterfaceType (Gig, TenGig, etc.), so I broke the Interface Type and Interface Number apart, put them into a Dictionary, and parsed/pulled as I needed.