cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

DNAC Template - CLI + Velocity

348
Views
0
Helpful
0
Comments

Template Introduction

The template editor is a standalone application that can be used to Build your Day-0 (PnP) or Day-N configurations.

•Day-0 (PnP)  : Is your PnP/Onboarding Template . This is a one-time Template that used while you onboard your network devices, this  template are Pushed to the Network devices as once (Bulk Template) .Usually we recommend to Push all your Major Connectivity config using This Template.

Note:If DNAC Management interface need to be changed from the PnP discovery interface to any other interface, make sure to use : “ip http client source-interface”. **Managed I interface need to be reachable via DNAC.

•Day-N: Is your Provisioning Template. This is the template that you can use to change any Configuration after your device is Managed by DNAC, this template are Push to the Network device in a line by line cli basis , make sure to not touch any basic connectivity or you will lose connectivity to the device.

Template Tool

•Click ‘+’ and  select Create Template

•Enter Template variables

  • Regular Template or Composite SequencePicture2.png
  • Name
  • Project Name
  • Description
  • Tags
  • Device Type (List)
  • Software Type
  • Software Version

•After Add a New Template is completed the Template Editor is openedPicture1.png

•The following basic Actions are available

  • Check for errors
  • Show history
  • Save
  • Commit

 

 

 

•The following basic Edit options are available

  • UndoPicture3.png
  • Redo
  • Copy
  • Paste
  • Find and Replace

Template Type

Template Type Comparison

Description

Regular Template

Composit Template

Number of Template

One Template

One or more regualr template

Apply To

Day0/DayN

DayN only

Easy to Manage/Troublshoot

Ok

Easier

Configuration Mode

All commands are entered in conf t mode. As commands are delivered a prompt is expected after each command. This complicates thing, here you can find use cases and solutions to address the need :

  1. Enter multiple lines without a prompt being returned after each line of configuration.  A banner would be an example of this.
    • It can be address using ## ! Multiple Commands Tag.
  2. Questions Prompt,  when you configure things which also doesn’t show the regular prompt. Generating an SSH key pair could be an example of this.
    • It can be address using ## ! Interactive Tag.
  3. Exec Mode Config, Sometimes you might need to enter stuff in exec mode
    • It can be address using #MODE_ENABLE Tag.

Note: All the commands executed via templates are always in conf t mode. So there is no need to specify the enable / conf t command explicitly in the template.

Adding Enable Mode Commands

Use this syntax to add enable mode commands to your CLI templates:

Picture6.png

 

 

Note: You need to specify #MODE_ENABLE if you want to execute any command outside the conf t.

Adding interactive Mode Commands

An interactive command contains the expected cli query and input that must be entered following the execution of a command.

To enter interactive command mode

      To enter an interactive command in the CLI Content area, use the following syntax:

       CLI Command<IQ>interactive question 1<R>command response 1 <IQ>interactive question 2<R>command  response 2

Where Interactive Question <IQ> and Response <R> tags are case-sensitive and must be entered in uppercase. 

For example:

Picture7.png

 

Note: You need to specify #MODE_ENABLE if you want to execute any command outside the conf t.

Combining Interactive Enable Mode Commands

Use this syntax to combine interactive Enable Mode commands:

  #MODE_ENABLE

  #INTERACTIVE

  commands<IQ>interactive question<R>response

  #ENDS_INTERACTIVE

  #MODE_END_ENABLE

For example:

Picture8.png

 

Note:  All the templates in the PI system will work here also, except the multi line tag<MLTD>.

Input Form Editor variables

Picture10.png•Variable Form option  can be either Text Field, Single select or multiple select .

•Variables Value can Be validated against different format ( String ,IP ,integer, etc..)

•Variable Value can Bind to source – I don’t recommend as its not reliable •sometimes its not working.unless you are sure and you test this option against your •Hardware running release don't go with this approach.

•Commit will prompt you to save , no need to save and Commit

Template Sample

Templates are a composite of Cisco CLI, and velocity

•Configure hostname

hostname $name

•Configure Macro

Picture12.jpg

 

 

Picture13.jpg

 


 

 

 

 

 

 

 

Split the comma delimited Text string into a string list..

Example : Picture14.png

  $data_vlanids = 200,300

  $vlans list = [200,300]

 

 

Replace function is very useful to trim any spaces in an input variableScreen Shot 2020-05-21 at 4.09.09 PM.png

Template Form Export/ Import

On multiple device on-boarding scenario, rather than selecting each device and fill their variables , you can export Form variable into *.csv file,Fill it in excel and import it back.

•On testing/troubleshooting  scenario , it will reduce your time by importing the excel rather than fill in the variable every trial.

Note: Excel sheet Column will be head of device serial number.

Screen Shot 2020-05-21 at 2.42.58 PM.png
 
 
 
 
 
Screen Shot 2020-05-21 at 2.43.53 PM.png

 

 

 

 

 

 

 

 

Lesson Learned. Tips && Tricks

Picture16.png

 

Using Velocity to Create Plug and Play Reference

https://blogs.cisco.com/developer/using-velocity-to-create-plug-and-play-templates-in-dna-center-part-4

https://velocity.apache.org/engine/1.4/user-guide.html