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

Netconf on Cisco switches - Native vs IEFT - getting interface name

ChrisMott30064
Beginner
Beginner

I'm new to Netconf/YANG and am having difficulty with a simple script. This script will eventually allow the user to edit a User Interface to change the Description, the Access VLAN, and Port-security settings.

Using the IEFT model, I can get the interface name as "GigabitEthernet" pretty simply but using "xmltodict" and the below filter:

netconf_filter = """
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
    <interface>
      <name/>
      <description/>
    </interface>
  </interfaces>
</filter>
"""
 
However, I need to use the Native model because I need to get the "access vlan" information and potentially change it. I've not gotten to the port-security yet, but that's also available only in the Native model.
 
Within the Native model, the interface name "seems" to be a key, not a value, but for the life of me I cannot seem to pull it out. For now, the script that leverages the Native model uses this filter:
desc_config = """
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <interface>
      <GigabitEthernet>
        <name>{name}</name>
        <description>{desc}</description>
      </GigabitEthernet>
    </interface>
  </native>
</config>
 """
 
As with many Cisco shops, we have switches with various interface speeds on the same platform - Gigabit, Twogigabit, TenGigabit, etc. The script needs to gather this information to ensure when writing to a specific interface, it uses the correct interface name.
 
I've been searching for days and have examined probably 30-40 different blogs, but it's still not registering to me. I feel like I'm dancing around the answer but just haven't stepped the right way.
1 Accepted Solution

Accepted Solutions

Thank you for your reply. I did check that link, and it looks interesting, but it did not necessarily address my issue.

I did eventually figure it out with a combination of Operational and Configuration Models, using the Operational Model to query which ports are "operationally up", then using the Config Model to affect changes to those ports.

Moving forward with any Netconf scripts used for Cisco device Interfaces, it looks like part of the script will be to gather and parse the Interface information, as the Cisco devices only report "GigabitEthernet1/0/1", not "GigabitEthernet" + "1/0/1" as separate data points.

That being said, once that function is written, it's either just a cut-and-paste or a refactor into a Module.

View solution in original post

2 Replies 2

Geevarghese Cheria
Cisco Employee
Cisco Employee

Did you had chance to check this python notebook which could be helpfull in answering your question.

https://github.com/CiscoDevNet/xr-netconf-lab/blob/master/workshop.ipynb

 

Thank you for your reply. I did check that link, and it looks interesting, but it did not necessarily address my issue.

I did eventually figure it out with a combination of Operational and Configuration Models, using the Operational Model to query which ports are "operationally up", then using the Config Model to affect changes to those ports.

Moving forward with any Netconf scripts used for Cisco device Interfaces, it looks like part of the script will be to gather and parse the Interface information, as the Cisco devices only report "GigabitEthernet1/0/1", not "GigabitEthernet" + "1/0/1" as separate data points.

That being said, once that function is written, it's either just a cut-and-paste or a refactor into a Module.

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:

Recognize Your Peers