From 4d0dba4358399a97798e472ac83871afb245950a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 13 Mar 2015 15:19:43 +0000 Subject: [PATCH] HostnameSortSwapWords: Make name order mangling configurable We still default to having the mangling enabled. Arguably this is wrong I'm am minimising the number of things that will be wrong for the existing Cambridge instance. Signed-off-by: Ian Jackson --- Osstest.pm | 2 ++ mg-hosts | 5 +++-- ms-planner | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Osstest.pm b/Osstest.pm index 9fbadbd..5854257 100644 --- a/Osstest.pm +++ b/Osstest.pm @@ -73,6 +73,8 @@ our %c = qw( Baud 115200 DebianNonfreeFirmware firmware-bnx2 + + HostnameSortSwapWords 1 ); $c{$_}='' foreach qw( diff --git a/mg-hosts b/mg-hosts index 497139a..a911099 100755 --- a/mg-hosts +++ b/mg-hosts @@ -439,9 +439,10 @@ END sub cmd_showflags () { die if @ARGV; + my $sortkey = !$c{HostnameSortSwapWords} ? "hostname" + : "split_part(hostname, '-', 2), hostname"; my $hostsq= $dbh_tests->prepare(<prepare(<{Events}{$reso} } ]; } - my $colheadsortkey= sub { ($_[0] =~ m/-/ ? "$' $`" : "").$_[0]; }; + my $colheadsortkey= + !$c{HostnameSortSwapWords} ? sub { $_[0]; } + : sub { ($_[0] =~ m/-/ ? "$' $`" : "").$_[0]; }; my @colheads = sort { $colheadsortkey->($a) cmp $colheadsortkey->($b) } keys %{ $plan->{Events} }; -- 2.39.5