From e6801503956f868c677dff3ef58f40a18e3a7188 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 14 Sep 2012 17:31:00 +0000 Subject: [PATCH] add getTablesAllRowAttribs git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@13806 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 03c99ec74..743c17a5e 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -58,6 +58,7 @@ sub handled_commands getNodesAttribs => "tabutils", getTablesAllNodeAttribs => "tabutils", getTablesNodesAttribs => "tabutils", + getTablesAllRowAttribs => "tabutils", setNodesAttribs => "tabutils", delEntries => "tabutils", getAttribs => "tabutils", @@ -165,6 +166,10 @@ sub process_request { return getTablesNodesAttribs($request,$callback); } + elsif ($command eq "getTablesAllRowAttribs") + { + return getTablesAllRowAttribs($request,$callback); + } elsif ($command eq "setNodesAttribs") { return setNodesAttribs($request,$callback); @@ -2568,6 +2573,100 @@ sub getTablesNodesAttribs $cb->(\%rsp); return; } +# getTablesALLRowAttribs +# Read all the rows from the input non-Node key'd +# tables and get the input attributes +# or get ALL attributes, if the word ALL is used. +# +#PCM +#getTablesALLRowAttribs +# +#osimage +#imagename +#synclists +#
+# +#linuximage +#ALL +#
+# . +# . +# . +#
+# +# +# +#osimage +# +#value1 +# +# +#. +#. +# +#
+# +#linuximage +# +#value +# +#. +#. +# +# +#. +#. +# +#
+#
+#. +#. +# +sub getTablesAllRowAttribs +{ + 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; + # 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 attributes in this table + my @recs = $tab->getAllAttribs(@attrs); + my %tblrecs; + foreach my $rec (@recs) { + my %datseg=(); + foreach my $key (keys %$rec) { + $datseg{$key} = $rec->{$key}; + } + push @{$tblrecs{table}->[0]->{row}}, \%datseg; + } + push @{$rsp{"table"}}, @{$tblrecs{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