Change to make the nodeset osimage=<osimage name> command to copy the install/netboot resources to /tftpboot/xcat/osimage/<osimage name>/ instead of /tftpboot/xcat/(netboot)/<os>/<arch>/<profile>/
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14845 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -250,6 +250,7 @@ sub mknetboot | ||||
|         my $rootfstype;  | ||||
|         my $tftpdir; | ||||
|         my $cfgpart; | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
|         if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{tftpdir}) { | ||||
| 		$tftpdir = $reshash->{$node}->[0]->{tftpdir}; | ||||
|         } else { | ||||
| @@ -259,7 +260,7 @@ sub mknetboot | ||||
|  | ||||
|         my $ent = $oents{$node}->[0]; #ostab->getNodeAttribs($node, ['os', 'arch', 'profile']); | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| 	        my $imagename=$ent->{provmethod}; | ||||
| 	        $imagename=$ent->{provmethod}; | ||||
| 	        #print "imagename=$imagename\n"; | ||||
| 	        if (!exists($img_hash{$imagename})) { | ||||
|         	    if (!$osimagetab) { | ||||
| @@ -334,7 +335,7 @@ sub mknetboot | ||||
|             $crashkernelsize = $ph->{crashkernelsize}; | ||||
|             $dump = $ph->{dump}; | ||||
|             $cfgpart = $ph->{'cfgpart'}; | ||||
| 	    } | ||||
| 	  } | ||||
|         else { | ||||
|             $osver = $ent->{os}; | ||||
|             $arch    = $ent->{arch}; | ||||
| @@ -349,7 +350,6 @@ sub mknetboot | ||||
|                 $imgname = "$osver-$arch-netboot-$profile"; | ||||
|             } | ||||
|  | ||||
|  | ||||
|             if (! $osimagetab) { | ||||
|                 $osimagetab = xCAT::Table->new('osimage'); | ||||
|             } | ||||
| @@ -427,18 +427,18 @@ sub mknetboot | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
| 	        if (!-r "$rootimgdir/initrd-statelite.gz") { | ||||
|             if (!-r "$rootimgdir/initrd-statelite.gz") { | ||||
|                 if (! -r "$rootimgdir/initrd.gz") { | ||||
|                     $callback->({ | ||||
|                         error=>[qq{Did you run "genimage" before running "liteimg"? initrd.gz or initrd-statelite.gz cannot be found}], | ||||
|                         errorcode=>[1] | ||||
| 				    }); | ||||
|             	    }); | ||||
|                     next; | ||||
|                 } | ||||
| 		        else { | ||||
| 		            copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-statelite.gz"); | ||||
|                 else { | ||||
|                     copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-statelite.gz"); | ||||
|                 } | ||||
| 	        }  | ||||
|             }  | ||||
|             if ( $rootfstype eq "ramdisk" and ! -r "$rootimgdir/rootimg-statelite.gz") { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{No packed image for platform $osver, architecture $arch and profile $profile, please run "liteimg" to create it.}], | ||||
| @@ -455,17 +455,16 @@ sub mknetboot | ||||
|                 next; | ||||
| 	        } | ||||
| 	        if (!-r "$rootimgdir/initrd-stateless.gz") { | ||||
|                 if (! -r "$rootimgdir/initrd.gz") { | ||||
|                     $callback->({ | ||||
|                         error=>[qq{Did you run "genimage" before running "packimage"? initrd.gz or initrd-stateless.gz cannot be found}], | ||||
|                         errorcode=>[1] | ||||
| 				    }); | ||||
|                     next; | ||||
|                 } | ||||
| 		        else { | ||||
| 		            copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); | ||||
|                 } | ||||
|             } | ||||
|                   if (! -r "$rootimgdir/initrd.gz") { | ||||
|                       $callback->({ | ||||
|                           error=>[qq{Did you run "genimage" before running "packimage"? initrd.gz or initrd-stateless.gz cannot be found}], | ||||
|                           errorcode=>[1] | ||||
|   				    }); | ||||
|                       next; | ||||
|                   } else { | ||||
|                       copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); | ||||
|                   } | ||||
|               } | ||||
| 	        unless ( -r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.sfs" ) { | ||||
|                 $callback->({ | ||||
|                     error=>["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (e.g.  packimage -o $osver -p $profile -a $arch"], | ||||
| @@ -478,47 +477,64 @@ sub mknetboot | ||||
|         #mkpath "/install/postscripts/"; | ||||
|         #xCAT::Postage->writescript($node,"/install/postscripts/".$node, "netboot", $callback); | ||||
|  | ||||
|         mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|  | ||||
|         #TODO: only copy if newer... | ||||
|         unless ($donetftp{$osver,$arch,$profile}) { | ||||
| 	        if (-f "$rootimgdir/hypervisor") { | ||||
|         	    copy("$rootimgdir/hypervisor", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
| 		        $xenstyle=1; | ||||
| 	        } | ||||
|             copy("$rootimgdir/kernel", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|         # Copy the boot resource to /tftpboot and check to only copy once | ||||
|         my $docopy = 0; | ||||
|         my $tftppath; | ||||
|         my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|         if ($imagename) { | ||||
|             $tftppath = "$tftpdir/xcat/osimage/$imagename"; | ||||
|             $rtftppath = "xcat/osimage/$imagename"; | ||||
|             unless ($donetftp{$imagename}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$imagename} = 1; | ||||
|             } | ||||
|         } else { | ||||
|             $tftppath = "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"; | ||||
|             $rtftppath = "xcat/netboot/$osver/$arch/$profile/"; | ||||
|             unless ($donetftp{$osver,$arch,$profile}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$osver,$arch,$profile} = 1; | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         if ($docopy) { | ||||
|             mkpath("$tftppath"); | ||||
|             if (-f "$rootimgdir/hypervisor") { | ||||
|                 copy("$rootimgdir/hypervisor", "$tftppath"); | ||||
|                 $xenstyle=1; | ||||
|             } | ||||
|             copy("$rootimgdir/kernel", "$tftppath"); | ||||
|             if ($statelite) { | ||||
|                 if($rootfstype eq "ramdisk") { | ||||
|                     copy("$rootimgdir/initrd-stateless.gz", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|                     copy("$rootimgdir/initrd-stateless.gz", "$tftppath"); | ||||
|                 } else { | ||||
|                     copy("$rootimgdir/initrd-statelite.gz", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|                     copy("$rootimgdir/initrd-statelite.gz", "$tftppath"); | ||||
|                 } | ||||
|             } else { | ||||
|                 copy("$rootimgdir/initrd-stateless.gz", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|                 copy("$rootimgdir/initrd-stateless.gz", "$tftppath"); | ||||
|             } | ||||
|             $donetftp{$osver,$arch,$profile} = 1; | ||||
|         } | ||||
|  | ||||
|         if ($statelite) { | ||||
|             my $initrdloc = "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"; | ||||
|             my $initrdloc = "$tftppath"; | ||||
|             if ($rootfstype eq "ramdisk") { | ||||
|                 $initrdloc .= "initrd-stateless.gz"; | ||||
|                 $initrdloc .= "/initrd-stateless.gz"; | ||||
|             } else { | ||||
|                 $initrdloc .= "initrd-statelite.gz"; | ||||
|                 $initrdloc .= "/initrd-statelite.gz"; | ||||
|             } | ||||
|             unless ( -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" | ||||
|             unless ( -r "$tftppath/kernel" | ||||
|                     and -r $initrdloc ) { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed}], | ||||
|                     error=>[qq{copying to $tftppath failed}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
|         } else { | ||||
|             unless ( -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" | ||||
|                     and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz") { | ||||
|             unless ( -r "$tftppath/kernel" | ||||
|                     and -r "$tftppath/initrd-stateless.gz") { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed}], | ||||
|                     error=>[qq{copying to $tftppath failed}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
| @@ -829,16 +845,16 @@ sub mknetboot | ||||
|             | ||||
|         #} | ||||
|          | ||||
| 	    my $kernstr="xcat/netboot/$osver/$arch/$profile/kernel"; | ||||
| 	    my $kernstr="$rtftppath/kernel"; | ||||
| 	    if ($xenstyle) { | ||||
| 	        $kernstr.= "!xcat/netboot/$osver/$arch/$profile/hypervisor"; | ||||
| 	        $kernstr.= "!$rtftppath/hypervisor"; | ||||
| 	    } | ||||
|         my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|         $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite); | ||||
|         my $initrdstr = "$rtftppath/initrd-stateless.gz"; | ||||
|         $initrdstr = "$rtftppath/initrd-statelite.gz" if ($statelite); | ||||
|         # special case for the dracut-enabled OSes | ||||
|         if (&using_dracut($osver)) { | ||||
|             if($statelite and $rootfstype eq "ramdisk") { | ||||
|                 $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|                 $initrdstr = "$rtftppath/initrd-stateless.gz"; | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -910,7 +926,7 @@ sub mkinstall | ||||
|  | ||||
|     my $node; | ||||
|     my $ostab = xCAT::Table->new('nodetype'); | ||||
|     my %doneimgs; | ||||
|     my %donetftp; | ||||
|     my $restab = xCAT::Table->new('noderes'); | ||||
|     my $bptab  = xCAT::Table->new('bootparams',-create=>1); | ||||
|     my $hmtab  = xCAT::Table->new('nodehm'); | ||||
| @@ -949,9 +965,9 @@ sub mkinstall | ||||
|         my $profile; | ||||
|         my $tmplfile; | ||||
|         my $pkgdir; | ||||
| 	my $pkglistfile; | ||||
| 	my $imagename; | ||||
| 	my $platform; | ||||
|         my $pkglistfile; | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
|         my $platform; | ||||
|         my $xcatmaster; | ||||
|         my $partfile; | ||||
|         my $netdrivers; | ||||
| @@ -1046,11 +1062,11 @@ sub mkinstall | ||||
| 	    $os = $ph->{osver}; | ||||
| 	    $arch  = $ph->{osarch}; | ||||
| 	    $profile = $ph->{profile}; | ||||
|         $partfile = $ph->{partitionfile}; | ||||
|           $partfile = $ph->{partitionfile}; | ||||
| 	    $platform=xCAT_plugin::anaconda::getplatform($os); | ||||
| 	 | ||||
| 	    $tmplfile=$ph->{template}; | ||||
|             $pkgdir=$ph->{pkgdir}; | ||||
|           $pkgdir=$ph->{pkgdir}; | ||||
| 	    if (!$pkgdir) { | ||||
| 		$pkgdir="$installroot/$os/$arch"; | ||||
| 	    } | ||||
| @@ -1176,8 +1192,6 @@ sub mkinstall | ||||
|                     ); | ||||
|             next; | ||||
|         } | ||||
|         #my $installdir="/install"; #TODO: not hardcode installdir | ||||
|         #my $tftpdir = "/tftpboot"; | ||||
|           | ||||
|         #To support multiple paths for osimage.pkgdir. We require the first value of osimage.pkgdir | ||||
|         # should be the os base pkgdir. | ||||
| @@ -1190,7 +1204,7 @@ sub mkinstall | ||||
|         my $kernpath; | ||||
|         my $initrdpath; | ||||
|         my $maxmem; | ||||
| 	my $esxi = 0; | ||||
| 	 my $esxi = 0; | ||||
|  | ||||
|         if ( | ||||
|             ( | ||||
| @@ -1230,26 +1244,36 @@ sub mkinstall | ||||
|                 and $initrdpath = "$pkgdir/ppc/ppc64/initrd.img"))) | ||||
|           ) | ||||
|         { | ||||
|  | ||||
|             #TODO: driver slipstream, targetted for network. | ||||
|             unless ($doneimgs{"$os|$arch|$profile|$tftpdir"}) | ||||
|             { | ||||
|                 mkpath("$tftpdir/xcat/$os/$arch"); | ||||
|             # Copy the install resource to /tftpboot and check to only copy once | ||||
|             my $docopy = 0; | ||||
|             my $tftppath; | ||||
|             my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|             if ($imagename) { | ||||
|                 $tftppath = "$tftpdir/xcat/osimage/$imagename"; | ||||
|                 $rtftppath = "xcat/osimage/$imagename"; | ||||
|                 unless ($donetftp{$imagename}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{$imagename} = 1; | ||||
|                 } | ||||
|             } else { | ||||
|                 $tftppath = "/$tftpdir/xcat/$os/$arch/$profile"; | ||||
|                 $rtftppath = "xcat/$os/$arch/$profile"; | ||||
|                 unless ($donetftp{"$os|$arch|$profile|$tftpdir"}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{"$os|$arch|$profile|$tftpdir"} = 1; | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             if ($docopy) { | ||||
|                 mkpath("$tftppath"); | ||||
|                 if($esxi){ | ||||
|                     copyesxiboot($pkgdir, "$tftpdir/xcat/$os/$arch",osver=>$os);		 | ||||
|                     copyesxiboot($pkgdir, "$tftppath", osver=>$os);		 | ||||
|                 }else{ | ||||
|                     my $tftppath; | ||||
|                     if ($profile) { | ||||
|                         $tftppath = "/$tftpdir/xcat/$os/$arch/$profile"; | ||||
|                     } else { | ||||
|                         $tftppath = "/$tftpdir/xcat/$os/$arch"; | ||||
|                     } | ||||
|                     mkpath ("$tftppath"); | ||||
|                     copy($kernpath,"$tftppath"); | ||||
|                     copy($initrdpath,"$tftppath/initrd.img"); | ||||
|                     &insert_dd($callback, $os, $arch, "$tftppath/initrd.img", $driverupdatesrc, $netdrivers); | ||||
|                 } | ||||
|                 $doneimgs{"$os|$arch|$profile|$tftpdir"} = 1; | ||||
|             } | ||||
|  | ||||
|             #We have a shot... | ||||
| @@ -1267,10 +1291,11 @@ sub mkinstall | ||||
|             if ($ent and $ent->{nfsserver}) { | ||||
| 	    	$instserver=$ent->{nfsserver}; | ||||
| 	    } | ||||
|  | ||||
|             my $kcmdline = | ||||
|                 "quiet repo=$httpmethod://$instserver:$httpport/install/$os/$arch/ ks=$httpmethod://" | ||||
|                 "quiet repo=$httpmethod://$instserver:$httpport$pkgdir ks=$httpmethod://" | ||||
|               . $instserver . ":". $httpport | ||||
|               . "/install/autoinst/" | ||||
|               . "$installroot/autoinst/" | ||||
|               . $node; | ||||
|             if ($maxmem) { | ||||
|                 $kcmdline.=" mem=$maxmem"; | ||||
| @@ -1357,21 +1382,16 @@ sub mkinstall | ||||
|             my $k; | ||||
|             my $i; | ||||
|             if($esxi){ | ||||
|                 $k = "xcat/$os/$arch/mboot.c32"; | ||||
|                 $k = "$rtftppath/mboot.c32"; | ||||
|                 $i = ""; | ||||
|                 my @addfiles = qw(vmkernel.gz sys.vgz cim.vgz ienviron.vgz install.vgz mod.tgz); | ||||
| 		$kcmdline = "xcat/$os/$arch/vmkboot.gz " . $kcmdline; | ||||
|                 $kcmdline = "$rtftppath/vmkboot.gz " . $kcmdline; | ||||
|                 foreach(@addfiles){ | ||||
|                     $kcmdline .= " --- xcat/$os/$arch/$_"; | ||||
|                     $kcmdline .= " --- $rtftppath/$_"; | ||||
|                 } | ||||
|             }else{ | ||||
|                 if ($profile) { | ||||
|                     $k = "xcat/$os/$arch/$profile/vmlinuz"; | ||||
|                     $i = "xcat/$os/$arch/$profile/initrd.img"; | ||||
|                 } else { | ||||
|                     $k = "xcat/$os/$arch/vmlinuz"; | ||||
|                     $i = "xcat/$os/$arch/initrd.img"; | ||||
|                 } | ||||
|                     $k = "$rtftppath/vmlinuz"; | ||||
|                     $i = "$rtftppath/initrd.img"; | ||||
|             } | ||||
|  | ||||
|             $bptab->setNodeAttribs( | ||||
| @@ -1387,7 +1407,7 @@ sub mkinstall | ||||
|         { | ||||
|             $callback->( | ||||
|                     { | ||||
|                      error => ["Install image not found in $installroot/$os/$arch"], | ||||
|                      error => ["Install image not found in $pkgdir"], | ||||
|                      errorcode => [1] | ||||
|                     } | ||||
|                     ); | ||||
|   | ||||
| @@ -404,7 +404,7 @@ sub mkinstall | ||||
|  | ||||
|     my $node; | ||||
|     my $ostab = xCAT::Table->new('nodetype'); | ||||
|     my %doneimgs; | ||||
|     my %donetftp; | ||||
|     my $restab = xCAT::Table->new('noderes'); | ||||
|     my $bptab  = xCAT::Table->new('bootparams',-create=>1); | ||||
|     my $hmtab  = xCAT::Table->new('nodehm'); | ||||
| @@ -443,14 +443,13 @@ sub mkinstall | ||||
|         my $tmplfile; | ||||
|         my $pkgdir; | ||||
|         my $pkglistfile; | ||||
|         my $imagename; | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
|         my $platform; | ||||
|  | ||||
|         my $osinst; | ||||
|         my $ent = $osents{$node}->[0]; #$ostab->getNodeAttribs($node, ['profile', 'os', 'arch']); | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| 	        $imagename=$ent->{provmethod}; | ||||
| 	        #print "imagename=$imagename\n"; | ||||
| 	        if (!exists($img_hash{$imagename})) { | ||||
| 		        if (!$osimagetab) { | ||||
| 		            $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
| @@ -671,12 +670,31 @@ sub mkinstall | ||||
| 		   ) | ||||
|        ){ | ||||
|             #TODO: driver slipstream, targetted for network. | ||||
|             unless ($doneimgs{"$os|$arch"}) | ||||
|             { | ||||
|                 mkpath("/tftpboot/xcat/$os/$arch"); | ||||
|                 copy($kernpath,"$tftpdir/xcat/$os/$arch/vmlinuz"); | ||||
|                 copy($initrdpath,"$tftpdir/xcat/$os/$arch/initrd.img"); | ||||
|                 $doneimgs{"$os|$arch"} = 1; | ||||
|  | ||||
|             # Copy the install resource to /tftpboot and check to only copy once | ||||
|             my $docopy = 0; | ||||
|             my $tftppath; | ||||
|             my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|             if ($imagename) { | ||||
|                 $tftppath = "$tftpdir/xcat/osimage/$imagename"; | ||||
|                 $rtftppath = "xcat/osimage/$imagename"; | ||||
|                 unless ($donetftp{$imagename}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{$imagename} = 1; | ||||
|                 } | ||||
|             } else { | ||||
|                 $tftppath = "/$tftpdir/xcat/$os/$arch/$profile"; | ||||
|                 $rtftppath = "xcat/$os/$arch/$profile"; | ||||
|                 unless ($donetftp{"$os|$arch"}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{"$os|$arch"} = 1; | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             if ($docopy) { | ||||
|                 mkpath("$tftppath"); | ||||
|                 copy($kernpath,"$tftppath/vmlinuz"); | ||||
|                 copy($initrdpath,"$tftppath/initrd.img"); | ||||
|             } | ||||
|  | ||||
|             #We have a shot... | ||||
| @@ -800,8 +818,8 @@ sub mkinstall | ||||
|             $bptab->setNodeAttribs( | ||||
|                                    $node, | ||||
|                                    { | ||||
|                                     kernel   => "xcat/$os/$arch/vmlinuz", | ||||
|                                     initrd   => "xcat/$os/$arch/initrd.img", | ||||
|                                     kernel   => "$rtftppath/vmlinuz", | ||||
|                                     initrd   => "$rtftppath/initrd.img", | ||||
|                                     kcmdline => $kcmdline | ||||
|                                    } | ||||
|                                    ); | ||||
| @@ -908,6 +926,8 @@ sub mknetboot | ||||
|         my $crashkernelsize; | ||||
|         my $rootfstype; | ||||
|         my $tftpdir; | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
|          | ||||
|         if ($reshash->{$node}->[0] and $reshash->{$node}->[0]->{tftpdir}) { | ||||
|                 $tftpdir = $reshash->{$node}->[0]->{tftpdir}; | ||||
|         } else { | ||||
| @@ -916,8 +936,7 @@ sub mknetboot | ||||
|  | ||||
|         my $ent = $oents{$node}->[0]; #ostab->getNodeAttribs($node, ['os', 'arch', 'profile']); | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| 	    my $imagename=$ent->{provmethod}; | ||||
| 	    #print "imagename=$imagename\n"; | ||||
| 	    $imagename=$ent->{provmethod}; | ||||
| 	    if (!exists($img_hash{$imagename})) { | ||||
| 		if (!$osimagetab) { | ||||
| 		    $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
| @@ -1094,55 +1113,66 @@ sub mknetboot | ||||
|         #mkpath "/install/postscripts/"; | ||||
|         #xCAT::Postage->writescript($node,"/install/postscripts/".$node, "netboot", $callback); | ||||
|  | ||||
|         mkpath("$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|  | ||||
|         #TODO: only copy if newer... | ||||
|         unless ($donetftp{$osver,$arch,$profile}) { | ||||
| 	  if (-f "$rootimgdir/hypervisor") { | ||||
|         	copy("$rootimgdir/hypervisor", | ||||
|              	"$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
| 		$xenstyle=1; | ||||
| 	  } | ||||
|           copy("$rootimgdir/kernel", | ||||
|                "$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|           if ($statelite) { | ||||
|               if ($rootfstype eq "ramdisk") { | ||||
|                  copy("$rootimgdir/initrd-stateless.gz",  | ||||
|                       "$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|               } else { | ||||
|                  copy("$rootimgdir/initrd-statelite.gz",  | ||||
|                       "$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|               } | ||||
|           } else { | ||||
|               copy("$rootimgdir/initrd-stateless.gz",  | ||||
|                    "$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|           } | ||||
|             $donetftp{$osver,$arch,$profile} = 1; | ||||
|         } | ||||
|         if ($statelite) { | ||||
|             my $initrdloc = "$tftpdir/xcat/netboot/$osver/$arch/$profile/"; | ||||
|             if ($rootfstype eq "ramdisk") { | ||||
|                 $initrdloc .= "initrd-stateless.gz"; | ||||
|             } else { | ||||
|                 $initrdloc .= "initrd-statelite.gz"; | ||||
|         # Copy the boot resource to /tftpboot and check to only copy once | ||||
|         my $docopy = 0; | ||||
|         my $tftppath; | ||||
|         my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|         if ($imagename) { | ||||
|             $tftppath = "$tftpdir/xcat/osimage/$imagename"; | ||||
|             $rtftppath = "xcat/osimage/$imagename"; | ||||
|             unless ($donetftp{$imagename}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$imagename} = 1; | ||||
|             } | ||||
|             unless ( -r "$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" | ||||
|                     and -r $initrdloc ) { | ||||
|         } else { | ||||
|             $tftppath = "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"; | ||||
|             $rtftppath = "xcat/netboot/$osver/$arch/$profile/"; | ||||
|             unless ($donetftp{$osver,$arch,$profile}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$osver,$arch,$profile} = 1; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($docopy) { | ||||
|             mkpath("$tftppath"); | ||||
|             if (-f "$rootimgdir/hypervisor") { | ||||
|                 copy("$rootimgdir/hypervisor", "$tftppath"); | ||||
|                 $xenstyle=1; | ||||
|             } | ||||
|             copy("$rootimgdir/kernel", "$tftppath"); | ||||
|             if ($statelite) { | ||||
|                if ($rootfstype eq "ramdisk") { | ||||
|                   copy("$rootimgdir/initrd-stateless.gz", "$tftppath"); | ||||
|                } else { | ||||
|                   copy("$rootimgdir/initrd-statelite.gz", "$tftppath"); | ||||
|                } | ||||
|             } else { | ||||
|                copy("$rootimgdir/initrd-stateless.gz", "$tftppath"); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         if ($statelite) { | ||||
|             my $initrdloc = "$tftppath"; | ||||
|             if ($rootfstype eq "ramdisk") { | ||||
|                 $initrdloc .= "/initrd-stateless.gz"; | ||||
|             } else { | ||||
|                 $initrdloc .= "/initrd-statelite.gz"; | ||||
|             } | ||||
|             unless ( -r "$tftppath/kernel" and -r $initrdloc ) { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{copying to $tftpdir/xcat/netboot/$osver/$arch/$profile failed}], | ||||
|                     error=>[qq{copying to $tftppath failed}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
|         } else { | ||||
|  | ||||
|           unless (    -r "$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel" | ||||
|                   and -r "$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz") | ||||
|           unless (    -r "$tftppath/kernel" and -r "$tftppath/initrd-stateless.gz") | ||||
|           { | ||||
|             $callback->( | ||||
|                 { | ||||
|                  error => [ | ||||
|                      "Copying to $tftpdir/xcat/netboot/$osver/$arch/$profile failed" | ||||
|                      "Copying to $tftppath failed" | ||||
|                  ], | ||||
|                  errorcode => [1] | ||||
|                 } | ||||
| @@ -1384,16 +1414,16 @@ sub mknetboot | ||||
|             | ||||
|         #} | ||||
|          | ||||
| 	my $kernstr="xcat/netboot/$osver/$arch/$profile/kernel"; | ||||
| 	my $kernstr="$rtftppath/kernel"; | ||||
| 	if ($xenstyle) { | ||||
| 	   $kernstr.= "!xcat/netboot/$osver/$arch/$profile/hypervisor"; | ||||
| 	   $kernstr.= "!$rtftppath/hypervisor"; | ||||
| 	} | ||||
|         my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|         $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite); | ||||
|         my $initrdstr = "$rtftppath/initrd-stateless.gz"; | ||||
|         $initrdstr = "$rtftppath/initrd-statelite.gz" if ($statelite); | ||||
|         # special case for the dracut-enabled OSes | ||||
|         if (&using_dracut($osver)) { | ||||
|             if($statelite and $rootfstype eq "ramdisk") { | ||||
|                 $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|                 $initrdstr = "$rtftppath/initrd-stateless.gz"; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -128,11 +128,11 @@ sub mknetboot | ||||
|         my $crashkernelsize; | ||||
|         my $rootfstype; | ||||
|         my $cfgpart; | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
| 	 | ||||
|         my $ent= $ntents->{$node}->[0]; | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
|             my $imagename=$ent->{provmethod}; | ||||
|             #print "imagename=$imagename\n"; | ||||
|             $imagename=$ent->{provmethod}; | ||||
|             if (!exists($img_hash{$imagename})) { | ||||
|                 if (!$osimagetab) { | ||||
|                     $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
| @@ -367,33 +367,49 @@ sub mknetboot | ||||
|         } | ||||
|  | ||||
|  | ||||
|         mkpath("/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|  | ||||
|         #TODO: only copy if newer... | ||||
|         unless ($donetftp{$osver,$arch,$profile,$tftpdir}) { | ||||
|             copy("$rootimgdir/kernel", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|             if ($statelite) { | ||||
|                 copy("$rootimgdir/initrd-statelite.gz", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|             } else { | ||||
|                 copy("$rootimgdir/initrd-stateless.gz", "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"); | ||||
|         # Copy the boot resource to /tftpboot and check to only copy once | ||||
|         my $docopy = 0; | ||||
|         my $tftppath; | ||||
|         my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|         if ($imagename) { | ||||
|             $tftppath = "$tftpdir/xcat/osimage/$imagename"; | ||||
|             $rtftppath = "xcat/osimage/$imagename"; | ||||
|             unless ($donetftp{$imagename}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$imagename} = 1; | ||||
|             } | ||||
|         } else { | ||||
|             $tftppath = "/$tftpdir/xcat/netboot/$osver/$arch/$profile/"; | ||||
|             $rtftppath = "xcat/netboot/$osver/$arch/$profile/"; | ||||
|             unless ($donetftp{$osver,$arch,$profile,$tftpdir}) { | ||||
|                 $docopy = 1; | ||||
|                 $donetftp{$osver,$arch,$profile,$tftpdir} = 1; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($docopy) { | ||||
|             mkpath("$tftppath"); | ||||
|             copy("$rootimgdir/kernel", "$tftppath"); | ||||
|             if ($statelite) { | ||||
|                 copy("$rootimgdir/initrd-statelite.gz", "$tftppath"); | ||||
|             } else { | ||||
|                 copy("$rootimgdir/initrd-stateless.gz", "$tftppath"); | ||||
|             } | ||||
|             $donetftp{$osver,$arch,$profile,$tftpdir} = 1; | ||||
|         } | ||||
|  | ||||
|         if ($statelite) { | ||||
|             unless ( -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel"  | ||||
|                     and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz") { | ||||
|             unless ( -r "$tftppath/kernel" and -r "$tftppath/initrd-statelite.gz" ) { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed}], | ||||
|                     error=>[qq{copying to $tftppath failed}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
|             } | ||||
|         } else { | ||||
|             unless ( -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/kernel"  | ||||
|                     and -r "/$tftpdir/xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz") { | ||||
|             unless ( -r "$tftppath/kernel"  | ||||
|                     and -r "$tftppath/initrd-stateless.gz") { | ||||
|                 $callback->({ | ||||
|                     error=>[qq{copying to /$tftpdir/xcat/netboot/$osver/$arch/$profile failed}], | ||||
|                     error=>[qq{copying to $tftppath failed}], | ||||
|                     errorcode=>[1] | ||||
|                 }); | ||||
|                 next; | ||||
| @@ -599,8 +615,8 @@ sub mknetboot | ||||
|             $kcmdline .= " PARTITION"; | ||||
|         } | ||||
|  | ||||
|         my $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-stateless.gz"; | ||||
|         $initrdstr = "xcat/netboot/$osver/$arch/$profile/initrd-statelite.gz" if ($statelite); | ||||
|         my $initrdstr = "$rtftppath/initrd-stateless.gz"; | ||||
|         $initrdstr = "$rtftppath/initrd-statelite.gz" if ($statelite); | ||||
|  | ||||
|         if($statelite) | ||||
|         { | ||||
| @@ -615,7 +631,7 @@ sub mknetboot | ||||
|         $bptab->setNodeAttribs( | ||||
|             $node, | ||||
|             { | ||||
|             kernel => "xcat/netboot/$osver/$arch/$profile/kernel", | ||||
|             kernel => "$rtftppath/kernel", | ||||
|             initrd => $initrdstr, | ||||
|             kcmdline => $kcmdline | ||||
|             }); | ||||
| @@ -689,7 +705,7 @@ sub mkinstall | ||||
|         } | ||||
|     #} | ||||
|  | ||||
|     my %doneimgs; | ||||
|     my %donetftp; | ||||
|     require xCAT::Template; #only used here, load so memory can be COWed | ||||
|     # Define a variable for driver update list | ||||
|     my @dd_drivers; | ||||
| @@ -718,23 +734,23 @@ sub mkinstall | ||||
|         my $profile; | ||||
|         my $tmplfile; | ||||
|         my $pkgdir; | ||||
| 	my $pkglistfile; | ||||
|         my $pkglistfile; | ||||
|         my $osinst; | ||||
|         my $ent = $ntents->{$node}->[0]; | ||||
| 	my $plat = ""; | ||||
|         my $plat = ""; | ||||
|         my $tftpdir; | ||||
|         my $partfile; | ||||
|         my $netdrivers; | ||||
|         my $driverupdatesrc; | ||||
|  	if ($resents->{$node} and $resents->{$node}->[0]->{tftpdir}) { | ||||
|         my $imagename; # set it if running of 'nodeset osimage=xxx' | ||||
|         if ($resents->{$node} and $resents->{$node}->[0]->{tftpdir}) { | ||||
| 	   $tftpdir = $resents->{$node}->[0]->{tftpdir}; | ||||
|         } else { | ||||
| 	   $tftpdir = $globaltftpdir; | ||||
|         } | ||||
|  | ||||
|         if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) { | ||||
| 	    my $imagename=$ent->{provmethod}; | ||||
| 	    #print "imagename=$imagename\n"; | ||||
| 	    $imagename=$ent->{provmethod}; | ||||
| 	    if (!exists($img_hash{$imagename})) { | ||||
| 		if (!$osimagetab) { | ||||
| 		    $osimagetab=xCAT::Table->new('osimage', -create=>1); | ||||
| @@ -864,7 +880,6 @@ sub mkinstall | ||||
|         my @srcdirs = split(",", $pkgdir); | ||||
|         $pkgdir = $srcdirs[0]; | ||||
|  | ||||
|  | ||||
|         #Call the Template class to do substitution to produce a kickstart file in the autoinst dir | ||||
|         my $tmperr; | ||||
|         if (-r "$tmplfile") | ||||
| @@ -916,17 +931,29 @@ sub mkinstall | ||||
|             or ($arch =~ /ppc/ and -r "$pkgdir/1/suseboot/inst64") | ||||
|           ) | ||||
|         { | ||||
|  | ||||
|  | ||||
|             #TODO: driver slipstream, targetted for network. | ||||
|             unless ($doneimgs{"$os|$arch|$profile|$tftpdir"}) | ||||
|             { | ||||
|                 my $tftppath; | ||||
|                 if ($profile) { | ||||
|                     $tftppath = "/$tftpdir/xcat/$os/$arch/$profile"; | ||||
|                 } else { | ||||
|                     $tftppath = "/$tftpdir/xcat/$os/$arch"; | ||||
|              | ||||
|             # Copy the install resource to /tftpboot and check to only copy once | ||||
|             my $docopy = 0; | ||||
|             my $tftppath; | ||||
|             my $rtftppath; # the relative tftp path without /tftpboot/ | ||||
|             if ($imagename) { | ||||
|                 $tftppath = "/$tftpdir/xcat/osimage/$imagename"; | ||||
|                 $rtftppath = "xcat/osimage/$imagename"; | ||||
|                 unless ($donetftp{$imagename}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{$imagename} = 1; | ||||
|                 } | ||||
|             } else { | ||||
|                 $tftppath = "/$tftpdir/xcat/$os/$arch/$profile"; | ||||
|                 $rtftppath = "xcat/$os/$arch/$profile"; | ||||
|                 unless ($donetftp{"$os|$arch|$profile|$tftpdir"}) { | ||||
|                     $docopy = 1; | ||||
|                     $donetftp{"$os|$arch|$profile|$tftpdir"} = 1; | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             if ($docopy) { | ||||
|                 mkpath("$tftppath"); | ||||
|                 if ($arch =~ /x86_64/) | ||||
|                 { | ||||
| @@ -943,7 +970,6 @@ sub mkinstall | ||||
|                     copy("$pkgdir/1/suseboot/inst64", "$tftppath"); | ||||
|                     @dd_drivers = &insert_dd($callback, $os, $arch, "$tftppath/inst64", $driverupdatesrc, $netdrivers); | ||||
|                 } | ||||
|                 $doneimgs{"$os|$arch|$profile|$tftpdir"} = 1; | ||||
|             } | ||||
|  | ||||
|             #We have a shot... | ||||
| @@ -963,11 +989,11 @@ sub mkinstall | ||||
|             my $kcmdline = | ||||
|                 "quiet autoyast=$httpmethod://" | ||||
|               . $netserver . ":" . $httpport | ||||
|               . "/install/autoinst/" | ||||
|               . "$installroot/autoinst/" | ||||
|               . $node | ||||
|               . " install=$httpmethod://" | ||||
|               . $netserver . ":" . $httpport | ||||
|               . "/install/$os/$arch/1"; | ||||
|               . "$pkgdir/1"; | ||||
|  | ||||
|             my $netdev = ""; | ||||
|             if ($ent->{installnic}) | ||||
| @@ -1054,13 +1080,8 @@ sub mkinstall | ||||
|              | ||||
|             if ($arch =~ /x86/) | ||||
|             { | ||||
|                 if ($profile) { | ||||
|                     $kernelpath = "xcat/$os/$arch/$profile/linux"; | ||||
|                     $initrdpath = "xcat/$os/$arch/$profile/initrd"; | ||||
|                 } else { | ||||
|                     $kernelpath = "xcat/$os/$arch/linux"; | ||||
|                     $initrdpath = "xcat/$os/$arch/initrd"; | ||||
|                 } | ||||
|                 $kernelpath = "$rtftppath/linux"; | ||||
|                 $initrdpath = "$rtftppath/initrd"; | ||||
|                 $bptab->setNodeAttribs( | ||||
|                                         $node, | ||||
|                                         { | ||||
| @@ -1072,11 +1093,7 @@ sub mkinstall | ||||
|             } | ||||
|             elsif ($arch =~ /ppc/) | ||||
|             { | ||||
|                 if ($profile) { | ||||
|                     $kernelpath = "xcat/$os/$arch/$profile/inst64"; | ||||
|                 } else { | ||||
|                     $kernelpath = "xcat/$os/$arch/inst64"; | ||||
|                 } | ||||
|                 $kernelpath = "$rtftppath/inst64"; | ||||
|                 $bptab->setNodeAttribs( | ||||
|                                         $node, | ||||
|                                         { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user