From a84a9e655bb955ec3071bb3fed93478205008913 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 12 May 2015 01:36:55 -0400 Subject: [PATCH] appending "statement" within makedhcp rather than from nodeset, this commit include grub2,petitboot and nimol netboot method --- xCAT-server/lib/xcat/plugins/dhcp.pm | 8 +++++++ xCAT-server/lib/xcat/plugins/grub2.pm | 23 +++++++++++++------ xCAT-server/lib/xcat/plugins/nimol.pm | 27 +++++++++++++---------- xCAT-server/lib/xcat/plugins/petitboot.pm | 25 +++++++++------------ 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 1dd8406a1..8f79aed18 100755 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -616,6 +616,14 @@ sub addnode $lstatements = 'if option vendor-class-identifier = \"ScaleMP\" { filename = \"vsmp/pxelinux.0\"; } else { filename = \"pxelinux.0\"; }'.$lstatements; } } + } elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'yaboot') { + $lstatements = 'filename = \"/yb/node/yaboot-'.$node.'\";'.$lstatements; + } elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'grub2') { + $lstatements = 'filename = \"/boot/grub2/grub2-'.$node.'\";'.$lstatements; + } elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'petitboot') { + $lstatements = 'option conf-file \"http://'.$nxtsrv.'/tftpboot/petitboot/'.$node.'\";'.$lstatements; + } elsif ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'nimol') { + $lstatements = 'supersede server.filename=\"/vios/nodes/'.$node.'\"'.$lstatements; } diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index 1b75a24a0..c3b128b48 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -580,27 +580,36 @@ sub process_request { xCAT::MsgUtils->message("E", $rsp, $callback); return; } + chdir("$tftpdir/boot/grub2/"); + foreach my $tmp_node (@{$osimagenodehash{$osimage}}) { + unless (-e "grub2-$tmp_node") { + symlink("grub2.".$validarch, "grub2-$tmp_node"); + } + } if ($do_dhcpsetup) { if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command $sub_req->({command=>['makedhcp'], - node=>\@{$osimagenodehash{$osimage}}, - arg=>['-l','-s','filename = \"'.$grub2.'\";']},$callback); + node=>\@{$osimagenodehash{$osimage}}}, $callback); } else { $sub_req->({command=>['makedhcp'], - node=>\@{$osimagenodehash{$osimage}}, - arg=>['-s','filename = \"'.$grub2.'\";']},$callback); + node=>\@{$osimagenodehash{$osimage}}},$callback); } } } #end of foreach osimagenodehash + + foreach my $tmp_node (@breaknetboot) { + if (-e "$tftpdir/boot/grub2/grub2-$tmp_node") { + unlink("$tftpdir/boot/grub2/grub2-$tmp_node"); + } + } if ($do_dhcpsetup) { 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); + arg=>['-l']},$callback); } else { $sub_req->({command=>['makedhcp'], - node=>\@breaknetboot, - arg=>['-s','filename = \"xcat/nonexistant_file_to_intentionally_break_netboot_for_localboot_to_work\";']},$callback); + node=>\@breaknetboot},$callback); } } } diff --git a/xCAT-server/lib/xcat/plugins/nimol.pm b/xCAT-server/lib/xcat/plugins/nimol.pm index 46f206364..ae02590fc 100644 --- a/xCAT-server/lib/xcat/plugins/nimol.pm +++ b/xCAT-server/lib/xcat/plugins/nimol.pm @@ -409,8 +409,13 @@ sub create_imgconf_file { my $subreq = shift; my $nim_root = shift; my $bootimg_root = shift; - my $relative_path = $bootimg_root; + my $bootimg_link = "/tftpboot/vios/nodes"; + my $relative_path = $bootimg_link; $relative_path =~ s/^\/tftpboot//; + # check the dir where the bootimage link file and bootimage configuration file stored + unless (-e $bootimg_link) { + mkpath($bootimg_link); + } # Get nodes network information my %nethash = (); %nethash = xCAT::DBobjUtils->getNetwkInfo($nodes); @@ -428,7 +433,7 @@ sub create_imgconf_file { unless (-e $bootimg_root."/viobootimg") { return "Unable to find VIOS bootimg file"; } - chdir($bootimg_root); + chdir($bootimg_link); foreach my $node (@$nodes) { my $bootimg_conf_fd; my $gateway = $nethash{$node}{gateway}; @@ -438,18 +443,17 @@ sub create_imgconf_file { my $master = xCAT::NetworkUtils->gethostname($master_node); my $master_ip = xCAT::NetworkUtils->getipaddr($master); my $node_ip = xCAT::NetworkUtils->getipaddr($node); - my $relative_bootfile = $relative_path."/viobootimg-$node"; - unless (-e "viobootimg-$node") { - symlink("viobootimg", "viobootimg-$node"); + unless (-e "$node") { + symlink($bootimg_root."/viobootimg", "$node"); } - if (-e $bootimg_root."/viobootimg-$node.info") { - unlink($bootimg_root."/viobootimg-$node.info"); + if (-e $bootimg_link."/$node.info") { + unlink($bootimg_link."/$node.info"); } - open ($bootimg_conf_fd, ">", $bootimg_root."/viobootimg-$node.info"); + open ($bootimg_conf_fd, ">", $bootimg_link."/$node.info"); print $bootimg_conf_fd "export NIM_SERVER_TYPE=linux\n"; print $bootimg_conf_fd "export NIM_SYSLOG_PORT=514\n"; print $bootimg_conf_fd "export NIM_SYSLOG_FACILITY=local2\n"; - print $bootimg_conf_fd "export NIM_NAME=viobootimg-$node\n"; + print $bootimg_conf_fd "export NIM_NAME=$node\n"; print $bootimg_conf_fd "export NIM_HOSTNAME=$node\n"; print $bootimg_conf_fd "export NIM_CONFIGURATION=standalone\n"; print $bootimg_conf_fd "export NIM_MASTER_HOSTNAME=$master\n"; @@ -472,8 +476,7 @@ sub create_imgconf_file { close($bootimg_conf_fd); $subreq->({command=>['makedhcp'], - node=>[$node], - arg=>['-s', 'supersede server.filename=\"'.$relative_bootfile.'\";']}, $global_callback); + node=>[$node]}, $global_callback); } } @@ -506,7 +509,7 @@ sub nodeset { if ($ref) { if ($ref->{provmethod} and $ref->{provmethod} eq 'nimol' and $ref->{osdistroname}) { $nim_root = $installroot."/nim/".$ref->{osdistroname}; - $bootimg_root = "/tftpboot/".$ref->{osdistroname}."/nodes"; + $bootimg_root = "/tftpboot/".$ref->{osdistroname}; } else { $callback->({error=>["The 'provmethod' for OS image $osimage can only be 'nimol'."], errorcode=>[1]}); return; diff --git a/xCAT-server/lib/xcat/plugins/petitboot.pm b/xCAT-server/lib/xcat/plugins/petitboot.pm index 21ab4c9ce..789eaf385 100644 --- a/xCAT-server/lib/xcat/plugins/petitboot.pm +++ b/xCAT-server/lib/xcat/plugins/petitboot.pm @@ -472,24 +472,19 @@ sub process_request { if (defined($t_entry) ) { if ($t_entry =~ /0|n|N/) { $do_dhcpsetup=0; } } - if ($do_dhcpsetup) { foreach my $node (@normalnodeset) { - my $server = xCAT::TableUtils->GetMasterNodeName($node); - my $ipfn = xCAT::NetworkUtils->my_ip_facing($server); - if(($server != 1) and defined($ipfn)) { - my $fpath = "http://$ipfn/tftpboot/petitboot/$node"; - if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command - $sub_req->({command=>['makedhcp'], - node=> [$node], - arg=>['-l','-s','option conf-file \"'.$fpath.'\";']},$callback); - } else { - $sub_req->({command=>['makedhcp'], - node=> [$node], - arg=>['-s','option conf-file \"'.$fpath.'\";']},$callback); - } + if ($request->{'_disparatetftp'}->[0]) { #reading hint from preprocess_command + $sub_req->({command=>['makedhcp'], + node=> [$node], + arg=>['-l']},$callback); + #arg=>['-l','-s','option conf-file \"'.$fpath.'\";']},$callback); + } else { + $sub_req->({command=>['makedhcp'], + node=> [$node]}, $callback); + #arg=>['-s','option conf-file \"'.$fpath.'\";']},$callback); } - } + } } }