From e05f183a8fcff3ce8c9111b0169f5aa70925a68b Mon Sep 17 00:00:00 2001 From: chenglch Date: Mon, 20 Feb 2017 11:04:30 +0800 Subject: [PATCH] Use bulk operation to update chain table for multiple nodes Do not query bootparams table in yaboot patial-issue: #2024 --- xCAT-server/lib/xcat/plugins/destiny.pm | 14 +++++++++----- xCAT-server/lib/xcat/plugins/yaboot.pm | 11 ++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index 1b7eecde6..7d02170ff 100755 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -397,6 +397,7 @@ sub setdestiny { my $ntents = $nodetypetable->getNodesAttribs($samestatenodes, [qw(os arch profile)]); + my $updates; foreach (@{$samestatenodes}) { $nstates{$_} = $tempstate; #local copy of state variable for mod my $ntent = $ntents->{$_}->[0]; #$nodetype->getNodeAttribs($_,[qw(os arch profile)]); @@ -416,9 +417,10 @@ sub setdestiny { } else { $errored = 1; $callback->({ errorcode => [1], error => "nodetype.profile not defined for $_" }); } } if ($errored) { return; } - - #statelite - unless ($tempstate =~ /^netboot|^statelite/) { $chaintab->setNodeAttribs($_, { currchain => "boot" }); } + $updates->{$_}->{'currchain'} = "boot"; + } + unless ($tempstate =~ /^netboot|^statelite/) { + $chaintab->setNodesAttribs($updates); } if ($action eq "reboot4deploy") { @@ -599,18 +601,20 @@ sub setdestiny { } if ($noupdate) { return; } #skip table manipulation if just doing 'enact' + my $updates; foreach (@nodes) { my $lstate = $state; if ($nstates{$_}) { $lstate = $nstates{$_}; } - $chaintab->setNodeAttribs($_, { currstate => $lstate }); + $updates->{$_}->{'currstate'} = $lstate; # if there are multiple actions in the state argument, set the rest of states (shift out the first one) # to chain.currchain so that the rest ones could be used by nextdestiny command if ($reststates) { - $chaintab->setNodeAttribs($_, { currchain => $reststates }); + $updates->{$_}->{'currchain'} = $reststates; } + $chaintab->setNodesAttribs($updates); } return getdestiny($flag + 1); } diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index a1bde29f0..8e8ac37c9 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -95,7 +95,7 @@ sub setstate { my $tftpdir = shift; my %nrhash = %{ shift() }; my $linuximghash = shift(); - my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); + my $kern = $bphash{$node}->[0]; if ($kern->{kcmdline} =~ /!myipfn!/) { my $ipfn; my @ipfnd = xCAT::NetworkUtils->my_ip_facing($node); @@ -567,17 +567,18 @@ sub process_request { if (exists($::YABOOT_request->{inittime})) { $inittime = $::YABOOT_request->{inittime}->[0]; } if (!$inittime) { $inittime = 0; } $errored = 0; + my %bphash; unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { xCAT::MsgUtils->trace($verbose_on_off, "d", "yaboot: issue setdestiny request"); $sub_req->({ command => ['setdestiny'], node => \@nodes, inittime => [$inittime], - arg => \@args }, \&pass_along); + arg => \@args, + bootparams => \%bphash}, + \&pass_along); } if ($errored) { return; } - my $bptab = xCAT::Table->new('bootparams', -create => 1); - my $bphash = $bptab->getNodesAttribs(\@nodes, [ 'kernel', 'initrd', 'kcmdline', 'addkcmdline' ]); my $chaintab = xCAT::Table->new('chain', -create => 1); my $chainhash = $chaintab->getNodesAttribs(\@nodes, ['currstate']); my $noderestab = xCAT::Table->new('noderes', -create => 1); @@ -614,7 +615,7 @@ sub process_request { $linuximghash = $linuximgtab->getAttribs({ imagename => $osimgname }, 'boottarget', 'addkcmdline'); } - ($rc, $errstr) = setstate($_, $bphash, $chainhash, $machash, $tftpdir, $nrhash, $linuximghash); + ($rc, $errstr) = setstate($_, \%bphash, $chainhash, $machash, $tftpdir, $nrhash, $linuximghash); if ($rc) { $response{node}->[0]->{errorcode}->[0] = $rc; $response{node}->[0]->{errorc}->[0] = $errstr;