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 ); |
Then you get your output as configured in the program, passed into HTML::Template:
You can see a demo here and see updates on my github.
0 Comments.