From 8f4cb070578a3c1ea42bb1bbe18909d5506514e0 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 12 Sep 2012 13:55:41 +0000 Subject: [PATCH] checkin getTablesAllNodeAttribs git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@13777 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 92 ++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 8a252583e..8eced0363 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -56,6 +56,7 @@ sub handled_commands tabgrep => "tabutils", getAllEntries => "tabutils", getNodesAttribs => "tabutils", + getTablesAllNodeAttribs => "tabutils", setNodesAttribs => "tabutils", delEntries => "tabutils", getAttribs => "tabutils", @@ -155,6 +156,10 @@ sub process_request { return getNodesAttribs($request,$callback); } + elsif ($command eq "getTablesAllNodeAttribs") + { + return getTablesAllNodeAttribs($request,$callback); + } elsif ($command eq "setNodesAttribs") { return setNodesAttribs($request,$callback); @@ -2376,6 +2381,93 @@ sub getNodesAttribs return; } +# getTablesAllNodeAttribs +# Read all all the nodes from the input tables and get the input attribute +# or get ALL attributes, if the word ALL is used. +# If the ALL is input then read all the attributes +# +#PCM +#getTablesAllNodeAttribs +# +#nodelist +#groups +#status +#
+# +#nodetype +#ALL +#
+# . +# . +# . +#
+# +# +# +#tablename1 +# +#n1 +#value1 +#value1 +#. +#valueN +# +#
+# . +# . +# . +#
+# +sub getTablesAllNodeAttribs +{ + my $request = shift; + my $cb = shift; + my $command = $request->{command}->[0]; + my %rsp; + + # process each table in the request + my $tables = $request->{table}; + foreach my $tabhash (@$tables) { + + my $tablename = $tabhash->{tablename}->[0]; + my $attr = $tabhash->{attr}; + my @attrs=@$attr; + my $tab=xCAT::Table->new($tablename); + my %noderecs; + my $recs; + # build the table name record + @{$noderecs{table}->[0]->{tablename}} = $tablename; + # if request for ALL attributes + if (grep (/ALL/,@attrs)) { # read the schema and build array of all attrs + @attrs=(); + my $schema = xCAT::Table->getTableSchema($tablename); + my $desc = $schema->{descriptions}; + foreach my $c (@{$schema->{cols}}) { + # my $space = (length($c)<7 ? "\t\t" : "\t"); + push @attrs, $c; + } + } + # read all the nodes and there attributes in this table + my @nodeentries = $tab->getAllNodeAttribs(\@attrs); + foreach my $node (@nodeentries){ + # build the node entrys + my %datseg=(); + $datseg{name} = $node->{node}; + foreach my $at (@attrs) { + # if the attribute has a value and is not the node attribute + if (($node->{$at}) && ($at ne "node")) { + $datseg{$at} = $node->{$at}; + } + } + push @{$noderecs{table}->[0]->{node}}, \%datseg; + } + push @{$rsp{"table"}}, @{$noderecs{table}}; + } # end of all table processing +# for checkin XML created +#my $xmlrec=XMLout(\%rsp,RootName=>'xcatresponse',NoAttr=>1,KeyAttr=>[]); + $cb->(\%rsp); + return; +} # # setNodesAttribs # Sets Nodes attributes for noderange for each of the tables supplied