From 2742a29bcfb609511db0199b33374099b9a96ebe Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Fri, 2 Sep 2016 12:08:38 +0000 Subject: [PATCH 1/6] [xCAT-client]xdshbak: make `-q` match manpage --- xCAT-client/bin/xdshbak | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xCAT-client/bin/xdshbak b/xCAT-client/bin/xdshbak index 66bc59ff3..a4d6769ed 100644 --- a/xCAT-client/bin/xdshbak +++ b/xCAT-client/bin/xdshbak @@ -110,8 +110,7 @@ while () # $num_lines++; if (!($quiet)) { - if ($::opt_x) { $num_lines % 100 == 0 && print STDOUT "."; } - else { $num_lines % 1000 == 0 && print STDOUT "."; } + $num_lines % 1000 == 0 && print STDOUT "."; } if (/: /) { @@ -170,7 +169,7 @@ while () # The hostnames are sorted alphabetically # -$num_lines > 999 && print STDOUT "\n"; +!($quiet) && $num_lines > 999 && print STDOUT "\n"; if ($compress) { if ($long_ln eq $prev_ln) @@ -204,7 +203,7 @@ sub d_syntax "-c : compresses the output by listing unique output only once.\n"; my $usage3 = "-h : help \n"; my $usage4 = -"-x : omit extra header output for each node. Can not be used with -c. \n"; + "-x : omit extra header output for each node. Can not be used with -c. \n"; my $usage5 = "-q : quiet mode.\n"; my $usage = $usage1 .= $usage2 .= $usage3 .= $usage4 .= $usage5; xCAT::MsgUtils->message("I", $usage); @@ -302,10 +301,10 @@ sub print_tree xCAT::MsgUtils->message("I", "HOSTS:"); print -"-------------------------------------------------------------------------\n"; + "-------------------------------------------------------------------------\n"; &display_wc; print -"-------------------------------------------------------------------------------\n"; + "-------------------------------------------------------------------------------\n"; print $str{$index}; } } From 7b6b421b17d30fd718e940755213917a5689a7e1 Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Fri, 2 Sep 2016 12:16:01 +0000 Subject: [PATCH 2/6] [xCAT-client]xdshbak: make `-x` match manpage --- xCAT-client/bin/xdshbak | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/xdshbak b/xCAT-client/bin/xdshbak index a4d6769ed..48b612527 100644 --- a/xCAT-client/bin/xdshbak +++ b/xCAT-client/bin/xdshbak @@ -236,7 +236,9 @@ sub print_list if (!$::opt_x) { ($num_hosts >= 1) && print "\n"; } $num_hosts++; - if ($::opt_x) { print "$hostname: $ls{$hostname}"; } + if ($::opt_x) { + map { print "$hostname: $_\n" } split(/\n/, $ls{$hostname}); + } else { From 7fcfc0700b4ee70a6e24a41e10884d88ee10381d Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Fri, 2 Sep 2016 12:19:41 +0000 Subject: [PATCH 3/6] [xCAT-client]xdshbak: make header match manpage --- xCAT-client/bin/xdshbak | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xCAT-client/bin/xdshbak b/xCAT-client/bin/xdshbak index 48b612527..c200a185c 100644 --- a/xCAT-client/bin/xdshbak +++ b/xCAT-client/bin/xdshbak @@ -243,7 +243,7 @@ sub print_list { #$hn_string = `$SPMSG DSH $MSGCAT INFO510 'HOST: %1\$s\n' $hostname`; - xCAT::MsgUtils->message("I", "HOST:$hostname\n"); + xCAT::MsgUtils->message("I", "HOST:$hostname"); printf '%.' . (6 + length($hostname)) . "s\n", '---------------------------------------------------------------'; @@ -300,10 +300,9 @@ sub print_tree @wc = sort(@wc); #system "$SPMSG DSH $MSGCAT INFO511 'HOSTS '"; - xCAT::MsgUtils->message("I", "HOSTS:"); - - print - "-------------------------------------------------------------------------\n"; + xCAT::MsgUtils->message("I", + "HOSTS -------------------------------------------------------------------------" + ); &display_wc; print "-------------------------------------------------------------------------------\n"; From ccd0ff64f5f779df5a33a6aa56b52b4005dbfb10 Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Mon, 10 Oct 2016 15:12:57 +0000 Subject: [PATCH 4/6] [xCAT-client]xdshbak: Use `version` sorting on hostnames --- xCAT-client/bin/xdshbak | 7 +++++-- xCAT-client/debian/control | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xCAT-client/bin/xdshbak b/xCAT-client/bin/xdshbak index c200a185c..7084614bb 100644 --- a/xCAT-client/bin/xdshbak +++ b/xCAT-client/bin/xdshbak @@ -10,6 +10,9 @@ use xCAT::MsgUtils; use xCAT::DSHCLI; use locale; use Getopt::Std; + +eval "use Sort::Versions qw/versioncmp/; 1;" or *versioncmp = sub ($$) { ($a,$b)= @_ ; return $a cmp $b }; + ##################################################################### # # # Module: xdshbak # @@ -231,7 +234,7 @@ sub print_list local (@lines, $numhosts, $hn_string, $l_string); - foreach $hostname (sort @hs) + foreach $hostname (sort { versioncmp($a, $b) } @hs) { if (!$::opt_x) { ($num_hosts >= 1) && print "\n"; } $num_hosts++; @@ -297,7 +300,7 @@ sub print_tree ($num_hosts >= 1) && print "\n"; $num_hosts++; @wc = split(/:/, $hdr{$index}); - @wc = sort(@wc); + @wc = sort { versioncmp($a, $b) } @wc; #system "$SPMSG DSH $MSGCAT INFO511 'HOSTS '"; xCAT::MsgUtils->message("I", diff --git a/xCAT-client/debian/control b/xCAT-client/debian/control index 321fc1b19..032f70438 100644 --- a/xCAT-client/debian/control +++ b/xCAT-client/debian/control @@ -8,5 +8,6 @@ Standards-Version: 3.7.2 Package: xcat-client Architecture: all Depends: ${perl:Depends}, nmap, perl-xcat +Recommends: libsort-versions-perl Description: Core executables and data of the xCAT management project xCAT-client provides the fundamental xCAT commands (chtab, chnode, rpower, etc) helpful in administrating systems at scale, with particular attention paid to large HPC clusters. From c6f7861fb1da01f77e1ba9c7cf35b45618ec9d95 Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Mon, 10 Oct 2016 15:21:26 +0000 Subject: [PATCH 5/6] [xCAT-client]xdshbak: Add bare output sub-option `-b` for `-x` --- xCAT-client/bin/xdshbak | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/xCAT-client/bin/xdshbak b/xCAT-client/bin/xdshbak index 7084614bb..fd343f30f 100644 --- a/xCAT-client/bin/xdshbak +++ b/xCAT-client/bin/xdshbak @@ -24,6 +24,7 @@ eval "use Sort::Versions qw/versioncmp/; 1;" or *versioncmp = sub ($$) { ($a,$b # output from multiple nodes preceded by the hostname # # # # Inputs: # +# -b : bare output, don't prepend hostname per line. only with -x # # -c : list distinct output only once # # -h : usage # # -x : omit extra header output for each node. # @@ -53,7 +54,7 @@ $::dsh_command = 'xdshbak'; # # Process the command line... # -if (!getopts('cxhq')) +if (!getopts('bcxhq')) { # Gather options; if errors &d_syntax; exit(-1); @@ -71,6 +72,11 @@ if ($::opt_c && $::opt_x) exit(-1); } # these 2 options are mutually exclusive +if ($::opt_b && !($::opt_x)) { + &d_syntax; + exit(-1); +} # -b only makes sense with -x + if ($::opt_c) { $compress++; @@ -201,14 +207,15 @@ else sub d_syntax { - my $usage1 = "Usage: xdshbak [-c | -x | -h | -q] \n"; - my $usage2 = - "-c : compresses the output by listing unique output only once.\n"; - my $usage3 = "-h : help \n"; - my $usage4 = - "-x : omit extra header output for each node. Can not be used with -c. \n"; - my $usage5 = "-q : quiet mode.\n"; - my $usage = $usage1 .= $usage2 .= $usage3 .= $usage4 .= $usage5; + # Duplicates POD - pod2usage ? + my @usage; + push @usage, "Usage: xdshbak [-c | -x [-b] | -h | -q]"; + push @usage, " -b : bare output, don't prepend hostname per line. only with -x"; + push @usage, " -c : compresses the output by listing unique output only once."; + push @usage, " -h : help"; + push @usage, " -x : omit extra header output for each node. Can not be used with -c."; + push @usage, " -q : quiet mode."; + my $usage = join "\n", @usage; xCAT::MsgUtils->message("I", $usage); } @@ -240,7 +247,13 @@ sub print_list $num_hosts++; if ($::opt_x) { - map { print "$hostname: $_\n" } split(/\n/, $ls{$hostname}); + if ($::opt_b) { + # Bare output + print $ls{$hostname}; + } else { + # No header. hostname prepended on every line + map { print "$hostname: $_\n" } split(/\n/, $ls{$hostname}); + } } else { From a91bf8e258f1f32b0aeb4245352c1603bb71f4d7 Mon Sep 17 00:00:00 2001 From: Samveen Gulati Date: Thu, 5 Nov 2015 11:36:05 +0000 Subject: [PATCH 6/6] [xCAT-client]xdshbak: Add `-b` option to manpage --- xCAT-client/pods/man1/xdshbak.1.pod | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xCAT-client/pods/man1/xdshbak.1.pod b/xCAT-client/pods/man1/xdshbak.1.pod index 61262572e..fed91b77d 100644 --- a/xCAT-client/pods/man1/xdshbak.1.pod +++ b/xCAT-client/pods/man1/xdshbak.1.pod @@ -4,7 +4,7 @@ B - Formats the output of the B command. =head1 B -B [B<-c> | B<-x> | B<-h> | B<-q>] +B [B<-c> | B<-x> [ B<-b> ] | B<-h> | B<-q>] =head1 DESCRIPTION @@ -62,6 +62,9 @@ the output by hostname for easier viewing: . . +If the B<-b> flag is specified in addition to B<-x>, the hostname at the beginning +of each line is stripped. + =head2 Standard Error When the B filter is used and standard error messages are generated, @@ -72,6 +75,11 @@ output messages. This is true with and without the B<-c> flag. =over 6 +=item B<-b> + +Strip the host prefix from the beginning of the lines. This only +works with the B<-x> option. + =item B<-c> If the output from multiple nodes is identical it will be collapsed