diff --git a/xCAT-server/lib/xcat/plugins/prescripts.pm b/xCAT-server/lib/xcat/plugins/prescripts.pm index d153adf63..74014504a 100644 --- a/xCAT-server/lib/xcat/plugins/prescripts.pm +++ b/xCAT-server/lib/xcat/plugins/prescripts.pm @@ -173,17 +173,16 @@ sub runbeginpre foreach my $s (@script_array) { my $ret=`NODES=$runnodes_s ACTION=$action $installdir/prescripts/$s 2>&1`; my $err_code=$?; - if ($err_code != 0) { + if ($ret) { my $rsp = {}; $rsp->{data}->[0]="$localhostname: $s: $ret"; $callback->($rsp); - my $err_code=$?; - if ($err_code != 0) { - $rsp = {}; - $rsp->{data}->[0]="$localhostname: $s: error code=$err_code."; - $callback->($rsp); - last; - } + } + if ($err_code != 0) { + $rsp = {}; + $rsp->{error}->[0]="$localhostname: $s: return code=$err_code."; + $callback->($rsp); + last; } } } @@ -226,13 +225,15 @@ sub runendpre my @script_array=split(',', $scripts); foreach my $s (@script_array) { my $ret=`NODES=$runnodes_s ACTION=$action $installdir/prescripts/$s 2>&1`; - my $rsp = {}; - $rsp->{data}->[0]="$localhostname: $s: $ret"; - $callback->($rsp); my $err_code=$?; + if ($ret) { + my $rsp = {}; + $rsp->{data}->[0]="$localhostname: $s: $ret"; + $callback->($rsp); + } if ($err_code != 0) { $rsp = {}; - $rsp->{data}->[0]="$localhostname: $s: error code=$err_code."; + $rsp->{error}->[0]="$localhostname: $s: return code=$err_code."; $callback->($rsp); last; } diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 4b510f31c..bd347eff6 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -9,6 +9,7 @@ use Getopt::Long; my $request; my $callback; +my $callback1; my $dhcpconf = "/etc/dhcpd.conf"; my $tftpdir = "/tftpboot"; #my $dhcpver = 3; @@ -221,13 +222,26 @@ sub pass_along { } } +sub pass_along1 { + my $resp = shift; + $callback1->($resp); + if ($resp and ($resp->{errorcode} and $resp->{errorcode}->[0]) or ($resp->{error} and $resp->{error}->[0])) { + $errored=1; + } + foreach (@{$resp->{node}}) { + if ($_->{error} or $_->{errorcode}) { + $errored=1; + } + } +} + sub preprocess_request { my $req = shift; if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } - $callback = shift; + $callback1 = shift; my $command = $req->{command}->[0]; my $sub_req = shift; my @args=(); @@ -245,7 +259,7 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } @@ -254,7 +268,7 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } @@ -263,7 +277,7 @@ sub preprocess_request { my $ver = xCAT::Utils->Version(); my %rsp; $rsp{data}->[0]="$ver"; - $callback->(\%rsp); + $callback1->(\%rsp); return; } @@ -271,25 +285,25 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } #now run the begin part of the prescripts - #my @nodes=(); - #if (ref($req->{node})) { -# @nodes = @{$req->{node}}; -# } else { -# if ($req->{node}) { @nodes = ($req->{node}); } -# } -# $errored=0; -# unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { -# $sub_req->({command=>['runbeginpre'], -# node=>\@nodes, -# arg=>[$args[0]]},\&pass_along); -# } -# if ($errored) { return; } + my @nodes=(); + if (ref($req->{node})) { + @nodes = @{$req->{node}}; + } else { + if ($req->{node}) { @nodes = ($req->{node}); } + } + $errored=0; + unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + $sub_req->({command=>['runbeginpre'], + node=>\@nodes, + arg=>[$args[0]]},\&pass_along1); + } + if ($errored) { return; } #Assume shared tftp directory for boring people, but for cool people, help sync up tftpdirectory contents when #they specify no sharedtftp in site table diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index cf9f5ff21..45ec0918f 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -11,6 +11,7 @@ my $request; my %breaknetbootnodes; my %normalnodes; my $callback; +my $callback1; my $sub_req; my $dhcpconf = "/etc/dhcpd.conf"; my $tftpdir = "/tftpboot"; @@ -188,8 +189,11 @@ sub setstate { my $errored = 0; sub pass_along { - #print "pass_along\n"; + print "pass_along\n"; my $resp = shift; + +# print Dumper($resp); + $callback->($resp); if ($resp and ($resp->{errorcode} and $resp->{errorcode}->[0]) or ($resp->{error} and $resp->{error}->[0])) { $errored=1; @@ -201,13 +205,28 @@ sub pass_along { } } +sub pass_along1 { + print "pass_along1\n"; + my $resp = shift; +# print Dumper($resp); + + $callback1->($resp); + if ($resp and ($resp->{errorcode} and $resp->{errorcode}->[0]) or ($resp->{error} and $resp->{error}->[0])) { + $errored=1; + } + foreach (@{$resp->{node}}) { + if ($_->{error} or $_->{errorcode}) { + $errored=1; + } + } +} sub preprocess_request { my $req = shift; if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; } - $callback = shift; + $callback1 = shift; my $command = $req->{command}->[0]; my $sub_req = shift; my @args=(); @@ -225,7 +244,7 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } @@ -234,7 +253,7 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } @@ -243,7 +262,7 @@ sub preprocess_request { my $ver = xCAT::Utils->Version(); my %rsp; $rsp{data}->[0]="$ver"; - $callback->(\%rsp); + $callback1->(\%rsp); return; } @@ -251,25 +270,25 @@ sub preprocess_request { if($usage{$command}) { my %rsp; $rsp{data}->[0]=$usage{$command}; - $callback->(\%rsp); + $callback1->(\%rsp); } return; } #now run the begin part of the prescripts - #my @nodes=(); - #if (ref($req->{node})) { -# @nodes = @{$req->{node}}; -# } else { -# if ($req->{node}) { @nodes = ($req->{node}); } -# } -# $errored=0; -# unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { -# $sub_req->({command=>['runbeginpre'], -# node=>\@nodes, -# arg=>[$args[0]]},\&pass_along); -# } -# if ($errored) { return; } + my @nodes=(); + if (ref($req->{node})) { + @nodes = @{$req->{node}}; + } else { + if ($req->{node}) { @nodes = ($req->{node}); } + } + $errored=0; + unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') { + $sub_req->({command=>['runbeginpre'], + node=>\@nodes, + arg=>[$args[0]]},\&pass_along1); + } + if ($errored) { return; } #Assume shared tftp directory for boring people, but for cool people, help sync up tftpdirectory contents when #they specify no sharedtftp in site table