From 5535a5de5f1c3e1f20eea612c6373c2461d46c68 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 16 May 2012 17:34:18 +0000 Subject: [PATCH] add setAttribs XML routine git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12744 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 76 +++++++++++++++++++----- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index b49a142f7..2edfbc2a3 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -59,6 +59,7 @@ sub handled_commands setNodesAttribs1 => "tabutils", delEntries => "tabutils", getAttribs => "tabutils", + setAttribs => "tabutils", gennr => "tabutils" }; } @@ -165,6 +166,10 @@ sub process_request { return getAttribs($request,$callback); } + elsif ($command eq "setAttribs") + { + return setAttribs($request,$callback); + } else { print "$command not implemented yet\n"; @@ -2231,14 +2236,21 @@ else { # # Read all the rows from the input table name and returns the response, so # that the XML will look like this +# +#PCM +#getAllEntries +#nodelist
+#
+ + # -# +# #value1 #. #. #. #valueN -# +# #. #. #. @@ -2366,17 +2378,17 @@ sub getNodesAttribs # # # nodelist -# +# # test # This is a another testx -# +# #
# # nodetype -# +# # Redhat2 # This is a another testy -# +# #
#
# @@ -2399,12 +2411,12 @@ sub setNodesAttribs1 my $tablename = $table->{name}->[0]; my $tab=xCAT::Table->new($tablename); my %keyhash; - my $attrs = $table->{attrs}; + my $attrs = $table->{attr}; foreach my $attrhash (@$attrs) { foreach my $key (keys %$attrhash) { my $tblattr = $tablename; $tblattr .= ".$key="; - $tblattr .= $table->{attrs}->[0]->{$key}->[0]; + $tblattr .= $table->{attr}->[0]->{$key}->[0]; push (@{$newrequest->{arg}}, $tblattr); } } @@ -2429,10 +2441,10 @@ sub setNodesAttribs1 #delEntries # # nodelist -# +# # compute1,test # down -# +# #
# . # . @@ -2443,7 +2455,7 @@ sub setNodesAttribs1 # # # -# To delete all entries in a table, input no attributes +# To delete all entries in a table, you input no attributes # #PCM #delEntries @@ -2464,7 +2476,7 @@ sub delEntries my $tablename = $table->{name}->[0]; my $tab=xCAT::Table->new($tablename); my %keyhash; - my $attrs = $table->{attrs}; + my $attrs = $table->{attr}; foreach my $attrhash (@$attrs) { foreach my $key (keys %$attrhash) { $keyhash{$key} = $attrhash->{$key}->[0]; @@ -2488,8 +2500,8 @@ sub delEntries # # domain # -#value -#comments +#value +#comments # # # @@ -2503,7 +2515,7 @@ sub getAttribs my $cb = shift; my $command = $request->{command}->[0]; my $tablename = $request->{table}->[0]; - my $attr = $request->{attrs}; + my $attr = $request->{attr}; my @attrs= @$attr; my $tab=xCAT::Table->new($tablename); my %rsp; @@ -2523,3 +2535,37 @@ sub getAttribs $cb->(\%rsp); return; } +# setAttribs +# Set the attributes for the key(s) input in the table. +# +#PCM +#setAttribs +#site
+# +# domain +# +# +# cluster.net +# This is a comment +#
+# +# +sub setAttribs +{ + my $request = shift; + my $cb = shift; + my $command = $request->{command}->[0]; + my $tablename = $request->{table}->[0]; + my $tab=xCAT::Table->new($tablename); + my %rsp; + my %keyhash; + my %attrhash; + foreach my $k (keys %{$request->{keys}->[0]}) { + $keyhash{$k} = $request->{keys}->[0]->{$k}->[0]; + } + foreach my $a (keys %{$request->{attr}->[0]}) { + $attrhash{$a} = $request->{attr}->[0]->{$a}->[0]; + } + $tab->setAttribs(\%keyhash,\%attrhash); + return; +}