aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Lyngstol <kristian@bohemians.org>2016-02-29 20:40:16 +0100
committerKristian Lyngstol <kristian@bohemians.org>2016-02-29 20:40:16 +0100
commit42b0129ec342b8044d0d84c94151da160c288602 (patch)
tree89ca8489724bd3b503838adeb97e2fcafa83cdaf
parentc3ba8fcf1c8e35a4417348109af925bc2a769991 (diff)
nms: Update add_switches.txt.pl to output an arrary
-rw-r--r--include/nms/util.pm16
-rw-r--r--nms/nms-dump.sql.gzbin4195 -> 4167 bytes
-rwxr-xr-xtools/add_switches.txt.pl4
3 files changed, 10 insertions, 10 deletions
diff --git a/include/nms/util.pm b/include/nms/util.pm
index e1ebaa3..c97572b 100644
--- a/include/nms/util.pm
+++ b/include/nms/util.pm
@@ -12,7 +12,7 @@ sub parse_switch {
my ($switch, $subnet4, $subnet6, $mgtmt4, $mgtmt6, $lolid, $distro) = split(/ /);
my %foo = guess_placement($switch);
my %ret = (
- 'name' => "$switch",
+ 'sysname' => "$switch",
'subnet4' => "$subnet4",
'subnet6' => "$subnet6",
'mgtmt4' => "$mgtmt4",
@@ -20,7 +20,7 @@ sub parse_switch {
'lolid' => "$lolid",
'distro' => "$distro"
);
- %{$ret{'placement_guess'}} = guess_placement($switch);
+ %{$ret{'placement'}} = guess_placement($switch);
return %ret;
}
@@ -28,26 +28,26 @@ sub parse_switch {
# (e.g.: parse_switches_txt(*STDIN) or parse_switches_txt(whatever).
sub parse_switches_txt {
my $fh = $_[0];
- my %switches = ();
+ my @switches;
while(<$fh>) {
chomp;
my %switch = parse_switch($_);
- %{$switches{$switch{'name'}}} = %switch;
+ push @switches, {%switch};
}
- return %switches;
+ return @switches;
}
# Parses switches in switches.txt format given as $_[0].
# E.g: parse_switches("e1-3 88.92.0.0/26 2a06:5840:0a::/64 88.92.54.2/26 2a06:5840:54a::2/64 1013 distro0")
sub parse_switches {
- my %switches = ();
+ my @switches;
my $txt = $_[0];
foreach (split("\n",$txt)) {
chomp;
my %switch = parse_switch($_);
- %{$switches{$switch{'name'}}} = %switch;
+ push @switches, {%switch};
}
- return %switches;
+ return @switches;
}
# Guesses placement from name to get a starting point
diff --git a/nms/nms-dump.sql.gz b/nms/nms-dump.sql.gz
index 5fd8f5b..ea5c09d 100644
--- a/nms/nms-dump.sql.gz
+++ b/nms/nms-dump.sql.gz
Binary files differ
diff --git a/tools/add_switches.txt.pl b/tools/add_switches.txt.pl
index 5a6b83c..635e356 100755
--- a/tools/add_switches.txt.pl
+++ b/tools/add_switches.txt.pl
@@ -12,6 +12,6 @@ use lib '../include';
use JSON;
use nms::util;
-my %switches = parse_switches_txt(*STDIN);
+my @switches = parse_switches_txt(*STDIN);
-print JSON::XS::encode_json(\%switches);
+print JSON::XS::encode_json(\@switches);