cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1772
Views
6
Helpful
4
Replies

Netconf and Yang models and Python

Oli4cat
Level 1
Level 1

Hey i'm trying to learn netconf as a network automation student and I'm having a real hard time getting to understand the connection between all parts. I know what yang models, Python and netconf is. My lab setup has the devasc VM and a Devnet router Csr1kv.

Question number 1: Where can I find the correct yang models I need to configure the device? For example to configure ACL's? (I had this question on an exam but didn't pass the examen.)

Question number 2: How do I know the correct version for the devnet router operating system? If I look on the github repository there are a lot of 16.0.x or 17.0.x versions.

The models are like a template if i'm correct that you just have to adjust to your own environment and then work with the ncclient module in Python. 

1 Accepted Solution

Accepted Solutions

No problem. If you can't find a specific YANG model repository for your exact software version (16.09.05), and you have to choose between using older or newer YANG models, here are some considerations:
Use the Closest Version: If you can find a repository for a version close to 16.09.05 (for example, a repository for version 16.09), that would be a good starting point. The closer the version, the more likely the YANG models will match your software's behavior.

Newer Models: In most cases, using slightly newer YANG models might still work, as newer models often include improvements, bug fixes, and new features. However, there's a chance that some features or syntax might change between versions, so it's crucial to test thoroughly.

Cross-Check with Documentation: Refer to the official Cisco documentation for the YANG models that correspond to your software version. Cisco's documentation should provide information about the YANG models associated with specific IOS XE versions.

Hope this helps!

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

View solution in original post

4 Replies 4

M02@rt37
VIP
VIP

Hello @Oli4cat,

To find the correct YANG models for your specific device and software version, you can usually look directly at the device's documentation or the vendor's website. Cisco, for example, provides comprehensive documentation for their devices, including details on supported YANG models for various features.

https://developer.cisco.com/learning/

To determine the correct software version for the CSR1000v (Devnet router), you can refer to the Cisco Software Download page: https://software.cisco.com/download/home. Search for the CSR1000v, and you'll find various software versions available for download. Choose the version that best suits your needs. It's often a good idea to use the latest stable release, but be mindful of compatibility with your lab environment.

The models indeed act as templates that define the structure of the data you need to send in your NETCONF requests to configure the device. You'll use the ncclient Python module (or other libraries) to establish a NETCONF session with the device, send your requests using the YANG models, and receive responses back from the device.

As you work with NETCONF and ncclient, you'll get more familiar with the process, and it will become more intuitive. Explore the documentation, examples, and tutorials available on the Cisco DevNet website and other learning platforms to enhance your understanding of NETCONF and YANG models.

 

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.

NETCONF operations in a client/server model with the server being the network device and the client being a station the network administrator controls. NETCONF doesn’t itself define the format of the data, it provides a means for communicating programmatically with network devices based on a set of defined operations. These operations allow you to get/edit/delete the configuration or portions of it, save the configuration, and get state information. NETCONF message use XML-formatted messages in RPC’s to communicate with network devices, but don’t be too discouraged by this as Python’s ncclient makes this easy to work with.

Regarding YANG models, you're correct. YANG models serve as templates that define the structure of configuration and operational data for network devices. You can adapt these models to your environment and use the ncclient Python library to communicate with NETCONF-enabled devices, sending and receiving structured data in XML format.

You can identify which YANG modules are supported with the following code. To see which modules the network device has available we can use the device.server_capabilities iterator. This prints a very long list of capabilities, but these are the various YANG modules and namespaces available.

FC5D9A0B-0AEA-44FA-89D3-C7A5A295E150.jpeg

 

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Oli4cat
Level 1
Level 1

Thank you for explaining so clearly, I think I understand that part but now I have a DevNet router with a Cisco IOS XE, software version 16.09.05 (show version command). If I search for the yang data models in Github Github repository I can't find this specific version. Do I need to use the 1693 repo or 1691 or search somewhere else for the yang models? 

No problem. If you can't find a specific YANG model repository for your exact software version (16.09.05), and you have to choose between using older or newer YANG models, here are some considerations:
Use the Closest Version: If you can find a repository for a version close to 16.09.05 (for example, a repository for version 16.09), that would be a good starting point. The closer the version, the more likely the YANG models will match your software's behavior.

Newer Models: In most cases, using slightly newer YANG models might still work, as newer models often include improvements, bug fixes, and new features. However, there's a chance that some features or syntax might change between versions, so it's crucial to test thoroughly.

Cross-Check with Documentation: Refer to the official Cisco documentation for the YANG models that correspond to your software version. Cisco's documentation should provide information about the YANG models associated with specific IOS XE versions.

Hope this helps!

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io