From 87bdbd136fdfb7ede086c08d5b06159f6ca554da Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 28 Mar 2009 15:03:36 +0000 Subject: [PATCH] -Fix nodeset at tftp setup time, and prevent makedhcp from farming out when nodeset was already farmed out git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3032 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/AAsn.pm | 2 +- xCAT-server/lib/xcat/plugins/dhcp.pm | 5 +++++ xCAT-server/lib/xcat/plugins/pxe.pm | 6 +++--- xCAT-server/lib/xcat/plugins/yaboot.pm | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/AAsn.pm b/xCAT-server/lib/xcat/plugins/AAsn.pm index cbb93a857..bad7339f6 100644 --- a/xCAT-server/lib/xcat/plugins/AAsn.pm +++ b/xCAT-server/lib/xcat/plugins/AAsn.pm @@ -965,7 +965,7 @@ sub setup_TFTP } } $cmdref->{command}->[0] = "nodeset"; - $cmdref->{localonly}->[0] = "1"; + $cmdref->{inittime}->[0] = "1"; $cmdref->{arg}->[0] = "enact"; $cmdref->{cwd}->[0] = "/opt/xcat/sbin"; my $plugins_dir=$::XCATROOT.'/lib/perl/xCAT_plugin'; diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 4d5467320..ad62a6b98 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -12,6 +12,7 @@ use Sys::Syslog; use IPC::Open2; use xCAT::Utils; use xCAT::NodeRange; +use Fcntl ':flock'; my @dhcpconf; #Hold DHCP config file contents to be written back. my @nrn; # To hold output of networks table to be consulted throughout process @@ -428,6 +429,9 @@ sub process_request return; } + my $dhcplockfd; + open($dhcplockfd,"/tmp/xcat/dhcplock"); + flock($dhcplockfd,LOCK_EX); if (grep /^-n$/, @{$req->{arg}}) { if (-e "/etc/dhcpd.conf") @@ -637,6 +641,7 @@ sub process_request system("/etc/init.d/dhcpd restart"); system("chkconfig dhcpd on"); } + flock($dhcplockfd,LOCK_UN); umask $oldmask; } diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 8a46a9340..e682f962b 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -189,7 +189,7 @@ sub preprocess_request { my $sent = $stab->getAttribs({key=>'sharedtftp'},'value'); if ($sent and ($sent->{value} == 0 or $sent->{value} =~ /no/i)) { $req->{'_disparatetftp'}=[1]; - if ($req->{localonly}->[0]) { + if ($req->{inittime}->[0]) { return [$req]; } return xCAT::Scope->get_broadcast_scope($req,@_); @@ -341,9 +341,9 @@ sub process_request { } } } - unless ($sub_req) { return; } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time + if ($request->{inittime}->[0]) { return; } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time if ($args[0] ne 'stat') { - if ($req->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command + if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command $sub_req->({command=>['makedhcp'],arg=>['-l'], node=>\@nodes},$callback); } else { diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index aaff1880c..3502dc5fe 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -191,7 +191,7 @@ sub preprocess_request { my $sent = $stab->getAttribs({key=>'sharedtftp'},'value'); if ($sent and ($sent->{value} == 0 or $sent->{value} =~ /no/i)) { $req->{'_disparatetftp'}=[1]; - if ($req->{localonly}->[0]) { + if ($req->{inittime}->[0]) { return [$req]; } return xCAT::Scope->get_broadcast_scope($req,@_); @@ -322,9 +322,9 @@ sub process_request { } } } - unless ($sub_req) { return; } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time + if ($request->{inittime}->[0]) { return; } #Don't bother to try dhcp binding changes if sub_req not passed, i.e. service node build time my @normalnodeset = keys %normalnodes; - if ($req->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command, only change local settings if already farmed + 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 { @@ -332,7 +332,7 @@ sub process_request { node=>\@normalnodeset},$callback); } my @breaknetboot=keys %breaknetbootnodes; - if ($req->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command + 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);