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

Choose one of the topics below for Cisco DNA Center Resources to help you on your journey with Cisco DNA Center

This community is for technical, feature, configuration and deployment questions.
For production deployment issues, please contact the TAC!
We will not comment or assist with your TAC case in these forums.

161
Views
0
Helpful
3
Replies
Highlighted

Template Loop With Range Not Working

In advance of deploying DNAC I'm trying to figure out VTL, but can't get loops to work when using variables. This is on one of the reserved instances of DNAC on Devnet. I got the idea from this post by Adam Radford

Even when I try exactly what he does in the blog post, the simulation has zero output

 

#set ($stack_member_count = $stack_count)

#foreach($switch in [1..${stack_member_count}])
interface Ten${switch}/0/1
#uplink_interface
#end

 

What I'm trying to get working is this

 

#macro (access_interface)
switchport host
switchport access vlan $access_vlan
switchport voice vlan $voice_vlan
#end

$first_access_port
$last_access_port
$access_vlan
$voice_vlan

#foreach($port in [${first_access_port}..${last_access_port}])
int gig1/0/$port
#access_interface
#end

Everyone's tags (1)
3 REPLIES 3
Cisco Employee

Re: Template Loop With Range Not Working

There's an important line in that post, "It is important to define the data type of $stack_count as an integer."  When I tested with it as a string (default) it also gave me no output (using Adam's example).  When I changed to int, I got ouptut

Re: Template Loop With Range Not Working

Thanks for the reply, but the variable is defined as an integer. It's possible the problem is with the sandbox, and not with the syntax. 

 

Outside the sandbox is there a way for me to check my syntax? I can't seem to find a VTL tester online, and I don't know Java. 

Cisco Employee

Re: Template Loop With Range Not Working

Ya, that could be it. I copied and pasted the desired template that you specified, and didn't have any issues.  But I'm testing on 1.3 and I think the devnet sandboxes are 1.2.10.   I don't have a 1.2.10 to play with at the moment. Here is part of the output I got from your template from the simulator.

 

int gig1/0/1
switchport host
switchport access vlan 4
switchport voice vlan 2

int gig1/0/2
switchport host
switchport access vlan 4
switchport voice vlan 2

....

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards