From 7c314e731fa286c99f0f4c262c2db8d9e02aca61 Mon Sep 17 00:00:00 2001 From: lissav Date: Sun, 13 May 2012 11:44:38 +0000 Subject: [PATCH] Add delEntries XML support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12654 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/tabutils.pm | 85 ++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 94f4874d2..64f182926 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -54,10 +54,10 @@ sub handled_commands nr => "tabutils", # not implemented yet rnoderange => "tabutils", # not implemented yet tabgrep => "tabutils", - getAllEntries => "tabutils", - getNodesAttribs => "tabutils", - setNodesAttribs1 => "tabutils", - setNodesAttribs2 => "tabutils", + getAllEntries => "tabutils", + getNodesAttribs => "tabutils", + setNodesAttribs1 => "tabutils", + delEntries => "tabutils", gennr => "tabutils" }; } @@ -156,6 +156,10 @@ sub process_request { return setNodesAttribs1($request,$callback); } + elsif ($command eq "delEntries") + { + return delEntries($request,$callback); + } else { print "$command not implemented yet\n"; @@ -2339,7 +2343,7 @@ sub getNodesAttribs # # nodelist # -# lissa +# test # This is a another testx # #
@@ -2357,7 +2361,7 @@ sub setNodesAttribs1 { my $request = shift; my $cb = shift; - my $node = $request->{node}; + my $node = $request->{node}; # added by Client.pm my $noderange = $request->{noderange}; my $command = $request->{command}->[0]; my %rsp; @@ -2369,6 +2373,8 @@ sub setNodesAttribs1 $newrequest->{command}->[0] = "nodech"; foreach my $table (@$tables) { my $tablename = $table->{name}->[0]; + my $tab=xCAT::Table->new($tablename); + my %keyhash; my $attrs = $table->{attrs}; foreach my $attrhash (@$attrs) { foreach my $key (keys %$attrhash) { @@ -2387,3 +2393,70 @@ sub setNodesAttribs1 } return; } +# +# delEntries +# Deletes the table entry based on the input attributes +# The attributes and AND'd to together to form the delete request +# DELETE FROM nodelist WHERE ("groups" = "compute1,test" AND "status" = "down") +# Example of XML in for this routine +# +# +#PCM +#delEntries +# +# nodelist +# +# compute1,test +# down +# +#
+# . +# . +# +# . +# . +# . +#
+#
+# +# To delete all entries in a table, input no attributes +# +#PCM +#delEntries +# +# nodelist +#
+#
+ + +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]; + my $tab=xCAT::Table->new($tablename); + my %keyhash; + my $attrs = $table->{attrs}; + foreach my $attrhash (@$attrs) { + foreach my $key (keys %$attrhash) { + $keyhash{$key} = $attrhash->{$key}->[0]; + } + } + if (%keyhash) { # delete based on requested attributes + $tab->delEntries(\%keyhash); #Yes, delete *all* entries + } else { # delete all entries + $tab->delEntries(); #delete *all* entries + } + $tab->commit; # commit + } + return; +}