From 1f5e0fde43e1a5dfdce14551c32e242dd27beb7f Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 18 Sep 2013 06:40:32 -0400 Subject: [PATCH] update database immediately for defect 3785 --- xCAT-server/lib/xcat/plugins/updatenode.pm | 54 ++++++++++++++++------ 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 245ab7887..51ef6117e 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -1131,23 +1131,26 @@ sub updatenode waitpid($_, 0); } } - - # update the node status, this is done when -F -S -P are run - # make sure the nodes only appear in one array good or bad - &cleanstatusarrays; - if(@::SUCCESSFULLNODES) - { + # if immediate return of status not requested (PCM), then update the DB here + # in one transaction, otherwise it is updated in getdata callback and buildnodestatus + if (!(defined($request->{status})) || ($request->{status} ne "yes")) { + # update the node status, this is done when -F -S -P are run + # make sure the nodes only appear in one array good or bad + &cleanstatusarrays; + if(@::SUCCESSFULLNODES) + { my $stat="synced"; xCAT::TableUtils->setUpdateStatus(\@::SUCCESSFULLNODES, $stat); - } - if(@::FAILEDNODES) - { + } + if(@::FAILEDNODES) + { my $stat="failed"; xCAT::TableUtils->setUpdateStatus(\@::FAILEDNODES, $stat); + } } # if site.precreatemypostscripts = not 1 or yes or undefined, # remove all the @@ -1486,6 +1489,11 @@ sub buildnodestatus my $rsp2 = {}; $rsp2->{status}->[0] = "$node: SUCCEEDED"; $::CALLERCALLBACK->($rsp2); + # update the nodelist table updatestatus flag for the node + my $stat="synced"; + my @nodearray=(); + push @nodearray,$node; + xCAT::TableUtils->setUpdateStatus(\@nodearray, $stat); } if (grep(/^$node$/, @::SUCCESSFULLNODES)) { # already on the buffer next; @@ -1500,6 +1508,11 @@ sub buildnodestatus my $rsp2 = {}; $rsp2->{status}->[0] = "$node: FAILED"; $::CALLERCALLBACK->($rsp2); + # update the nodelist table updatestatus flag for the node + my $stat="failed"; + my @nodearray=(); + push @nodearray,$node; + xCAT::TableUtils->setUpdateStatus(\@nodearray, $stat); } if (grep(/^$node$/, @::FAILEDNODES)) { # already on the buffer next; @@ -1720,7 +1733,12 @@ sub getdata if ($::REPORTSTATUS eq "Y" ) { # return status NOW my $rsp2 = {}; $rsp2->{status}->[0] = "$node: SUCCEEDED"; - $::CALLERCALLBACK->($rsp2); + $::CALLERCALLBACK->($rsp2); + # update the nodelist table updatestatus flag for the node + my $stat="synced"; + my @nodearray=(); + push @nodearray,$node; + xCAT::TableUtils->setUpdateStatus(\@nodearray, $stat); } if (grep(/^$node$/, @::SUCCESSFULLNODES)) { # already on the buffer next; @@ -1739,9 +1757,14 @@ sub getdata my ($node,$info) = split (/:/, $output); if ($alreadyinstalled == 0) { # not an already install error, then real error if ($::REPORTSTATUS eq "Y" ) { # return status NOW - my $rsp2 = {}; - $rsp2->{status}->[0] = "$node: FAILED"; - $::CALLERCALLBACK->($rsp2); + my $rsp2 = {}; + $rsp2->{status}->[0] = "$node: FAILED"; + $::CALLERCALLBACK->($rsp2); + # update the nodelist table updatestatus flag for the node + my $stat="failed"; + my @nodearray=(); + push @nodearray,$node; + xCAT::TableUtils->setUpdateStatus(\@nodearray, $stat); } if (grep(/^$node$/, @::FAILEDNODES)) { # already on the buffer next; @@ -1753,6 +1776,11 @@ sub getdata my $rsp2 = {}; $rsp2->{status}->[0] = "$node: SUCCEEDED"; $::CALLERCALLBACK->($rsp2); + # update the nodelist table updatestatus flag for the node + my $stat="synced"; + my @nodearray=(); + push @nodearray,$node; + xCAT::TableUtils->setUpdateStatus(\@nodearray, $stat); } if (grep(/^$node$/, @::SUCCESSFULLNODES)) { # already on the buffer next;