From 5a52fb253d617cac79a2bf00c5e0d30631c08ad1 Mon Sep 17 00:00:00 2001 From: mellor Date: Tue, 3 Jun 2014 11:27:09 -0400 Subject: [PATCH] defect 4147 - fix prescripts preprocess_request to only process nodes that have prescripts defined --- xCAT-server/lib/xcat/plugins/prescripts.pm | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/prescripts.pm b/xCAT-server/lib/xcat/plugins/prescripts.pm index 27bbf6931..ca9988ac3 100644 --- a/xCAT-server/lib/xcat/plugins/prescripts.pm +++ b/xCAT-server/lib/xcat/plugins/prescripts.pm @@ -46,8 +46,39 @@ sub preprocess_request #if already preprocessed, go straight to request if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } - my $nodes = $req->{node}; - if (!$nodes) { return;} + my $req_nodes = $req->{node}; + if (!$req_nodes) { return;} + + my @nodes; + my $command = $req->{command}->[0]; + my $column; + if ($command eq 'runbeginpre') { $column = 'begin'; } + elsif ($command eq 'runendpre') { $column = 'end'; } + else { $column = ''; } + + # See if anything in the prescripts table for the nodes. If not, skip. + # Nothing to do. + my $tab = xCAT::Table->new('prescripts'); + #first check if xcatdefaults entry + if ( $tab->getAttribs({node=>"xcatdefaults"},$column) ) { + # yes - process all nodes + @nodes = @$req_nodes; + } else { + # no xcatdefaults, check for node entries + my $tabdata=$tab->getNodesAttribs($req_nodes,['node', $column]); + if ($tabdata) { + foreach my $node (@$req_nodes) { + if (($tabdata->{$node}) && + ($tabdata->{$node}->[0]) && + ($tabdata->{$node}->[0]->{$column}) ) { + push (@nodes,$node); + } + } + } + } + + # if no nodes left to process, we are done + if (! @nodes) { return; } my $service = "xcat"; my @args=();