Config Templates Take 3 (22 of 30)

This is the 3rd part of a series of post’s on developing a Config Template tool, click this link to follow the whole series of post’s.

Sometimes the template system can only take you so far, and you have to get down to regular programming. The HTML::Template system will at least let you send the configs within the same tmpl file as a variable. In this example we let the user input ip networks in a form, and then split it up, however many times you put IPs in and put it into a wildcard networks.

1
2
3
4
5
6
7
8
9
10
11
my $EIGRP = "router eigrp 1\n";
my @splitiproute = split(/,/,$IPROUTE);
foreach my $route ( @splitiproute){
my @splitnet = split('/',$route);
my $network = $splitnet[0];
my $mask = $splitnet[1];
my $wildmask = &make_mask($mask);
$EIGRP .= "network $network $wildmask\n";
}

$switch->param('EIGRP' => $EIGRP );

Your input form:
take-3-1

Then you get your output as configured in the program, passed into HTML::Template:
take-3-2

You can see a demo here and see updates on my github.

 

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>