X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=config%2Fmake-port-config.pl;fp=config%2Fmake-port-config.pl;h=769c580118a9e28c5ca43fb23e852939faf96a5f;hb=07d92d8b9eeb73d1813e67a66b2bcb467a559407;hp=0000000000000000000000000000000000000000;hpb=05e1bb96cc098a2c3d28bda0e204c9c8e068c580;p=nms diff --git a/config/make-port-config.pl b/config/make-port-config.pl new file mode 100644 index 0000000..769c580 --- /dev/null +++ b/config/make-port-config.pl @@ -0,0 +1,65 @@ +#! /usr/bin/perl +open PATCHLIST, ") { + chomp; + my ($name, $distro, $port) = split / /; + + $name =~ /e(\d+)-(\d+)/; + my ($row, $switch) = ($1, $2); + + my $ip; + if ($switch == 1) { + $ip = "87.76." . ($row - 1) . "1"; + } elsif ($switch == 2) { + $ip = "87.76." . ($row - 1) . "65"; + } elsif ($switch == 3) { + $ip = "87.76." . ($row - 1) . "129"; + } elsif ($switch == 4) { + $ip = "87.76." . $row . "1"; + } elsif ($switch == 5) { + $ip = "87.76." . $row . "65"; + } elsif ($switch == 6) { + $ip = "87.76." . $row . "129"; + } + + my $vlan = "$row$switch"; + + $distros{$distro} .= <<"EOF"; +vlan $vlan + name $name +! +default interface vlan $vlan +interface $vlan + description $name + ip address $ip 255.255.255.192 + ip directed-broadcast 10 + ip helper-address 87.76.254.2 + no ip proxy-arp + no shutdown +! + +default interface $port +interface $port + description $name + switchport mode access + switchport access vlan $vlan + + spanning-tree portfast + spanning-tree bpduguard enable + + ip igmp snooping + storm-control broadcast level 2 + no shutdown + +EOF +} + +for my $distro (keys %distros) { + open DISTRO, ">$distro-config" + or die "$distro-config: $!"; + print DISTRO $distros{$distro}; + close DISTRO; +}