defect 3998 - change file vars to globals

This commit is contained in:
mellor 2014-03-26 17:08:17 -04:00
parent c822d4f560
commit e75be5fe88
4 changed files with 132 additions and 142 deletions

View File

@ -11,9 +11,6 @@ use Getopt::Long;
require xCAT::Utils;
require xCAT::TableUtils;
use xCAT::ServiceNodeUtils;
my $addkcmdlinehandled;
my $request;
my $callback;
my $dhcpconf = "/etc/dhcpd.conf";
my $globaltftpdir = xCAT::TableUtils->getTftpDir();
#my $dhcpver = 3;
@ -93,7 +90,7 @@ sub setstate {
my $imgaddkcmdline=($linuximghash{'boottarget'})? undef:$linuximghash{'addkcmdline'};
my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']);
if (not $addkcmdlinehandled->{$node} and ($kern->{addkcmdline} or ($imgaddkcmdline))) {
if (not $::PXE_addkcmdlinehandled->{$node} and ($kern->{addkcmdline} or ($imgaddkcmdline))) {
#Implement the kcmdline append here for
#most generic, least code duplication
@ -129,7 +126,7 @@ sub setstate {
$kcmdlinehack =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$naval/;
} else {
my $msg = "Table key of $2 not yet supported by boottarget mini-template";
$::callback->({
$::PXE_callback->({
error => ["$msg"],
errorcode => [1]
});
@ -148,7 +145,7 @@ sub setstate {
unless ($ipfn) {
my @myself = xCAT::NetworkUtils->determinehostname();
my $myname = $myself[(scalar @myself)-1];
$::callback->(
$::PXE_callback->(
{
error => [
"$myname: Unable to determine or reasonably guess the image server for $node"
@ -263,11 +260,11 @@ sub pass_along {
$errored=1;
}
if ($_->{_addkcmdlinehandled}) {
$addkcmdlinehandled->{$_->{name}->[0]}=1;
$::PXE_addkcmdlinehandled->{$_->{name}->[0]}=1;
return; #Don't send back to client this internal hint
}
}
$callback->($resp);
$::PXE_callback->($resp);
}
@ -356,28 +353,28 @@ sub preprocess_request {
}
sub process_request {
$request = shift;
$callback = shift;
$::PXE_request = shift;
$::PXE_callback = shift;
my $sub_req = shift;
$::callback=$callback;
undef $::PXE_addkcmdlinehandled;
my @args;
my @nodes;
my @rnodes;
if (ref($request->{node})) {
@rnodes = @{$request->{node}};
if (ref($::PXE_request->{node})) {
@rnodes = @{$::PXE_request->{node}};
} else {
if ($request->{node}) { @rnodes = ($request->{node}); }
if ($::PXE_request->{node}) { @rnodes = ($::PXE_request->{node}); }
}
unless (@rnodes) {
if ($usage{$request->{command}->[0]}) {
$callback->({data=>$usage{$request->{command}->[0]}});
if ($usage{$::PXE_request->{command}->[0]}) {
$::PXE_callback->({data=>$usage{$::PXE_request->{command}->[0]}});
}
return;
}
#if not shared, then help sync up
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::PXE_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
foreach (@rnodes) {
if (xCAT::NetworkUtils->nodeonmynet($_)) {
@ -396,16 +393,16 @@ sub process_request {
return;
}
if (ref($request->{arg})) {
@args=@{$request->{arg}};
if (ref($::PXE_request->{arg})) {
@args=@{$::PXE_request->{arg}};
} else {
@args=($request->{arg});
@args=($::PXE_request->{arg});
}
#now run the begin part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::PXE_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runbeginpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -418,7 +415,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running begin prescripts\n";
$callback->($rsp);
$::PXE_callback->($rsp);
return;
}
}
@ -426,7 +423,7 @@ sub process_request {
#end prescripts code
if (! -r "$tftpdir/pxelinux.0") {
unless (-r "/usr/lib/syslinux/pxelinux.0" or -r "/usr/share/syslinux/pxelinux.0") {
$callback->({error=>["Unable to find pxelinux.0 "],errorcode=>[1]});
$::PXE_callback->({error=>["Unable to find pxelinux.0 "],errorcode=>[1]});
return;
}
if (-r "/usr/lib/syslinux/pxelinux.0") {
@ -437,14 +434,14 @@ sub process_request {
chmod(0644,"$tftpdir/pxelinux.0");
}
unless ( -r "$tftpdir/pxelinux.0" ) {
$callback->({errror=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
$::PXE_callback->({errror=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
return;
}
$errored=0;
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::PXE_request->{inittime})) { $inittime= $::PXE_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$sub_req->({command=>['setdestiny'],
@ -476,7 +473,7 @@ sub process_request {
$response{node}->[0]->{name}->[0]=$_;
if ($args[0] eq 'stat') {
$response{node}->[0]->{data}->[0]= getstate($_,$tftpdir);
$callback->(\%response);
$::PXE_callback->(\%response);
} elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate
my $ent = $nthash{$_}->[0];
my $osimgname = $ent->{'provmethod'};
@ -488,13 +485,13 @@ sub process_request {
if ($rc) {
$response{node}->[0]->{errorcode}->[0]= $rc;
$response{node}->[0]->{errorc}->[0]= $errstr;
$callback->(\%response);
$::PXE_callback->(\%response);
}
}
}
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::PXE_request->{inittime})) { $inittime= $::PXE_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
#dhcp stuff -- inittime is set when xcatd on sn is started
@ -511,12 +508,12 @@ sub process_request {
#}
if ($do_dhcpsetup) {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::PXE_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@nodes},$callback);
node=>\@nodes},$::PXE_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@nodes},$callback);
node=>\@nodes},$::PXE_callback);
}
}
@ -568,7 +565,7 @@ sub process_request {
#now run the end part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact')
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::PXE_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runendpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -581,7 +578,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running end prescripts\n";
$callback->($rsp);
$::PXE_callback->($rsp);
return;
}
}

View File

@ -11,9 +11,6 @@ use Getopt::Long;
use xCAT::MsgUtils;
use xCAT::ServiceNodeUtils;
use xCAT::TableUtils;
my $addkcmdlinehandled;
my $request;
my $callback;
my $dhcpconf = "/etc/dhcpd.conf";
my $tftpdir = "/tftpboot/vsmp";
#my $dhcpver = 3;
@ -75,7 +72,7 @@ sub setstate {
my %chainhash = %{shift()};
my %machash = %{shift()};
my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']);
if (not $addkcmdlinehandled->{$node} and $kern->{addkcmdline}) { #Implement the kcmdline append here for
if (not $::VSMPPXE_addkcmdlinehandled->{$node} and $kern->{addkcmdline}) { #Implement the kcmdline append here for
#most generic, least code duplication
$kern->{kcmdline} .= " ".$kern->{addkcmdline};
}
@ -84,7 +81,7 @@ sub setstate {
unless ($ipfn) {
my @myself = xCAT::NetworkUtils->determinehostname();
my $myname = $myself[(scalar @myself)-1];
$callback->(
$::VSMPPXE_callback->(
{
error => [
"$myname: Unable to determine or reasonably guess the image server for $node"
@ -189,11 +186,11 @@ sub pass_along {
$errored=1;
}
if ($_->{_addkcmdlinehandled}) {
$addkcmdlinehandled->{$_->{name}->[0]}=1;
$::VSMPPXE_addkcmdlinehandled->{$_->{name}->[0]}=1;
return; #Don't send back to client this internal hint
}
}
$callback->($resp);
$::VSMPPXE_callback->($resp);
}
@ -288,29 +285,30 @@ sub preprocess_request {
}
sub process_request {
$request = shift;
$callback = shift;
$::VSMPPXE_request = shift;
$::VSMPPXE_callback = shift;
my $sub_req = shift;
undef $::VSMPPXE_addkcmdlinehandled;
my @args;
my @nodes;
my @rnodes;
if (ref($request->{node})) {
@rnodes = @{$request->{node}};
if (ref($::VSMPPXE_request->{node})) {
@rnodes = @{$::VSMPPXE_request->{node}};
} else {
if ($request->{node}) {
@rnodes = ($request->{node});
if ($::VSMPPXE_request->{node}) {
@rnodes = ($::VSMPPXE_request->{node});
}
}
unless (@rnodes) {
if ($usage{$request->{command}->[0]}) {
$callback->({data=>$usage{$request->{command}->[0]}});
if ($usage{$::VSMPPXE_request->{command}->[0]}) {
$::VSMPPXE_callback->({data=>$usage{$::VSMPPXE_request->{command}->[0]}});
}
return;
}
#if not shared, then help sync up
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::VSMPPXE_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
foreach (@rnodes) {
if (xCAT::NetworkUtils->nodeonmynet($_)) {
@ -329,17 +327,17 @@ sub process_request {
return;
}
if (ref($request->{arg})) {
@args=@{$request->{arg}};
if (ref($::VSMPPXE_request->{arg})) {
@args=@{$::VSMPPXE_request->{arg}};
} else {
@args=($request->{arg});
@args=($::VSMPPXE_request->{arg});
}
#now run the begin part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::VSMPPXE_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runbeginpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -352,7 +350,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running begin prescripts\n";
$callback->($rsp);
$::VSMPPXE_callback->($rsp);
return;
}
}
@ -375,7 +373,7 @@ sub process_request {
if (! -r "$tftpdir/pxelinux.0") {
unless (-r "/usr/lib/syslinux/pxelinux.0" or -r "/usr/share/syslinux/pxelinux.0") {
$callback->({error=>["Unable to find pxelinux.0 "],errorcode=>[1]});
$::VSMPPXE_callback->({error=>["Unable to find pxelinux.0 "],errorcode=>[1]});
return;
}
if (-r "/usr/lib/syslinux/pxelinux.0") {
@ -386,14 +384,14 @@ sub process_request {
chmod(0644,"$tftpdir/pxelinux.0");
}
unless ( -r "$tftpdir/pxelinux.0" ) {
$callback->({errror=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
$::VSMPPXE_callback->({errror=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
return;
}
$errored=0;
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::VSMPPXE_request->{inittime})) { $inittime= $::VSMPPXE_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$sub_req->({command=>['setdestiny'],
@ -414,19 +412,19 @@ sub process_request {
$response{node}->[0]->{name}->[0]=$_;
if ($args[0] eq 'stat') {
$response{node}->[0]->{data}->[0]= getstate($_);
$callback->(\%response);
$::VSMPPXE_callback->(\%response);
} elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate
($rc,$errstr) = setstate($_,\%bphash,\%chainhash,\%machash);
if ($rc) {
$response{node}->[0]->{errorcode}->[0]= $rc;
$response{node}->[0]->{errorc}->[0]= $errstr;
$callback->(\%response);
$::VSMPPXE_callback->(\%response);
}
}
}
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::VSMPPXE_request->{inittime})) { $inittime= $::VSMPPXE_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
#dhcp stuff -- inittime is set when xcatd on sn is started
@ -443,12 +441,12 @@ sub process_request {
#}
if ($do_dhcpsetup) {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::VSMPPXE_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@nodes},$callback);
node=>\@nodes},$::VSMPPXE_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@nodes},$callback);
node=>\@nodes},$::VSMPPXE_callback);
}
}
@ -456,7 +454,7 @@ sub process_request {
#now run the end part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact')
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::VSMPPXE_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runendpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -469,7 +467,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running end prescripts\n";
$callback->($rsp);
$::VSMPPXE_callback->($rsp);
return;
}
}

View File

@ -11,9 +11,7 @@ use Getopt::Long;
use xCAT::Utils;
use xCAT::TableUtils;
use xCAT::ServiceNodeUtils;
my $addkcmdlinehandled;
my $request;
my $callback;
my $dhcpconf = "/etc/dhcpd.conf";
#my $tftpdir = "/tftpboot";
my $globaltftpdir = xCAT::TableUtils->getTftpDir();
@ -102,7 +100,7 @@ sub setstate {
if (ref $linuximghashref) { %linuximghash = %{$linuximghashref}; }
my $imgaddkcmdline=($linuximghash{'boottarget'})? undef:$linuximghash{'addkcmdline'};
my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']);
unless ($addkcmdlinehandled->{$node}) { #Tag to let us know the plugin had a special syntax implemented for addkcmdline
unless ($::XNBA_addkcmdlinehandled->{$node}) { #Tag to let us know the plugin had a special syntax implemented for addkcmdline
if ($kern->{addkcmdline} or ($imgaddkcmdline)) {
#Implement the kcmdline append here for
@ -138,7 +136,7 @@ sub setstate {
$kcmdlinehack =~ s/#TABLE:([^:#]+):([^:#]+):([^:#]+)#/$naval/;
} else {
my $msg = "Table key of $2 not yet supported by boottarget mini-template";
$callback->({
$::XNBA_callback->({
error => ["$msg"],
errorcode => [1]
});
@ -279,11 +277,11 @@ sub pass_along {
$errored=1;
}
if ($_->{_addkcmdlinehandled}) {
$addkcmdlinehandled->{$_->{name}->[0]}=1;
$::XNBA_addkcmdlinehandled->{$_->{name}->[0]}=1;
return; #Don't send back to client this internal hint
}
}
$callback->($resp);
$::XNBA_callback->($resp);
}
@ -376,27 +374,28 @@ sub preprocess_request {
}
sub process_request {
$request = shift;
$callback = shift;
$::XNBA_request = shift;
$::XNBA_callback = shift;
my $sub_req = shift;
undef $::XNBA_addkcmdlinehandled; # clear out any previous value
my @args;
my @nodes;
my @rnodes;
if (ref($request->{node})) {
@rnodes = @{$request->{node}};
if (ref($::XNBA_request->{node})) {
@rnodes = @{$::XNBA_request->{node}};
} else {
if ($request->{node}) { @rnodes = ($request->{node}); }
if ($::XNBA_request->{node}) { @rnodes = ($::XNBA_request->{node}); }
}
unless (@rnodes) {
if ($usage{$request->{command}->[0]}) {
$callback->({data=>$usage{$request->{command}->[0]}});
if ($usage{$::XNBA_request->{command}->[0]}) {
$::XNBA_callback->({data=>$usage{$::XNBA_request->{command}->[0]}});
}
return;
}
#if not shared, then help sync up
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::XNBA_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
foreach (@rnodes) {
if (xCAT::NetworkUtils->nodeonmynet($_)) {
@ -415,16 +414,16 @@ sub process_request {
return;
}
if (ref($request->{arg})) {
@args=@{$request->{arg}};
if (ref($::XNBA_request->{arg})) {
@args=@{$::XNBA_request->{arg}};
} else {
@args=($request->{arg});
@args=($::XNBA_request->{arg});
}
#now run the begin part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runbeginpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -437,7 +436,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running begin prescripts.\n";
$callback->($rsp);
$::XNBA_callback->($rsp);
return;
}
}
@ -445,21 +444,21 @@ sub process_request {
#back to normal business
if (! -r "$globaltftpdir/xcat/pxelinux.0") {
unless (-r $::XCATROOT."/share/xcat/netboot/syslinux/pxelinux.0") {
$callback->({error=>["Unable to find pxelinux.0 at ".$::XCATROOT."/share/xcat/netboot/syslinux/pxelinux.0"],errorcode=>[1]});
$::XNBA_callback->({error=>["Unable to find pxelinux.0 at ".$::XCATROOT."/share/xcat/netboot/syslinux/pxelinux.0"],errorcode=>[1]});
return;
}
copy($::XCATROOT."/share/xcat/netboot/syslinux/pxelinux.0","$globaltftpdir/xcat/pxelinux.0");
chmod(0644,"$globaltftpdir/xcat/pxelinux.0");
}
unless ( -r "$globaltftpdir/xcat/pxelinux.0" ) {
$callback->({error=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
$::XNBA_callback->({error=>["Unable to find pxelinux.0 from syslinux"],errorcode=>[1]});
return;
}
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::XNBA_request->{inittime})) { $inittime= $::XNBA_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
$errored=0;
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
@ -499,7 +498,7 @@ sub process_request {
$response{node}->[0]->{name}->[0]=$_;
if ($args[0] eq 'stat') {
$response{node}->[0]->{data}->[0]= getstate($_,$tftpdir);
$callback->(\%response);
$::XNBA_callback->(\%response);
} elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate
my $rc;
my $errstr;
@ -514,7 +513,7 @@ sub process_request {
#if ($rc) {
# $response{node}->[0]->{errorcode}->[0]= $rc;
# $response{node}->[0]->{errorc}->[0]= $errstr;
# $callback->(\%response);
# $::XNBA_callback->(\%response);
#}
if($args[0] eq 'offline') {
unlink($tftpdir."/xcat/xnba/nodes/".$_);
@ -540,12 +539,12 @@ sub process_request {
#}
if ($do_dhcpsetup) {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::XNBA_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@nodes},$callback);
node=>\@nodes},$::XNBA_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@nodes},$callback);
node=>\@nodes},$::XNBA_callback);
}
}
}
@ -553,7 +552,7 @@ sub process_request {
#now run the end part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact')
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::XNBA_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runendpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -566,7 +565,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running end prescripts.\n";
$callback->($rsp);
$::XNBA_callback->($rsp);
return;
}
}

View File

@ -13,11 +13,8 @@ use Socket;
use Getopt::Long;
use xCAT::Table;
my $request;
my %breaknetbootnodes;
our %normalnodes;
my $callback;
my $sub_req;
my $dhcpconf = "/etc/dhcpd.conf";
my $globaltftpdir = xCAT::TableUtils->getTftpDir();
#my $dhcpver = 3;
@ -104,7 +101,7 @@ sub setstate {
if (xCAT::InstUtils->is_me($sn)) {
my @myself = xCAT::NetworkUtils->determinehostname();
my $myname = $myself[(scalar @myself)-1];
$::callback->(
$::YABOOT_callback->(
{
error => [
"$myname: Unable to determine the image server for $node on service node $sn"
@ -116,7 +113,7 @@ sub setstate {
}
}
} else {
$::callback->(
$::YABOOT_callback->(
{
error => [
"$myname: Unable to determine the image server for $node"
@ -177,7 +174,7 @@ sub setstate {
delete $normalnodes{$node}; #Signify to omit this from one makedhcp command
#$sub_req->({command=>['makedhcp'], #batched elsewhere, this code is stale, hopefully
# node=>[$node],
# arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
# arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
print $pcfg "bye\n";
close($pcfg);
} elsif ($kern and $kern->{kernel}) {
@ -231,13 +228,13 @@ sub setstate {
#to clear the filename field, so the logic is a little
#opposite
# $sub_req->({command=>['makedhcp'], #This is currently batched elswhere
# node=>[$node]},$callback); #It hopefully will perform correctly
# node=>[$node]},$::YABOOT_callback); #It hopefully will perform correctly
if ($cref and $cref->{currstate} eq "boot") {
$breaknetbootnodes{$node}=1;
delete $normalnodes{$node}; #Signify to omit this from one makedhcp command
#$sub_req->({command=>['makedhcp'], #batched elsewhere, this code is stale, hopefully
# node=>[$node],
# arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
# arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
print $pcfg "bye\n";
close($pcfg);
} elsif ($kern and $kern->{kernel}) {
@ -309,7 +306,7 @@ sub pass_along {
# print Dumper($resp);
$callback->($resp);
$::YABOOT_callback->($resp);
if ($resp and ($resp->{errorcode} and $resp->{errorcode}->[0]) or ($resp->{error} and $resp->{error}->[0])) {
$errored=1;
}
@ -409,31 +406,30 @@ sub preprocess_request {
sub process_request {
$request = shift;
$callback = shift;
$::callback=$callback;
$sub_req = shift;
my $command = $request->{command}->[0];
$::YABOOT_request = shift;
$::YABOOT_callback = shift;
my $sub_req = shift;
my $command = $::YABOOT_request->{command}->[0];
%breaknetbootnodes=();
%normalnodes=();
my @args;
my @nodes;
my @rnodes;
if (ref($request->{node})) {
@rnodes = @{$request->{node}};
if (ref($::YABOOT_request->{node})) {
@rnodes = @{$::YABOOT_request->{node}};
} else {
if ($request->{node}) { @rnodes = ($request->{node}); }
if ($::YABOOT_request->{node}) { @rnodes = ($::YABOOT_request->{node}); }
}
unless (@rnodes) {
if ($usage{$request->{command}->[0]}) {
$callback->({data=>$usage{$request->{command}->[0]}});
if ($usage{$::YABOOT_request->{command}->[0]}) {
$::YABOOT_callback->({data=>$usage{$::YABOOT_request->{command}->[0]}});
}
return;
}
#if not shared tftpdir, then filter, otherwise, set up everything
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
@nodes = ();
foreach (@rnodes) {
if (xCAT::NetworkUtils->nodeonmynet($_)) {
@ -452,16 +448,16 @@ sub process_request {
return;
}
if (ref($request->{arg})) {
@args=@{$request->{arg}};
if (ref($::YABOOT_request->{arg})) {
@args=@{$::YABOOT_request->{arg}};
} else {
@args=($request->{arg});
@args=($::YABOOT_request->{arg});
}
#now run the begin part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runbeginpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -474,14 +470,14 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running begin prescripts.\n";
$callback->($rsp);
$::YABOOT_callback->($rsp);
return;
}
}
#back to normal business
my $inittime=0;
if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];}
if (exists($::YABOOT_request->{inittime})) { $inittime= $::YABOOT_request->{inittime}->[0];}
if (!$inittime) { $inittime=0;}
$errored=0;
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') {
@ -521,7 +517,7 @@ sub process_request {
$response{node}->[0]->{name}->[0]=$_;
if ($args[0] eq 'stat') {
$response{node}->[0]->{data}->[0]= getstate($_,$tftpdir);
$callback->(\%response);
$::YABOOT_callback->(\%response);
} elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate
my $ent = $typehash->{$_}->[0];
my $osimgname = $ent->{'provmethod'};
@ -534,7 +530,7 @@ sub process_request {
if ($rc) {
$response{node}->[0]->{errorcode}->[0]= $rc;
$response{node}->[0]->{errorc}->[0]= $errstr;
$callback->(\%response);
$::YABOOT_callback->(\%response);
}
}
}# end of foreach node
@ -577,7 +573,7 @@ sub process_request {
my $rsp;
push @{$rsp->{data}},
"stop configuration because yaboot DOES NOT work for $os provision, please change noderes.netboot=grub2 instead.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
@ -589,7 +585,7 @@ sub process_request {
my $rsp;
push @{$rsp->{data}},
"stop configuration because yaboot-xcat need to be installed for $os.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
} elsif (($osv =~ /rh/ and int($osn) >= 6) or
@ -600,7 +596,7 @@ sub process_request {
my $rsp;
push @{$rsp->{data}},
"stop configuration because rsync does not exist or is not executable.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
my $yabootpath = $tftpdir."/yb/".$os;
@ -622,7 +618,7 @@ sub process_request {
my $rsp;
push @{$rsp->{data}},
"stop configuration because Unable to find the os shipped yaboot file.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
@ -633,7 +629,7 @@ sub process_request {
my $rsp;
push @{$rsp->{data}},
"stop configuration because $synccmd failed.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
xCAT::MsgUtils->message("E", $rsp, $::YABOOT_callback);
return;
}
}
@ -675,42 +671,42 @@ sub process_request {
if (($osv =~ /rh/ and int($osn) >= 6) or
($osv =~ /sles/ and int($osn) >= 11)) {
my $fpath = "/yb/". $osentry."/yaboot";
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-l','-s','filename = \"'.$fpath.'\";']},$callback);
arg=>['-l','-s','filename = \"'.$fpath.'\";']},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}},
arg=>['-s','filename = \"'.$fpath.'\";']},$callback);
arg=>['-s','filename = \"'.$fpath.'\";']},$::YABOOT_callback);
}
} else {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@{$osimagenodehash{$osimage}}},$callback);
node=>\@{$osimagenodehash{$osimage}}},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@{$osimagenodehash{$osimage}}},$callback);
node=>\@{$osimagenodehash{$osimage}}},$::YABOOT_callback);
}
}
}
} else {
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed
$sub_req->({command=>['makedhcp'],arg=>['-l'],
node=>\@normalnodeset},$callback);
node=>\@normalnodeset},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@normalnodeset},$callback);
node=>\@normalnodeset},$::YABOOT_callback);
}
}
if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-l','-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
arg=>['-l','-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
} else {
$sub_req->({command=>['makedhcp'],
node=>\@breaknetboot,
arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback);
arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$::YABOOT_callback);
}
}
}
@ -718,7 +714,7 @@ sub process_request {
#now run the end part of the prescripts
unless ($args[0] eq 'stat') { # or $args[0] eq 'enact')
$errored=0;
if ($request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
if ($::YABOOT_request->{'_disparatetftp'}->[0]) { #the call is distrubuted to the service node already, so only need to handles my own children
$sub_req->({command=>['runendpre'],
node=>\@nodes,
arg=>[$args[0], '-l']},\&pass_along);
@ -731,7 +727,7 @@ sub process_request {
my $rsp;
$rsp->{errorcode}->[0]=1;
$rsp->{error}->[0]="Failed in running end prescripts\n";
$callback->($rsp);
$::YABOOT_callback->($rsp);
return;
}
}