11-04-2024 07:42 AM
I'm trying to write a template to push AutoConf templates to ports and I'm having issues when I bind the input to the source.
I have bound the $interface_range to the source, inventory, interface, portName
when I run the simulation it never replaces the characters and always just puts in the $interface_range_cleaned in the output. The exception is if I manually set the input with something like "#set( $interface_range = '[TenGigabitEthernet1/0/1, TenGigabitEthernet1/0/2, TenGigabitEthernet1/0/3, TenGigabitEthernet1/0/4, TenGigabitEthernet1/0/5, TenGigabitEthernet1/0/6, TenGigabitEthernet1/0/7, TenGigabitEthernet1/0/8, TenGigabitEthernet1/0/9, TenGigabitEthernet1/0/10]' )". This works as expected.
I have inserted a Debug command to confirm the input is there and it is.
I have tried using the replaceAll method to utilize regex and get the same results. Wondering is anyone else has run into this and figured out a fix?
I have attached a screenshot of the variable input as well in case that helps.
!Debug: Interface Range is $interface_range
#set ( $interface_range_cleaned = $interface_range.replace("[", "").replace("]", ""))
interface range $interface_range_cleaned
source template DEFAULT_USER_ACCESS_TEMPLATE
Solved! Go to Solution.
11-05-2024 02:03 PM
I'm posting this in case someone else finds it helpful. I wasn't able to get my original solution to work, which I think would have been a bit more optimized. I did get this to work however.
!Debug: Interface Range is $interface_range
#foreach ($interface in $interface_range)
interface $interface
source template DEFAULT_USER_ACCESS_TEMPLATE
#end
11-05-2024 02:03 PM
I'm posting this in case someone else finds it helpful. I wasn't able to get my original solution to work, which I think would have been a bit more optimized. I did get this to work however.
!Debug: Interface Range is $interface_range
#foreach ($interface in $interface_range)
interface $interface
source template DEFAULT_USER_ACCESS_TEMPLATE
#end
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