diff options
author | Joachim Tingvold <joachim@tingvold.com> | 2015-03-21 14:48:22 +0100 |
---|---|---|
committer | Joachim Tingvold <joachim@tingvold.com> | 2015-03-21 14:48:22 +0100 |
commit | 6875390524d606e23b23ab0a45239630ed49ba65 (patch) | |
tree | 6e71411f41e3a7db379f69c17486ded35a75d053 /examples/historical/dlink-ng/make-dlink-config.pl | |
parent | 630f90f91cb5ef32d432314c9934a8ec5c3c7b05 (diff) |
Re-add moved files.
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 +} |