12-30-2024 11:19 AM - edited 12-30-2024 12:35 PM
Hi,
My current Cisco Lab environment details are as follows:
Cisco IOS XE Software, Version 17.12.04
Cisco IOS Software [Dublin], Catalyst L3 Switch Software (CAT9K_IOSXE)
My current Lab structure is as follows:
I use a linux system that runs Ansible in a virtual Env.
I have a YAML files called ntp.yml
Solved! Go to Solution.
12-31-2024 07:04 AM
Hey @caesarkrit yangtoxml can convert your YANG models to XML templates, this is part of pyang toolkit and can help in generate initial XML structure.
Agree it’s a common issue to find balance between machine readability and human readability.
12-31-2024 01:21 AM
@caesarkrit imo wrapping the cli commands within NETCONF is not recommended, this goes against the intended design and benefits of NETCONF. I would look more at Jinja2 Templates for XML Generation and create the reusable template blocks that you can import and include in other templates.
This or instead of writing large XML blocks, consider using modular YANG models.
Hope this helps.
12-31-2024 06:12 AM
Hi,
I agree that this isn't best practices or something recommended, so I'll provide some background on why I would want to do this.
What's happening:
1. I store desired configurations in YAML files, in this case the first image ntp.yml
2. Jinja2 templates convert YAML into XML structure, in this case the second image ntp.j2
3. XML is sent via NETCONF to configure device.
4. Device validates against its YANG models.
"YAML (human configs) -> Jinja2 Templates -> XML -> NETCONF -> Device".
My idea and goal is to move away from the complex jinja2 templates for XML. It would be great if there was a tool that converts switch configurations into XML or switch configuration into the jinja2 templates. The reason I am looking for this is to allow others to be able to modify the configuration they want (in YAML) and be able to adjust the jinja2 template if they need be.
12-31-2024 07:04 AM
Hey @caesarkrit yangtoxml can convert your YANG models to XML templates, this is part of pyang toolkit and can help in generate initial XML structure.
Agree it’s a common issue to find balance between machine readability and human readability.
12-31-2024 07:45 AM
I found the below, Thanks. I'll look into it and see how I can leverage this in my project to allow others to quickly create the XML files.
Much appreciated
https://github.com/vhosakot/yang_to_xml
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide