cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
334
Views
0
Helpful
4
Replies

Issue while Provisioning Templates in DNAC

salviprasad13
Level 1
Level 1

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

4 Replies 4

AshSe
VIP
VIP

Hi @salviprasad13 

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

  • If you're using a GUI-based provisioning system, check the variable configuration section and confirm that the default value for Do_You_Want_To_Configure_Printer_Port is set to "Yes".

2. Modify the Template to Handle Missing Values

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)
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

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

Torbjørn
VIP
VIP

That's odd. it should work the same during provisioning as in the simulation. Which Cat-C version are you running?

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

Version 2.3.5.5-70026-HF60