cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6349
Views
15
Helpful
10
Replies

Cisco DNA templates with multiline commands

Ben Demeyere
Level 1
Level 1

Hi,

 

I'd like to create configuration (day-n) templates with some multiline commands. The <MLTCMD> doesn't provide me the correct output for:

- interface macro's

- banners (containing some special characters ($,"(),#,-)

 

I tried #INTERACTIVE mode, but that didn't help either. Can anyone provide me a template snippet in order to get the above (multiline) commands to work?

10 Replies 10

Dan Rowe
Cisco Employee
Cisco Employee

Hey Ben,

 

Please make sure you follow rules listed below:

  *   <MLTCMD> and </MLTCMD> tags are case-sensitive and must be entered as uppercase.
  *   The multi-line commands must be inserted between the <MLTCMD> and </MLTCMD> tags.
  *   The tag cannot be started with a space.
  *   The <MLTCMD> and </MLTCMD> tags cannot be used in a single line.

 

Here is a template snippet which provides an example of multiline command being used for banner:

<MLTCMD>banner login ^
line 1
line 2
line 3
^C</MLTCMD>

 

Here is a snippet of how I have used macros to apply configuration to device interfaces:

#macro(interface_config)
switchport
switchport mode access
switchport access vlan 1050 #end interface ${interface} #interface_config

 

Best Regards,

Hi Dani,

I applied the <MTLCMD> with the banner as you mentioned above. However, it's skipping some special characters (#):

--------------------------------------------
########################################

This device is managed...

########################################

--------------------------------------------

Best regards

Ben

Hey Ben,

 

Velocity Template Language (VTL) does have some issues with special characters. If you plan to use special characters in your banner, it is recommended to configure the banner from DNAC Design -> Network Settings instead of through a configuration template.

 

 

Hi Dani

I like to add exec and login banners as well; which isn’t available in the network settings sections (only motd).

br

ChuckMcF
Level 1
Level 1

Can you provide an example of a command you are trying to use?

Thanks,

Chuck

Hi,

 

The problem I have is when I try to add a templete to configure a banner like this

 

<MLTCMD>banner login ^
line 1
line 2
line 3
^C</MLTCMD>

 I have DNA-C 1.3.3.6 and the switch is a 9300 with IOS-XE 16.12.3s.

 

Though the provision is successfully, the banner appears with a blank line between the lines I have defined.

 

Is there any issue with this config or a possible bug with the interpreter of DNA-C?

 

Thanks in advance and best regards

I have the same issue. When applying the multi line command from DNAC, it adds an extra line that is blank between lines 1,2, and 3. 

Ciro G Mele
Level 1
Level 1

Hi,

With what commands can I choose several interfaces in a switch to perform trunk, always using a DayN, does anyone have a link about it?

Thanks a lots !

Ciro Gustavo Mele.

Go here and read about building templates and also utilizing the system variables.  Please also build your templates in Jinja language. 

Enjoy!

https://github.com/kebaldwi/DNAC-TEMPLATES

Ciro, first, you can create a Multi-select bind-to-source variable with the list of interfaces available on the device (see attached image for example).  Then use a for loop to iterate through that list.

#foreach($i in $int)
interface $i.portName
!some commands

#end

Interface Multi-Select.png