mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	defect 3370506: make copycds command to generate the osimage obj for the stateless and statelite
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10136 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -734,82 +734,105 @@ sub  update_tables_with_diskless_image | ||||
|     my $osimagetab; | ||||
|     my $linuximagetab; | ||||
|  | ||||
|     #get the pkglist file | ||||
|     my $pkglistfile=get_pkglist_file_name($cuspath, $profile, $osver, $arch); | ||||
|     if (!$pkglistfile) { $pkglistfile=get_pkglist_file_name($defpath, $profile, $osver, $arch);} | ||||
|     #print "pkglistfile=$pkglistfile\n"; | ||||
|     if (!$pkglistfile) { return (0, "");} | ||||
|      | ||||
|     #get otherpkgs.pkglist file | ||||
|     my $otherpkgsfile=get_otherpkgs_pkglist_file_name($cuspath, $profile, $osver, $arch); | ||||
|     if (!$otherpkgsfile) { $otherpkgsfile=get_otherpkgs_pkglist_file_name($defpath, $profile, $osver, $arch);} | ||||
|      | ||||
|     #get synclist file | ||||
|     my $synclistfile=xCAT::SvrUtils->getsynclistfile(undef, $osver, $arch, $profile, "netboot"); | ||||
|      | ||||
|     #get the exlist file | ||||
|     my $exlistfile=get_exlist_file_name($cuspath, $profile, $osver, $arch); | ||||
|     if (!$exlistfile) {  $exlistfile=get_exlist_file_name($defpath, $profile, $osver, $arch); } | ||||
|  | ||||
|     #get postinstall script file name | ||||
|     my $postfile=get_postinstall_file_name($cuspath, $profile, $osver, $arch); | ||||
|     if (!$postfile) {  $postfile=get_postinstall_file_name($defpath, $profile, $osver, $arch); } | ||||
|  | ||||
|  | ||||
|     #now update the db | ||||
|     if (!$osimagetab) {  | ||||
| 	$osimagetab=xCAT::Table->new('osimage',-create=>1);  | ||||
|     my %profiles=(); | ||||
|     if ($profile) { | ||||
|         $profiles{$profile} = 1; | ||||
|     } else { | ||||
|         my @tmplfiles=glob($cuspath."/*.pkglist"); | ||||
|         foreach (@tmplfiles) { | ||||
|             my $tmpf=basename($_);  | ||||
|             #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' | ||||
|             $tmpf =~ /^([^\.]*)\..*$/; | ||||
|             $tmpf = $1; | ||||
|             $profiles{$tmpf}=1; | ||||
|         } | ||||
|         @tmplfiles=glob($defpath."/*.pkglist"); | ||||
|         foreach (@tmplfiles) { | ||||
|             my $tmpf=basename($_);  | ||||
|             #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' | ||||
|             $tmpf =~ /^([^\.]*)\..*$/; | ||||
|             $tmpf = $1; | ||||
|             $profiles{$tmpf}=1; | ||||
|         } | ||||
|     } | ||||
|     foreach my $profile (keys %profiles) { | ||||
|         #get the pkglist file | ||||
|         my $pkglistfile=get_pkglist_file_name($cuspath, $profile, $osver, $arch); | ||||
|         if (!$pkglistfile) { $pkglistfile=get_pkglist_file_name($defpath, $profile, $osver, $arch);} | ||||
|         #print "pkglistfile=$pkglistfile\n"; | ||||
|         if (!$pkglistfile) { next;} | ||||
|          | ||||
|         #get otherpkgs.pkglist file | ||||
|         my $otherpkgsfile=get_otherpkgs_pkglist_file_name($cuspath, $profile, $osver, $arch); | ||||
|         if (!$otherpkgsfile) { $otherpkgsfile=get_otherpkgs_pkglist_file_name($defpath, $profile, $osver, $arch);} | ||||
|          | ||||
|         #get synclist file | ||||
|         my $synclistfile=xCAT::SvrUtils->getsynclistfile(undef, $osver, $arch, $profile, "netboot"); | ||||
|          | ||||
|         #get the exlist file | ||||
|         my $exlistfile=get_exlist_file_name($cuspath, $profile, $osver, $arch); | ||||
|         if (!$exlistfile) {  $exlistfile=get_exlist_file_name($defpath, $profile, $osver, $arch); } | ||||
|      | ||||
|     if ($osimagetab) {     | ||||
| 	#check if the image is already in the table | ||||
| 	if ($osimagetab) { | ||||
| 	    my $found=0; | ||||
| 	    my $tmp1=$osimagetab->getAllEntries(); | ||||
| 	    if (defined($tmp1) && (@$tmp1 > 0)) { | ||||
| 		foreach my $rowdata(@$tmp1) { | ||||
| 		    if (($osver eq $rowdata->{osvers}) && ($arch eq $rowdata->{osarch}) && ($rowdata->{provmethod} eq $provm) && ($profile eq $rowdata->{profile})){ | ||||
| 			$found=1; | ||||
| 			last; | ||||
| 		    } | ||||
| 		} | ||||
| 	    } | ||||
| 	    if ($found) { print "The image is already in the db.\n"; return (0, ""); }  | ||||
| 	     | ||||
| 	    my $imagename=$osver . "-" . $arch . "-$provm-" . $profile; | ||||
| 	    #TODO: check if there happen to be a row that has the same imagename but with different contents | ||||
| 	    #now we can wirte the info into db | ||||
| 	    my %key_col = (imagename=>$imagename); | ||||
| 	    my %tb_cols=(imagetype=>$imagetype,  | ||||
| 			 provmethod=>$provm, | ||||
| 			 profile=>$profile,  | ||||
| 			 osname=>$ostype, | ||||
| 			 osvers=>$osver, | ||||
| 			 osarch=>$arch, | ||||
| 			 synclists=>$synclistfile); | ||||
| 	    $osimagetab->setAttribs(\%key_col, \%tb_cols); | ||||
| 	     | ||||
| 	    if ($osname !~ /^win/) { | ||||
| 		if (!$linuximagetab) { $linuximagetab=xCAT::Table->new('linuximage',-create=>1); } | ||||
| 		if ($linuximagetab) { | ||||
| 		    my %key_col = (imagename=>$imagename); | ||||
| 		    my %tb_cols=(pkglist=>$pkglistfile,  | ||||
| 				 pkgdir=>"$installroot/$osver/$arch", | ||||
| 				 otherpkglist=>$otherpkgsfile, | ||||
| 				 otherpkgdir=>"$installroot/post/otherpkgs/$osver/$arch", | ||||
| 				 exlist=>$exlistfile, | ||||
| 				 postinstall=>$postfile, | ||||
| 				 rootimgdir=>"$installroot/netboot/$osver/$arch/$profile"); | ||||
| 		    $linuximagetab->setAttribs(\%key_col, \%tb_cols); | ||||
| 		     | ||||
| 		} else { | ||||
| 		    return (1, "Cannot open the linuximage table."); | ||||
| 		} | ||||
| 	    } | ||||
| 	} else { | ||||
| 	    return (1, "Cannot open the osimage table.");  | ||||
| 	} | ||||
|     }   | ||||
|         #get postinstall script file name | ||||
|         my $postfile=get_postinstall_file_name($cuspath, $profile, $osver, $arch); | ||||
|         if (!$postfile) {  $postfile=get_postinstall_file_name($defpath, $profile, $osver, $arch); } | ||||
|      | ||||
|      | ||||
|         #now update the db | ||||
|         if (!$osimagetab) {  | ||||
|     	$osimagetab=xCAT::Table->new('osimage',-create=>1);  | ||||
|         } | ||||
|          | ||||
|         if ($osimagetab) {     | ||||
|     	#check if the image is already in the table | ||||
|     	if ($osimagetab) { | ||||
|     	    my $found=0; | ||||
|     	    my $tmp1=$osimagetab->getAllEntries(); | ||||
|     	    if (defined($tmp1) && (@$tmp1 > 0)) { | ||||
|     		foreach my $rowdata(@$tmp1) { | ||||
|     		    if (($osver eq $rowdata->{osvers}) && ($arch eq $rowdata->{osarch}) && ($rowdata->{provmethod} eq $provm) && ($profile eq $rowdata->{profile})){ | ||||
|     			$found=1; | ||||
|     			last; | ||||
|     		    } | ||||
|     		} | ||||
|     	    } | ||||
|     	    if ($found) { print "The image is already in the db.\n"; next; }  | ||||
|     	     | ||||
|     	    my $imagename=$osver . "-" . $arch . "-$provm-" . $profile; | ||||
|     	    #TODO: check if there happen to be a row that has the same imagename but with different contents | ||||
|     	    #now we can wirte the info into db | ||||
|     	    my %key_col = (imagename=>$imagename); | ||||
|     	    my %tb_cols=(imagetype=>$imagetype,  | ||||
|     			 provmethod=>$provm, | ||||
|     			 profile=>$profile,  | ||||
|     			 osname=>$ostype, | ||||
|     			 osvers=>$osver, | ||||
|     			 osarch=>$arch, | ||||
|     			 synclists=>$synclistfile); | ||||
|     	    $osimagetab->setAttribs(\%key_col, \%tb_cols); | ||||
|     	     | ||||
|     	    if ($osname !~ /^win/) { | ||||
|     		if (!$linuximagetab) { $linuximagetab=xCAT::Table->new('linuximage',-create=>1); } | ||||
|     		if ($linuximagetab) { | ||||
|     		    my %key_col = (imagename=>$imagename); | ||||
|     		    my %tb_cols=(pkglist=>$pkglistfile,  | ||||
|     				 pkgdir=>"$installroot/$osver/$arch", | ||||
|     				 otherpkglist=>$otherpkgsfile, | ||||
|     				 otherpkgdir=>"$installroot/post/otherpkgs/$osver/$arch", | ||||
|     				 exlist=>$exlistfile, | ||||
|     				 postinstall=>$postfile, | ||||
|     				 rootimgdir=>"$installroot/netboot/$osver/$arch/$profile"); | ||||
|     		    $linuximagetab->setAttribs(\%key_col, \%tb_cols); | ||||
|     		     | ||||
|     		} else { | ||||
|     		    return (1, "Cannot open the linuximage table."); | ||||
|     		} | ||||
|     	    } | ||||
|     	} else { | ||||
|     	    return (1, "Cannot open the osimage table.");  | ||||
|     	} | ||||
|         }   | ||||
|     } | ||||
|     if ($osimagetab) { $osimagetab->close(); } | ||||
|     if ($linuximagetab) { $linuximagetab->close(); } | ||||
|     return (0, ""); | ||||
|   | ||||
| @@ -1427,6 +1427,14 @@ sub copycd | ||||
|         if ($ret[0] != 0) { | ||||
| 	    $callback->({data => "Error when updating the osimage tables: " . $ret[1]}); | ||||
| 	} | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "netboot"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); | ||||
|         } | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -342,7 +342,14 @@ sub copycd | ||||
|         if ($ret[0] != 0) { | ||||
| 	    $callback->({data => "Error when updating the osimage tables: " . $ret[1]}); | ||||
| 	} | ||||
|  | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "netboot"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); | ||||
|         } | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1147,7 +1147,14 @@ sub copycd | ||||
|         if ($ret[0] != 0) { | ||||
| 	    $callback->({data => "Error when updating the osimage tables: " . $ret[1]}); | ||||
| 	} | ||||
|  | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "netboot"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for stateless: " . $ret[1]}); | ||||
|         } | ||||
|         my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($distname, $arch, undef, "statelite"); | ||||
|         if ($ret[0] != 0) { | ||||
|             $callback->({data => "Error when updating the osimage tables for statelite: " . $ret[1]}); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user