cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1300
Views
2
Helpful
4
Replies

Trying to understand CLI Templates

f2d5
Level 1
Level 1

I'm trying to understand CLI Templates in SD-Access. We have a handful of POE devices across the enterprise that require unique configurations. Trying to figure out the best templatized way of doing this. Some camera interfaces need "power inline port 2-event" or "power inline four-pair forced". I wrote a template to try and achieve this.

Two issues I have are:

1. I want to be able to mix and match configurations. Gi1/0/1 may need "power inline port 2-event" and Gi2/0/2 may need "power inline four-pair forced". I could solve this by having one template for 2-event, and one template for four-pair...but was trying to figure out if I could do this all in one template. 

2. If I want to remove this configuration and I go in and uncheck an interface, it doesn't deprovision the configuration. I don't know how to achieve removing this except for writing another "no" template and checking that box or something...but that seems like a terribly convoluted way to do this. 

Surely someone else has done something similar? Attached are some screenshots of my current template. 

 

4 Replies 4

u need to implement more complicated logic in your case like having arrays of Intf:PoE-type pairs. & default array of Intfs (those w/o PoE to apply default setting in background).
i'd say this (among with many other things) is something we would expect from CatC UI in Port Assignment workflow implemented by its developers...

Torbjørn
VIP
VIP

Hi, 

I would create one template for 2-event and one for four-pair and do something like this:

{% for interface in __interface %}
interface {{ interface.portName }}
 {% if interface.portName in selected_interfaces %}
  power inline port 2-event
 {% else %}
! @start-ignore-compliance
  no power inline port 2-event
! @ENd-ignore-compliance
 {% endif%}
{% endfor %}

This way it will configure all selected interfaces with the required command and revert all others to default settings. Note the flags for ignoring compliance, as the no version of these commands will never be rendered in configuration.

Here's how I've configured the selected_interfaces variable:

Screenshot 2025-02-25 at 09.24.37.png

Happy to help! Please mark as helpful/solution if applicable.
Get in touch: https://torbjorn.dev

This is very helpful. My only "concern" is that I really don't like that at every provision, it pushes a "no" to all interfaces. Feels like there should be a better way. It just kinda makes what is "changing" in the preview a little messy. Ignore the VLAN SVI, I can filter those out. 

f2d5_0-1740493894628.png

 

Well, all non-POE capable interfaces have to be filtered out because you can't do a "no power inline xxxx" on a non power capable interface. 

I used this regex filter on the template variable "^(GigabitEthernet[1-9]\/0\/.*|TenGigabitEthernet([1-2]|[5-9])\/0\/.*)$" and it works for selecting the interfaces, but the "no" commands still go to every interface. Not sure how to filter that down...

f2d5_0-1740515164088.pngf2d5_1-1740515195607.png