diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index d9aa1aa4e..346a466b5 100644 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -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, ""); diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 1824cbe91..665494b24 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -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]}); + } } } diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 4fab63761..126b36da8 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -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]}); + } } } diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index a7473a0ce..02759bfa4 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -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]}); + } } }