From c9151502b986069aed6bead713d03ac83c628176 Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Wed, 26 Aug 2009 19:41:30 +0000 Subject: [PATCH] - improved gettab man page - added usage support to tabgrep - fixed 2 uninitialized var msgs in xcatd git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4045 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/pods/man1/gettab.1.pod | 35 +++++++++++++----------- xCAT-server/lib/xcat/plugins/tabutils.pm | 10 +++++++ xCAT-server/sbin/xcatd | 4 +-- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/xCAT-client/pods/man1/gettab.1.pod b/xCAT-client/pods/man1/gettab.1.pod index 88b4f6d8b..56bccae4c 100644 --- a/xCAT-client/pods/man1/gettab.1.pod +++ b/xCAT-client/pods/man1/gettab.1.pod @@ -1,6 +1,6 @@ =head1 NAME -B - search through tables using keys and return attributes. +B - select table rows, based on attribute criteria, and display specific attributes. =head1 SYNOPSIS @@ -10,8 +10,10 @@ B [B<-?> | B<-h> | B<--help>] =head1 DESCRIPTION -The gettab command uses the specified key values to search the specified tables. For each matched -row, the specified attributes are displayed. +The B command uses the specified key values to select a row in each of the tables requested. +For each selected row, the specified attributes are displayed. The B command can be used instead +of B for tables that are not keyed by nodename (e.g. the B table), or to select rows based +on an attribute value other than nodename. =head1 OPTIONS @@ -19,7 +21,8 @@ row, the specified attributes are displayed. =item B<-H|--with-fieldname> -Always display table.column description next to result +Always display table.attribute name next to result. By default, this is done only if more than +one table.attribute is requested. =item B<-?|-h|--help> @@ -47,23 +50,23 @@ An error has occurred. =item * -To display node names that have B set to B in the nodehm table: +To display setting for B (management node) in the site table: + +B I + +The output would be similar to: + + site.value: mgmtnode.cluster.com + +=item * + +To display the first node or group name that has B set to B in the nodehm table: B I The output would be similar to: - nodehm.node: blades - -=item * - -To display setting for B (management node) in the site table: - -B I - -The output would be similar to: - - site.value: mgmtnode.cluster.com + blades =back diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index d52e315f1..b0ed980ad 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -148,6 +148,7 @@ sub gettab }; # Process arguments + if (!defined($req->{arg})) { $gettab_usage->(1); return; } @ARGV = @{$req->{arg}}; if (!GetOptions('h|?|help' => \$HELP,'H|with-fieldname' => \$NOTERSE)) { $gettab_usage->(1); return; } @@ -841,6 +842,15 @@ sub tabgrep my @tablist; my $callback = shift; + if (!defined($node) || !scalar(@$node)) { + my %rsp; + push @{$rsp{data}}, "Usage: tabgrep nodename"; + push @{$rsp{data}}, " tabgrep [-?|-h|--help]"; + $rsp{errorcode} = 1; + $callback->(\%rsp); + return; + } + foreach (keys %{xCAT::Schema::tabspec}) { if (grep /^node$/, @{$xCAT::Schema::tabspec{$_}->{cols}}) diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index 153a0d3a7..1404f4d3f 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -1289,7 +1289,7 @@ sub service_connection { $req->{'_xcat_clientfqdn'} = [$peerfqdn]; $req->{'_xcat_clientport'}= [$peerport]; $$progname="xCATd SSL: ".$req->{command}->[0]; - if ($req->{noderange}) { + if ($req->{noderange} && defined($req->{noderange}->[0])) { $$progname .= " to ".$req->{noderange}->[0]; } $$progname .= " for ".($peername ? $peername ."@".$peerhost : $peerhost); @@ -1541,7 +1541,7 @@ sub validate { if ($rule->{rule}) { if ($rule->{rule} =~ /allow/i or $rule->{rule} =~ /accept/i) { my $logst = "xCAT: Allowing ".$request->{command}->[0]; - if ($request->{noderange}) { $logst .= " to ".$request->{noderange}->[0]; } + if ($request->{noderange} && defined($request->{noderange}->[0])) { $logst .= " to ".$request->{noderange}->[0]; } if ($peername) { $logst .= " for " . $peername }; if ($peerhost) { $logst .= " from " . $peerhost }; xCAT::MsgUtils->message("S",$logst);