From 0456b6ef6c63822f30c4e09b2098bc36080116eb Mon Sep 17 00:00:00 2001 From: ligc Date: Tue, 21 Feb 2012 08:03:15 +0000 Subject: [PATCH] fix for bug 3422448: lsdef -t -h -i attrs_list support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11659 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/pods/man1/lsdef.1.pod | 7 +++++ xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 30 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/xCAT-client/pods/man1/lsdef.1.pod b/xCAT-client/pods/man1/lsdef.1.pod index bd4a1f0fe..43e557dbb 100644 --- a/xCAT-client/pods/man1/lsdef.1.pod +++ b/xCAT-client/pods/man1/lsdef.1.pod @@ -202,6 +202,13 @@ To list the nodes status and use xcoll to format the output. lsdef -t node -i status -c | xcoll +=item 16. + +To display the description for some specific attributes that could be used +when defining an xCAT node. + + lsdef -t node -h -i profile,pprofile + =back =head1 FILES diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 39829c352..51cba514d 100644 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -566,6 +566,12 @@ sub processArgs my $rsp; if ($t eq 'site') { + if ($::opt_i) + { + my $tmprsp; + $tmprsp->{data}->[0] = "It is not supported to list the description of some specific site attributes, displaying the description for all site attributes instead."; + xCAT::MsgUtils->message("W", $tmprsp, $::callback); + } my $schema = xCAT::Table->getTableSchema('site'); my $desc; @@ -581,7 +587,10 @@ sub processArgs # get the data type definition from Schema.pm my $datatype = $xCAT::Schema::defspec{$t}; - $rsp->{data}->[0] = "The valid attribute names for object type '$t' are:"; + if (!$::opt_i) + { + $rsp->{data}->[0] = "The valid attribute names for object type '$t' are:"; + } # get the objkey for this type object (ex. objkey = 'node') my $objkey = $datatype->{'objkey'}; @@ -591,10 +600,27 @@ sub processArgs my @alreadydone; # the same attr may appear more then once my @attrlist; my $outstr = ""; - + my @dispattrs = (); + my %dispattrhash = (); + if ($::opt_i) + { + @dispattrs = split(/,/, $::opt_i); + foreach my $dattr (@dispattrs) + { + $dispattrhash{$dattr} = 1; + } + } foreach my $this_attr (@{$datatype->{'attrs'}}) { my $attr = $this_attr->{attr_name}; + # Only display the specified attributes + if ($::opt_i) + { + if (!defined($dispattrhash{$attr}) || !$dispattrhash{$attr}) + { + next; + } + } my $desc = $this_attr->{description}; if (!defined($desc)) { # description key not there, so go to the corresponding