From f81a83bef466babe7700dffed06f0f35cbb5d0ae Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 14 May 2012 19:28:17 +0000 Subject: [PATCH] add getAttribs XML support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12667 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 63 ++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 64f182926..efd4a7805 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", setNodesAttribs1 => "tabutils", delEntries => "tabutils", + getAttribs => "tabutils", gennr => "tabutils" }; } @@ -160,6 +161,10 @@ sub process_request { return delEntries($request,$callback); } + elsif ($command eq "getAttribs") + { + return getAttribs($request,$callback); + } else { print "$command not implemented yet\n"; @@ -2283,6 +2288,15 @@ sub getAllEntries } # getNodesAttribs # Read all the array of attributes for the noderange from the input table. +# +#PCM +#getNodesAttribs +#nodelist
+#blade01-blade02 +#groups +#status +#
+# # # # nodename @@ -2433,13 +2447,8 @@ sub delEntries { my $request = shift; my $cb = shift; - # my $node = $request->{node}; # added by Client.pm - # my $noderange = $request->{noderange}; my $command = $request->{command}->[0]; my %rsp; - # my $args = $request->{arg}; - # my $tables= $args->[0]->{table}; - # my $tables= $request->{table}->{name}; my $tables= $request->{table}; foreach my $table (@$tables) { my $tablename = $table->{name}->[0]; @@ -2460,3 +2469,47 @@ sub delEntries } return; } +# getAttribs +# Read all the array of attributes for the key from the input table. +# +#PCM +#getAttribs +#site
+# +# domain +# +#value +#comments +#
+# +# +# +#{domain value} +#This is a comment +# +sub getAttribs +{ + my $request = shift; + my $cb = shift; + my $command = $request->{command}->[0]; + my $tablename = $request->{table}->[0]; + my $attr = $request->{attrs}; + my @attrs= @$attr; + my $tab=xCAT::Table->new($tablename); + my %rsp; + my %keyhash; + foreach my $k (keys %{$request->{keys}->[0]}) { + $keyhash{$k} = $request->{keys}->[0]->{$k}->[0]; + } + my $recs = $tab->getAttribs(\%keyhash,\@attrs); + + if ($recs) { + my %attrhash=%$recs; + foreach my $k (keys %attrhash) { + + push @{$rsp{$k}}, $recs->{$k}; + } + } + $cb->(\%rsp); + return; +}