diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 031997d68..0a2a43df1 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -534,6 +534,7 @@ site => { " defserialport:\tThe default serial port - currently only used by mknb.\n\n". " defserialspeed:\tThe default serial speed - currently only used by mknb.\n\n". " dhcpinterfaces\tThe network interfaces DHCP should listen on. If it is the same for all nodes, use simple comma-separated list of NICs. To specify different NICs for different nodes: mn|eth1,eth2;service|bond0.\n\n". + " dhcpsetup:\tIf set to 'n', it'll skip the dhcp setup process in the nodeset command. The default value is 'y'.\n\n". " domain:\tThe DNS domain name used for the cluster.\n\n". " forwarders:\tThe DNS servers at your site that can provide names outside of the cluster. The DNS on the management node will forward requests it does not know to these servers.\n\n". " fsptimeout:\tThe timeout, in milliseconds, to use when communicating with FSPs.\n\n". diff --git a/xCAT-server/lib/xcat/plugins/prescripts.pm b/xCAT-server/lib/xcat/plugins/prescripts.pm index 0315b1029..d153adf63 100644 --- a/xCAT-server/lib/xcat/plugins/prescripts.pm +++ b/xCAT-server/lib/xcat/plugins/prescripts.pm @@ -89,7 +89,6 @@ sub preprocess_request # find out the names for the Management Node foreach my $snkey (keys %$sn) { - print "sn=$snkey\n"; my $reqcopy = {%$req}; $reqcopy->{node} = $sn->{$snkey}; $reqcopy->{'_xcatdest'} = $snkey; @@ -176,9 +175,15 @@ sub runbeginpre my $err_code=$?; if ($err_code != 0) { my $rsp = {}; - $rsp->{data}->[0]="$localhostname: $err_code: $ret"; + $rsp->{data}->[0]="$localhostname: $s: $ret"; $callback->($rsp); - last; + my $err_code=$?; + if ($err_code != 0) { + $rsp = {}; + $rsp->{data}->[0]="$localhostname: $s: error code=$err_code."; + $callback->($rsp); + last; + } } } } @@ -204,28 +209,6 @@ sub runendpre { $installdir = $installdir1[0]; } - my $inittime=0; - if (exists($request->{inittime})) { $inittime=$request->{inittime}->[0];} - if (!$inittime) { $inittime=0; }; - - #normalnodeset and breaknetboot are used by setupdhcp - #yaboo sets up normalnodeset and breaknetboot; pxe does not, so we use $nodes for pxe - my $normalnodeset=[]; - if (exists($request->{normalnodeset})) { $normalnodeset=$request->{normalnodeset};} - my %n_hash=(); - foreach (@$normalnodeset) { - $n_hash{$_}=1; - } - - my $breaknetboot=[]; - if (exists($request->{breaknetboot})) { $breaknetboot=$request->{breaknetboot};} - if ((!$normalnodeset) && (!$breaknetboot)) { $normalnodeset=$nodes;} - my %b_hash=(); - foreach (@$breaknetboot) { - $b_hash{$_}=1; - } - - print "prescripts:inittime=$inittime; normalnodeset=@$normalnodeset; breaknetboot=@$breaknetboot\n"; my %script_hash=getprescripts($nodes, $action, "end"); foreach my $scripts (keys %script_hash) { @@ -242,31 +225,7 @@ sub runendpre undef $SIG{CHLD}; my @script_array=split(',', $scripts); foreach my $s (@script_array) { - my $ret; - print "script name=$s\n"; - if ($s eq "setupdhcp") { #special case for setupdhcp - #remove the nodes from normalnodeset and breaknetboot that are not in runnodes - my @new_normalnodeset=(); - my @new_breaknetboot=(); - foreach (@$runnodes) { - if ($n_hash{$_}) { - push(@new_normalnodeset, $_); - $n_hash{$_}=0; - } elsif ($b_hash{$_}) { - push(@new_breaknetboot, $_); - $b_hash{$_}=0; - } - } - my $normalnodeset_s=join(',', @new_normalnodeset); - my $breaknetboot_s=join(',', @new_breaknetboot); - if (!$normalnodeset_s) { $normalnodeset_s="NONE"; } - if (!$breaknetboot_s) { $breaknetboot_s="NONE";} - - print "prescripts:inittime=$inittime; normalnodeset=$normalnodeset_s; breaknetboot=$breaknetboot_s\n"; - $ret=`NODES=$runnodes_s ACTION=$action $installdir/prescripts/$s $inittime $normalnodeset_s $breaknetboot_s 2>&1`; - } else { - $ret=`NODES=$runnodes_s ACTION=$action $installdir/prescripts/$s 2>&1`; - } + my $ret=`NODES=$runnodes_s ACTION=$action $installdir/prescripts/$s 2>&1`; my $rsp = {}; $rsp->{data}->[0]="$localhostname: $s: $ret"; $callback->($rsp); @@ -279,48 +238,6 @@ sub runendpre } } } - } - - #now handle the left over nodes, need to run setupdhcp for them - my @new_normalnodeset=(); - my @new_breaknetboot=(); - foreach (keys %n_hash) { - if ($n_hash{$_}) { - push(@new_normalnodeset, $_); - } - } - foreach (keys %b_hash) { - if ($b_hash{$_}) { - push(@new_breaknetboot, $_); - } - } - if ((@new_normalnodeset>0) || (@new_breaknetboot> 0)) { - my $tab = xCAT::Table->new('prescripts',-create=>1); - my $et = $tab->getAttribs({node=>"xcatdefaults"},'end'); - my $tmp_def = $et->{end}; - my $defscripts; - if ($tmp_def) { - $defscripts=parseprescripts($tmp_def, $action); - } - - if ($defscripts =~ /setupdhcp/) { - my $normalnodeset_s=join(',', @new_normalnodeset); - my $breaknetboot_s=join(',', @new_breaknetboot); - if (!$normalnodeset_s) { $normalnodeset_s="NONE"; } - if (!$breaknetboot_s) { $breaknetboot_s="NONE";} - - print "prescripts: setup dhcp inittime=$inittime; normalnodeset=$normalnodeset_s; breaknetboot=$breaknetboot_s\n"; - my $ret=`ACTION=$action $installdir/prescripts/setupdhcp $inittime $normalnodeset_s $breaknetboot_s 2>&1`; - my $rsp = {}; - $rsp->{data}->[0]="$localhostname: setupdhsp: $ret"; - $callback->($rsp); - my $err_code=$?; - if ($err_code != 0) { - $rsp = {}; - $rsp->{data}->[0]="$localhostname: setupdhcp: error code=$err_code."; - $callback->($rsp); - } - } } return; diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 9b2aa9834..4b510f31c 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -447,20 +447,39 @@ sub process_request { my $inittime=0; if (exists($request->{inittime})) { $inittime= $request->{inittime}->[0];} if (!$inittime) { $inittime=0;} + + #dhcp stuff -- inittime is set when xcatd on sn is started + unless (($args[0] eq 'stat') || ($inittime)) { + my $do_dhcpsetup=1; + my $sitetab = xCAT::Table->new('site'); + if ($sitetab) { + (my $ref) = $sitetab->getAttribs({key => 'dhcpsetup'}, 'value'); + if ($ref) { + if ($ref->{value} =~ /0|n|N/) { $do_dhcpsetup=0; } + } + } + + if ($do_dhcpsetup) { + if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command + $sub_req->({command=>['makedhcp'],arg=>['-l'], + node=>\@nodes},$callback); + } else { + $sub_req->({command=>['makedhcp'], + node=>\@nodes},$callback); + } + } + } + #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 $sub_req->({command=>['runendpre'], node=>\@nodes, - inittime=>[$inittime], - normalnodeset=>\@nodes, arg=>[$args[0], '-l']},\&pass_along); } else { #nodeset did not distribute to the service node, here we need to let runednpre to distribute the nodes to their masters $sub_req->({command=>['runendpre'], node=>\@rnodes, - normalnodeset=>\@nodes, - inittime=>[$inittime], arg=>[$args[0]]},\&pass_along); } if ($errored) { return; } diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index 10fc60b52..cf9f5ff21 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -188,7 +188,7 @@ sub setstate { my $errored = 0; sub pass_along { - print "pass_along\n"; + #print "pass_along\n"; my $resp = shift; $callback->($resp); if ($resp and ($resp->{errorcode} and $resp->{errorcode}->[0]) or ($resp->{error} and $resp->{error}->[0])) { @@ -403,6 +403,38 @@ sub process_request { my @normalnodeset = keys %normalnodes; my @breaknetboot=keys %breaknetbootnodes; #print "yaboot:inittime=$inittime; normalnodeset=@normalnodeset; breaknetboot=@breaknetboot\n"; + + #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time + unless (($args[0] eq 'stat') || ($inittime)) { + #dhcp stuff + my $do_dhcpsetup=1; + my $sitetab = xCAT::Table->new('site'); + if ($sitetab) { + (my $ref) = $sitetab->getAttribs({key => 'dhcpsetup'}, 'value'); + if ($ref) { + if ($ref->{value} =~ /0|n|N/) { $do_dhcpsetup=0; } + } + } + + if ($do_dhcpsetup) { + if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed + $sub_req->({command=>['makedhcp'],arg=>['-l'], + node=>\@normalnodeset},$callback); + } else { + $sub_req->({command=>['makedhcp'], + node=>\@normalnodeset},$callback); + } + if ($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); + } else { + $sub_req->({command=>['makedhcp'], + node=>\@breaknetboot, + arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback); + } + } + } #now run the end part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') @@ -410,16 +442,10 @@ sub process_request { if ($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, - inittime=>[$inittime], - normalnodeset=>\@normalnodeset, - breaknetboot=>\@breaknetboot, arg=>[$args[0], '-l']},\&pass_along); } else { #nodeset did not distribute to the service node, here we need to let runednpre to distribute the nodes to their masters $sub_req->({command=>['runendpre'], node=>\@rnodes, - inittime=>[$inittime], - normalnodeset=>\@normalnodeset, - breaknetboot=>\@breaknetboot, arg=>[$args[0]]},\&pass_along); } if ($errored) { return; }