08-15-2019 09:03 AM - edited 08-15-2019 09:31 AM
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
08-15-2019 10:12 AM
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
08-15-2019 11:05 AM - edited 08-15-2019 11:12 AM
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.
08-15-2019 11:20 AM
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
....
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