02-26-2025 06:53 PM
I have a simple template where I need to configure ports on switches(C9300)
When I try simulation I do get the default selected option in mandatory variable (in my code Do_You_Want_To_Configure_Printer_Port is mandatory variable)
But When I try to provision the device the mandatory variable is not selected by default I have manually select the default key/value every time I provision the device with template
Code is as below in velocity language:-
#macro(PRINTER)
description Printer
switchport access vlan 200
switchport mode access
exit
#end
##Printer Port Config
#if ($Do_You_Want_To_Configure_Printer_Port == "Yes")
#set($Enter_Printer_Port_Number = $Enter_Printer_Port_Number.replaceAll(" ", "")) ## Remove spaces
#set($portNumbers = $Enter_Printer_Port_Number.split(","))
#foreach($port in $portNumbers)
#if($port.contains("-")) ## Check if it's a range
interface range $port
#PRINTER()
#else
interface $port
#PRINTER()
#end
#end
#else
#end
02-26-2025 09:20 PM
The issue you're describing seems to be related to how the default value for the mandatory variable Do_You_Want_To_Configure_Printer_Port
is being handled during provisioning. When you simulate the template, the default value is selected, but during provisioning, it requires manual selection. This behavior is likely due to how the provisioning system or platform you're using handles default values for mandatory variables.
Below are my suggestions:
1. Check the default value configuration
Do_You_Want_To_Configure_Printer_Port
is set to "Yes"
.To ensure the template works even if the variable is not explicitly set during provisioning, you can add a fallback mechanism in your Velocity code. For example:
#set(\$Do_You_Want_To_Configure_Printer_Port = \$Do_You_Want_To_Configure_Printer_Port ?: "Yes")
Here’s an updated version of your template with a fallback mechanism for the Do_You_Want_To_Configure_Printer_Port
variable:
#set(\$Do_You_Want_To_Configure_Printer_Port = \$Do_You_Want_To_Configure_Printer_Port ?: "Yes") #macro(PRINTER) ## Printer Port Config #set(\$Enter_Printer_Port_Number = \$Enter_Printer_Port_Number.replaceAll(" ", "")) ## Remove spaces #foreach(\$port in \$portNumbers) |
03-11-2025 08:46 PM
Here, you are assigning a default value to the variable
My issue is not related to coding; it is associated with the GUI while provisioning the device in DNAC
02-27-2025 03:14 AM - edited 02-27-2025 03:16 AM
That's odd. it should work the same during provisioning as in the simulation. Which Cat-C version are you running?
03-11-2025 08:46 PM
Version 2.3.5.5-70026-HF60
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