diff options
Diffstat (limited to 'examples/historical/dlink-ng/make-dlink-config.pl')
-rwxr-xr-x | examples/historical/dlink-ng/make-dlink-config.pl | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/examples/historical/dlink-ng/make-dlink-config.pl b/examples/historical/dlink-ng/make-dlink-config.pl new file mode 100755 index 0000000..7a20820 --- /dev/null +++ b/examples/historical/dlink-ng/make-dlink-config.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl -I /root/tgmanage/ +use strict; +use warnings; +use lib '..'; +BEGIN { + require "include/config.pm"; + eval { + require "include/config.local.pm"; + }; +} + +unless (@ARGV > 0) { + print "No arguments. Need switches.txt and patchlist.txt.\n"; + exit 1; +} + +my $s = open(SWITCHES, "$ARGV[0]") or die ("Cannot open switches.txt"); +my $p = open(PATCH, "$ARGV[1]") or die ("Cannot open patchlist.txt"); + +my $portchannel_start = 10; +my %portchannels; +my $letter = "a"; + +my %switches; +while(<SWITCHES>) { + chomp; + my ($network, $netmask, $switchname, $mngmt_ip) = split; # $mngmt_ip is unused + $switches{$switchname} = { + network => $network, + netmask => $netmask, + }; +} +while (<PATCH>) { + chomp; + my ($switchname, $coregw, @ports) = split; + my $network = $switches{$switchname}{network}; + my $netmask = $switches{$switchname}{netmask}; + my ($o1, $o2, $o3, $o4) = split(/\./, $network); + + # portchannel per distro + if($coregw =~ m/distro0/){ + # TG14-fix for distro0 + $portchannels{$coregw} = 15 unless ($portchannels{$coregw} && defined($portchannels{$coregw})); + } else { + $portchannels{$coregw} = $portchannel_start unless ($portchannels{$coregw} && defined($portchannels{$coregw})); + } + + if ($o4 eq "0") { + $letter = "a"; + } elsif ($o4 eq "64") { + $letter = "b"; + } elsif ($o4 eq "128") { + $letter = "c"; + } elsif ($o4 eq "192") { + $letter = "d"; + } + + my $v6addr = $nms::config::base_ipv6net . $o3 . $letter ."::1/64"; + + $o4 += 1; + my $gateway_addr = "$o1.$o2.$o3.$o4"; + $o4 += 1; + my $switch_addr = "$o1.$o2.$o3.$o4"; + + print "$switchname $coregw $portchannels{$coregw} $network/$netmask $switch_addr $gateway_addr $v6addr " . join(' ', @ports) . "\n"; + + # increase portchannel + $portchannels{$coregw}++; + + die("NO MORE ETHERCHANNELS!") if($portchannels{$coregw} > 64); # IOS-XE 4500 only supports 64 portchannels +} |