cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1517
Views
0
Helpful
1
Replies

Template editor with jinja to interact with selected interfaces

iran
Level 1
Level 1

I have this simple script:

{% for interface in selected_interfaces %}
interface {{ interface.portName }}
description {{ interface.description }}
{% endfor %}

It allow me to select several interfaces and assign automatically the description, but with the above script I need to use same descpriton to all ports

iran_0-1687115953679.png

I would like to know if it is possible to do the following:
- interact with the template to assign different description based on the selected interfaces. I mean, I want to have different description to all ports.

The description should the assign via input, not via pre-defined values.

 




1 Reply 1

Preston Chilcote
Cisco Employee
Cisco Employee

I think you're asking to have dynamically generated variables, meaning you want potentially a different number of description variables based on how many interfaces you select.  That isn't possible today.  One solution is to abandon the interface dropdown and pass in a string variable instead of tuples that you can split in jinja. For example, you would pass in "Gig0/1: Description1,Gig0/2: Description2") and split with something like this (I haven't tested this)

{% set tuple = interface_variable | split(".") %}

 

It's worth keeping in mind that automation works better when you have consistent configs across your network, and this is an example of why.  DNA Assurance eliminates a lot (perhaps all) of the need to rely on interface descriptions for troubleshooting and deployments thanks to Device 360, Client 360, and Topology diagrams.  So perhaps this is a good opportunity to rethink why you need so many unique interface descriptions in your network device configs?