From 2a0c0a3dbbdf7fa5040953c0b0d88ad6f62c011e Mon Sep 17 00:00:00 2001 From: Joachim Tingvold Date: Sun, 6 Apr 2014 03:11:04 +0200 Subject: Initial commit. Source; TG13-goodiebag. --- tools/make-accesspoints.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 tools/make-accesspoints.pl (limited to 'tools/make-accesspoints.pl') diff --git a/tools/make-accesspoints.pl b/tools/make-accesspoints.pl new file mode 100755 index 0000000..b84321a --- /dev/null +++ b/tools/make-accesspoints.pl @@ -0,0 +1,24 @@ +#! /usr/bin/perl +use strict; +use warnings; + +while (<>) { + my @arr = split " "; + my $ap = 'ap-'.$arr[0]; + my $core = $arr[1]; + # Trekk fra 1 + $core =~ s/^(distro)(\d+)$/$1.($2-1)/e; + + # Fjerde kabel er aksesspunkt + my $blade; + my $port; + if ($arr[5] =~ /^Gi(\d+)\/(\d+)$/) { + $blade = $1; + $port = $2; + } else { + die "Unknown port: ".$arr[5]; + } + printf "INSERT INTO switches(ip, sysname, switchtype) values(inet '127.0.0.1', '%s', 'ciscoap');\n", $ap; + printf "INSERT INTO uplinks SELECT (SELECT switch FROM switches WHERE sysname = '%s') AS switch, (SELECT switch FROM switches WHERE sysname = '%s') AS coreswitch, %d AS blade, %d AS port;\n", $ap, $core, $blade, $port; + printf "INSERT INTO ap_poll(switch) SELECT switch FROM switches WHERE sysname = '%s';\n", $ap; +} -- cgit v1.2.3