diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 64ebc8f32..6685310cd 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -14,6 +14,7 @@ use Data::Dumper; use xCAT::NodeRange qw/noderange abbreviate_noderange/; use xCAT::Schema; use xCAT::Utils; +#use XML::Simple; use xCAT::TableUtils; use xCAT::MsgUtils; use xCAT::DBobjUtils; @@ -57,6 +58,7 @@ sub handled_commands tabgrep => "tabutils", getAllEntries => "tabutils", getNodesAttribs => "tabutils", + getTablesAllNodeAttribs => "tabutils", setNodesAttribs => "tabutils", delEntries => "tabutils", getAttribs => "tabutils", @@ -156,6 +158,10 @@ sub process_request { return getNodesAttribs($request,$callback); } + elsif ($command eq "getTablesAllNodeAttribs") + { + return getTablesAllNodeAttribs($request,$callback); + } elsif ($command eq "setNodesAttribs") { return setNodesAttribs($request,$callback); @@ -1289,7 +1295,10 @@ sub getTableColumn { # } - +# +# Process the nodech command, also used by the XML setNodesAttribs utility +# in tabutils +# sub nodech { my $nodes = shift; @@ -2311,7 +2320,7 @@ sub getAllEntries return; } # getNodesAttribs -# Read all the array of attributes for the noderange from the input table. +# Read the array of attributes for the noderange from the input table. # If the ALL is input then read all the attributes # #PCM @@ -2378,9 +2387,96 @@ sub getNodesAttribs $cb->(\%rsp); 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 +# setNodesAttribs - setNodesAttribs # Sets Nodes attributes for noderange for each of the tables supplied # Example of XML in for this routine # @@ -2432,6 +2528,7 @@ sub setNodesAttribs } } } + # nodech will open the table and do all the work if (@$node) { &nodech(\@$node,$newrequest->{arg},$cb,0); } else {