added support to update the osimage and linuximage tables after copycds and packimage

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4173 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2009-09-19 17:03:14 +00:00
parent 05a5b0093d
commit 9524a49273
8 changed files with 567 additions and 111 deletions

View File

@ -382,7 +382,7 @@ noderes => {
},
},
nodetype => {
cols => [qw(node os arch profile supportedarchs nodetype comments disable)],
cols => [qw(node os arch profile provmethod supportedarchs nodetype comments disable)],
keys => [qw(node)],
table_desc => 'A few hardware and software characteristics of the nodes.',
descriptions => {
@ -390,6 +390,7 @@ nodetype => {
os => 'The operating system deployed on this node. Valid values: AIX, rh*, centos*, fedora*, sles* (where * is the version #).',
arch => 'The hardware architecture of this node. Valid values: x86_64, ppc64, x86, ia64.',
profile => 'Either the name of an xCAT osimage definition or a pointer to a kickstart or autoyast template to use for OS deployment of this node.',
provmethod => 'The provisioning method for node deployment. The valid values are install and netboot.',
supportedarchs => 'Comma delimited list of architectures this node can execute.',
nodetype => 'A comma-delimited list of characteristics of this node. Valid values: blade, vm (virtual machine), lpar, osi (OS image), hmc, fsp, ivm, bpa, mm, rsa, switch.',
comments => 'Any user-written notes.',
@ -410,12 +411,13 @@ notification => {
},
},
osimage => {
cols => [qw(imagename imagetype osname osvers osdistro osarch synclists comments disable)],
cols => [qw(imagename profile imagetype osname osvers osdistro osarch synclists comments disable)],
keys => [qw(imagename)],
table_desc => 'Basic information about an operating system image that can be used to deploy cluster nodes.',
descriptions => {
imagename => 'User provided name of this xCAT OS image definition.',
imagename => 'The name of this xCAT OS image definition.',
imagetype => 'The type of operating system image this definition represents.',
profile => 'The node usage category. For example compute, service.',
osname => 'Operating system name- AIX or Linux.',
osvers => 'Not used.',
osdistro => 'Not used.',
@ -425,6 +427,24 @@ osimage => {
disable => "Set to 'yes' or '1' to comment out this row.",
},
},
linuximage => {
cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir comments disable)],
keys => [qw(imagename)],
table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.',
descriptions => {
imagename => 'The name of this xCAT OS image definition.',
template => 'The fully qualified name of the template file that is used to create the kick start file for diskful installation.',
pkglist => 'The fully qualified name of the file that stores the distro packages list that will be included in the image. It is used for diskless image only.',
pkgdir => 'The name of the directory where the distro packages are stored.',
otherpkglist => 'The fully qualified name of the file that stores non-distro package lists that will be included in the image.',
otherpkgdir => 'The base directory where the non-distro packages are stored.',
exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.',
postinstall => 'The fully qualified name of the script file that will be run at the end of the packimage command. It is used for diskless image only.',
rootimgdir => 'The directory name where the image is stored. It is used for diskless image only.',
comments => 'Any user-written notes.',
disable => "Set to 'yes' or '1' to comment out this row.",
},
},
passwd => {
cols => [qw(key username password comments disable)],
keys => [qw(key username)],
@ -919,6 +939,10 @@ my @nodeattrs = (
tabentry => 'nodetype.profile',
access_tabentry => 'nodetype.node=attr:node',
},
{attr_name => 'provmethod',
tabentry => 'nodetype.provmethod',
access_tabentry => 'nodetype.node=attr:node',
},
####################
# iscsi table #
####################
@ -1337,67 +1361,143 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs);
tabentry => 'osimage.imagetype',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'nimtype',
tabentry => 'nimimage.nimtype',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'nimmethod',
tabentry => 'nimimage.nimmethod',
access_tabentry => 'nimimage.imagename=attr:imagename',
{attr_name => 'profile',
tabentry => 'osimage.profile',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'osname',
tabentry => 'osimage.osname',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'lpp_source',
tabentry => 'nimimage.lpp_source',
access_tabentry => 'nimimage.imagename=attr:imagename',
{attr_name => 'osvers',
tabentry => 'osimage.osvers',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'spot',
tabentry => 'nimimage.spot',
access_tabentry => 'nimimage.imagename=attr:imagename',
{attr_name => 'osdistro',
tabentry => 'osimage.osdistro',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'root',
tabentry => 'nimimage.root',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'dump',
tabentry => 'nimimage.dump',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'paging',
tabentry => 'nimimage.paging',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'resolv_conf',
tabentry => 'nimimage.resolv_conf',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'tmp',
tabentry => 'nimimage.tmp',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'home',
tabentry => 'nimimage.home',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'shared_home',
tabentry => 'nimimage.shared_home',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'shared_root',
tabentry => 'nimimage.shared_root',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'script',
tabentry => 'nimimage.script',
access_tabentry => 'nimimage.imagename=attr:imagename',
{attr_name => 'osarch',
tabentry => 'osimage.osarch',
access_tabentry => 'osimage.imagename=attr:imagename',
},
{attr_name => 'synclists',
tabentry => 'osimage.synclists',
access_tabentry => 'osimage.imagename=attr:imagename',
},
####################
# linuximage table#
####################
{attr_name => 'template',
only_if => 'osname=Linux',
tabentry => 'linuximage.template',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'pkglist',
only_if => 'osname=Linux',
tabentry => 'linuximage.pkglist',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'pkgdir',
only_if => 'osname=Linux',
tabentry => 'linuximage.pkgdir',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'otherpkglist',
only_if => 'osname=Linux',
tabentry => 'linuximage.otherpkglist',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'otherpkgdir',
only_if => 'osname=Linux',
tabentry => 'linuximage.otherpkgdir',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'exlist',
only_if => 'osname=Linux',
tabentry => 'linuximage.exlist',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'postinstall',
only_if => 'osname=Linux',
tabentry => 'linuximage.postinstall',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'rootimgdir',
only_if => 'osname=Linux',
tabentry => 'linuximage.rootimgdir',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
####################
# nimimage table#
####################
{attr_name => 'nimtype',
only_if => 'osname=AIX',
tabentry => 'nimimage.nimtype',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'nimmethod',
only_if => 'osname=AIX',
tabentry => 'nimimage.nimmethod',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'lpp_source',
only_if => 'osname=AIX',
tabentry => 'nimimage.lpp_source',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'spot',
only_if => 'osname=AIX',
tabentry => 'nimimage.spot',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'root',
only_if => 'osname=AIX',
tabentry => 'nimimage.root',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'dump',
only_if => 'osname=AIX',
tabentry => 'nimimage.dump',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'paging',
only_if => 'osname=AIX',
tabentry => 'nimimage.paging',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'resolv_conf',
only_if => 'osname=AIX',
tabentry => 'nimimage.resolv_conf',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'tmp',
only_if => 'osname=AIX',
tabentry => 'nimimage.tmp',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'home',
only_if => 'osname=AIX',
tabentry => 'nimimage.home',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'shared_home',
only_if => 'osname=AIX',
tabentry => 'nimimage.shared_home',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'shared_root',
only_if => 'osname=AIX',
tabentry => 'nimimage.shared_root',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'script',
only_if => 'osname=AIX',
tabentry => 'nimimage.script',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'fb_script',
only_if => 'osname=AIX',
tabentry => 'nimimage.fb_script',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
@ -1406,10 +1506,12 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs);
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'installp_bundle',
only_if => 'osname=AIX',
tabentry => 'nimimage.installp_bundle',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
{attr_name => 'filesets',
only_if => 'osname=AIX',
tabentry => 'nimimage.filesets',
access_tabentry => 'nimimage.imagename=attr:imagename',
},
@ -1422,6 +1524,7 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs);
# access_tabentry => 'nimimage.imagename=attr:imagename',
# },
{attr_name => 'usercomment',
only_if => 'osname=AIX',
tabentry => 'nimimage.comments',
access_tabentry => 'nimimage.imagename=attr:imagename',
},

View File

@ -269,8 +269,8 @@ sub makescript {
elsif ($os =~ /aix.*/) { $platform = "aix"; }
}
if (($nodesetstate) && ($nodesetstate eq "netboot")) { $stat="netboot";}
my $pkglist=get_otherpkg_file_name("/install/custom/$stat/$platform", $profile, $os, $arch);
if (!$pkglist) { $pkglist=get_otherpkg_file_name("$::XCATROOT/share/xcat/$stat/$platform", $profile, $os, $arch); }
my $pkglist=xCAT::SvrUtil->get_otherpkgs_pkglist_file_name("/install/custom/$stat/$platform", $profile, $os, $arch);
if (!$pkglist) { $pkglist=xCAT::SvrUtil->get_otherpkgs_pkglist_file_name("$::XCATROOT/share/xcat/$stat/$platform", $profile, $os, $arch); }
if ($pkglist) {
my @otherpkgs=();
@ -392,23 +392,6 @@ sub getnodesetstate {
return xCAT::SvrUtils->get_nodeset_state($node);
}
sub get_otherpkg_file_name {
my $pathtofiles=shift;
my $profile=shift;
my $os=shift;
my $arch=shift;
if (-r "$pathtofiles/$profile.$os.$arch.otherpkgs.pkglist") {
return "$pathtofiles/$profile.$os.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$arch.otherpkgs.pkglist") {
return "$pathtofiles/$profile.$arch.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.$os.otherpkgs.pkglist") {
return "$pathtofiles/$profile.$os.otherpkgs.pkglist";
} elsif (-r "$pathtofiles/$profile.otherpkgs.pkglist") {
return "$pathtofiles/$profile.otherpkgs.pkglist";
}
return "";
}
1;

View File

@ -9,6 +9,7 @@ BEGIN
use lib "$::XCATROOT/lib/perl";
require xCAT::Table;
require xCAT::Utils;
use File::Basename;
use strict;
@ -324,6 +325,7 @@ sub getsynclistfile()
elsif ($os =~ /fedora.*/) { $platform = "fedora"; }
elsif ($os =~ /sles.*/) { $platform = "sles"; }
elsif ($os =~ /AIX.*/) { $platform = "AIX"; }
elsif ($os =~ /win/) {$platform = "windows"; }
}
my $base = "/install/custom/$inst_type/$platform";
@ -341,8 +343,8 @@ sub getsynclistfile()
}
sub get_tmpl_file_name {
my ($searchpath, $profile, $os, $arch, $genos) = @_;
sub get_file_name {
my ($searchpath, $extension, $profile, $os, $arch, $genos) = @_;
#usally there're only 4 arguments passed for this function
#the $genos is only used for the Redhat family
@ -350,33 +352,394 @@ sub get_tmpl_file_name {
my $osbase = substr($os, 0, $dotpos);
#handle the following ostypes: sles10.2, sles11.1, rhels5.3, rhels5.4, etc
if (-r "$searchpath/$profile.$os.$arch.tmpl") {
return "$searchpath/$profile.$os.$arch.tmpl";
if (-r "$searchpath/$profile.$os.$arch.$extension") {
return "$searchpath/$profile.$os.$arch.$extension";
}
elsif (-r "$searchpath/$profile.$osbase.$arch.tmpl") {
return "$searchpath/$profile.$osbase.$arch.tmpl";
elsif (-r "$searchpath/$profile.$osbase.$arch.$extension") {
return "$searchpath/$profile.$osbase.$arch.$extension";
}
elsif (-r "$searchpath/$profile.$genos.$arch.tmpl") {
return "$searchpath/$profile.$genos.$arch.tmpl";
elsif (-r "$searchpath/$profile.$genos.$arch.$extension") {
return "$searchpath/$profile.$genos.$arch.$extension";
}
elsif (-r "$searchpath/$profile.$os.tmpl") {
return "$searchpath/$profile.$os.tmpl";
elsif (-r "$searchpath/$profile.$os.$extension") {
return "$searchpath/$profile.$os.$extension";
}
elsif (-r "$searchpath/$profile.$osbase.tmpl") {
return "$searchpath/$profile.$osbase.tmpl";
elsif (-r "$searchpath/$profile.$osbase.$extension") {
return "$searchpath/$profile.$osbase.$extension";
}
elsif (-r "$searchpath/$profile.$genos.tmpl") {
return "$searchpath/$profile.$genos.tmpl";
elsif (-r "$searchpath/$profile.$genos.$extension") {
return "$searchpath/$profile.$genos.$extension";
}
elsif (-r "$searchpath/$profile.$arch.tmpl") {
return "$searchpath/$profile.$arch.tmpl";
elsif (-r "$searchpath/$profile.$arch.$extension") {
return "$searchpath/$profile.$arch.$extension";
}
elsif (-r "$searchpath/$profile.tmpl") {
return "$searchpath/$profile.tmpl";
elsif (-r "$searchpath/$profile.$extension") {
return "$searchpath/$profile.$extension";
}
else {
return undef;
}
}
sub get_tmpl_file_name {
my $searchpath=shift;
if (($searchpath) && ($searchpath =~ /xCAT::SvrUtils/)) {
$searchpath = shift;
}
return xCAT::SvrUtils::get_file_name($searchpath, "tmpl", @_);
}
sub get_pkglist_file_name {
my $searchpath=shift;
if (($searchpath) && ($searchpath =~ /xCAT::SvrUtils/)) {
$searchpath = shift;
}
return xCAT::SvrUtils::get_file_name($searchpath, "pkglist", @_);
}
sub get_otherpkgs_pkglist_file_name {
my $searchpath=shift;
if (($searchpath) && ($searchpath =~ /xCAT::SvrUtils/)) {
$searchpath = shift;
}
return xCAT::SvrUtils::get_file_name($searchpath, "otherpkgs.pkglist", @_);
}
sub get_postinstall_file_name {
my $searchpath=shift;
if (($searchpath) && ($searchpath =~ /xCAT::SvrUtils/)) {
$searchpath = shift;
}
my $profile=shift;
my $os=shift;
my $arch=shift;
my $extension="postinstall";
my $dotpos = rindex($os, ".");
my $osbase = substr($os, 0, $dotpos);
#handle the following ostypes: sles10.2, sles11.1, rhels5.3, rhels5.4, etc
if (-x "$searchpath/$profile.$os.$arch.$extension") {
return "$searchpath/$profile.$os.$arch.$extension";
}
elsif (-x "$searchpath/$profile.$osbase.$arch.$extension") {
return "$searchpath/$profile.$osbase.$arch.$extension";
}
elsif (-x "$searchpath/$profile.$os.$extension") {
return "$searchpath/$profile.$os.$extension";
}
elsif (-x "$searchpath/$profile.$osbase.$extension") {
return "$searchpath/$profile.$osbase.$extension";
}
elsif (-x "$searchpath/$profile.$arch.$extension") {
return "$searchpath/$profile.$arch.$extension";
}
elsif (-x "$searchpath/$profile.$extension") {
return "$searchpath/$profile.$extension";
}
else {
return undef;
}
}
sub get_exlist_file_name {
my $searchpath=shift;
if (($searchpath) && ($searchpath =~ /xCAT::SvrUtils/)) {
$searchpath = shift;
}
return xCAT::SvrUtils::get_file_name($searchpath, "exlist", @_);
}
#-------------------------------------------------------------------------------
=head3 update_tables_with_templates
This function is called after copycds. Itwill get all the possible install templates
from the default directories for the given osver and arch and update the osimage table.
Arguments:
osver
arch
Returns:
an array (retcode, errmsg). The first one is the return code. If 0, it means succesful.
=cut
#-------------------------------------------------------------------------------
sub update_tables_with_templates
{
my $osver = shift; #like sle11, rhel5.3
if (($osver) && ($osver =~ /xCAT::SvrUtils/)) {
$osver = shift;
}
my $arch = shift; #like ppc64, x86, x86_64
my $osname=$osver;; #like sles, rh, centos, windows
my $ostype="Linux"; #like Linux, Windows
if ($osver =~ /^win/) {
$osname="windows";
$ostype="Windows";
} else {
until (-r "$::XCATROOT/share/xcat/install/$osname/" or not $osname) {
chop($osname);
}
unless ($osname) {
return (1, "Unable to find $::XCATROOT/share/xcat/install directory for $osver");
}
}
#for rhels5.1 genos=rhel5
my $genos = $osver;
$genos =~ s/\..*//;
if ($genos =~ /rh.*s(\d*)/) {
$genos = "rhel$1";
}
#print "osver=$osver, arch=$arch, osname=$osname, genos=$genos\n";
my $installroot="/install";
my $sitetab = xCAT::Table->new('site');
if ($sitetab) {
(my $ref) = $sitetab->getAttribs({key => "installdir"}, "value");
if ($ref and $ref->{value}) {
$installroot = $ref->{value};
}
}
my $cuspath="$installroot/custom/install/$osname";
my $defpath="$::XCATROOT/share/xcat/install/$osname";
#now get all the profile names for full installation
my %profiles=();
my @tmplfiles=glob($cuspath."/*.tmpl");
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;
#print "$tmpf\n";
$profiles{$tmpf}=1;
}
@tmplfiles=glob($defpath."/*.tmpl");
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;
}
#update the osimage and linuximage table
my $osimagetab;
my $linuximagetab;
foreach my $profile (keys %profiles) {
#print "profile=$profile\n";
#get template file
my $tmplfile=get_tmpl_file_name ($cuspath, $profile, $osver, $arch, $genos);
if (!$tmplfile) { $tmplfile=get_tmpl_file_name ($defpath, $profile, $osver, $arch, $genos);}
if (!$tmplfile) { 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");
#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->{imagetype} eq "install") && ($profile eq $rowdata->{profile})){
$found=1;
last;
}
}
}
if ($found) { next; }
my $imagename=$osver . "-" . $arch . "-install-" . $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=>"install",
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=(template=>$tmplfile,
pkgdir=>"$installroot/$osver/$arch",
otherpkglist=>$otherpkgsfile,
otherpkgdir=>"$installroot/post/otherpkgs/$osver/$arch");
$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, "");
}
#-------------------------------------------------------------------------------
=head3 update_tables_with_diskless_image
This function is called after a diskless image is created by packimage.
It'll writes the newimage info into the osimage and the linuximage tables.
Arguments:
osver
arch
profile
Returns:
an array (retcode, errmsg). The first one is the return code. If 0, it means succesful.
=cut
#-------------------------------------------------------------------------------
sub update_tables_with_diskless_image
{
my $osver = shift; #like sle11, rhel5.3
if (($osver) && ($osver =~ /xCAT::SvrUtils/)) {
$osver = shift;
}
my $arch = shift; #like ppc64, x86, x86_64
my $profile = shift;
my $osname=$osver;; #like sles, rh, centos, windows
my $ostype="Linux"; #like Linux, Windows
if ($osver =~ /^win/) {
$osname="windows";
$ostype="Windows";
} else {
until (-r "$::XCATROOT/share/xcat/netboot/$osname/" or not $osname) {
chop($osname);
}
unless ($osname) {
return (1, "Unable to find $::XCATROOT/share/xcat/netboot directory for $osver");
}
}
#for rhels5.1 genos=rhel5
my $genos = $osver;
$genos =~ s/\..*//;
if ($genos =~ /rh.*s(\d*)/) {
$genos = "rhel$1";
}
#print "osver=$osver, arch=$arch, osname=$osname, genos=$genos, profile=$profile\n";
my $installroot="/install";
my $sitetab = xCAT::Table->new('site');
if ($sitetab) {
(my $ref) = $sitetab->getAttribs({key => "installdir"}, "value");
if ($ref and $ref->{value}) {
$installroot = $ref->{value};
}
}
my $cuspath="$installroot/custom/netboot/$osname";
my $defpath="$::XCATROOT/share/xcat/netboot/$osname";
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);
}
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->{imagetype} eq "netboot") && ($profile eq $rowdata->{profile})){
$found=1;
last;
}
}
}
if ($found) { print "$profile already in\n"; return (0, ""); }
my $imagename=$osver . "-" . $arch . "-netboot-" . $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=>"netboot",
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);
$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, "");
}
1;

View File

@ -12,6 +12,7 @@ use POSIX qw(WNOHANG nice);
use xCAT::Table;
use xCAT::Utils;
use xCAT::MsgUtils;
use xCAT::SvrUtils;
#use Data::Dumper;
use Getopt::Long;
Getopt::Long::Configure("bundling");
@ -849,6 +850,10 @@ sub copycd
else
{
$callback->({data => "Media copy operation successful"});
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables: " . $ret[1]});
}
}
}

View File

@ -6,6 +6,7 @@ use xCAT::Table;
use xCAT::Utils;
use Time::HiRes qw (sleep);
use xCAT::MsgUtils;
use xCAT::SvrUtils;
use xCAT::Common;
use xCAT::VMCommon;
use POSIX "WNOHANG";
@ -1908,7 +1909,13 @@ sub copycd {
if ($rc != 0){
sendmsg([1,"Media copy operation failed, status $rc"]);
}else{
sendmsg("Media copy operation successful");
sendmsg("Media copy operation successful");
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch);
if ($ret[0] != 0) {
sendmsg("Error when updating the osimage tables: " . $ret[1]);
}
}
}
sub makecustomizedmod {

View File

@ -67,8 +67,8 @@ sub process_request {
return;
}
my $oldpath=cwd();
my $exlistloc=get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch);
if (!$exlistloc) { $exlistloc=get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch); }
my $exlistloc=xCAT::SvrUtils->get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch);
if (!$exlistloc) { $exlistloc=xCAT::SvrUtils->get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch); }
if (!$exlistloc)
{
@ -215,7 +215,11 @@ sub process_request {
}
chmod(0644,"../rootimg.sfs");
}
chdir($oldpath);
chdir($oldpath);
my @ret=xCAT::SvrUtils->update_tables_with_diskless_image($osver, $arch, $profile);
if ($ret[0] != 0) {
$callback->({error=>["Error when updating the osimage tables: " . $ret[1]]});
}
}
###########################################################
@ -282,21 +286,3 @@ sub copybootscript {
return 0;
}
sub get_exlist_file_name {
my $base=shift;
my $profile=shift;
my $osver=shift;
my $arch=shift;
my $exlistloc="";
if (-r "$base/$profile.$osver.$arch.exlist") {
$exlistloc = "$base/$profile.$osver.$arch.exlist";
} elsif (-r "$base/$profile.$arch.exlist") {
$exlistloc = "$base/$profile.$arch.exlist";
} elsif (-r "$base/$profile.$osver.exlist") {
$exlistloc = "$base/$profile.$osver.exlist";
} elsif (-r "$base/$profile.exlist") {
$exlistloc = "$base/$profile.exlist";
}
return $exlistloc;
}

View File

@ -745,6 +745,11 @@ sub copycd
else
{
$callback->({data => "Media copy operation successful"});
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables: " . $ret[1]});
}
}
}

View File

@ -491,7 +491,11 @@ sub copycd
else
{
$callback->({data => "Media copy operation successful"});
}
my @ret=xCAT::SvrUtils->update_tables_with_templates($distname, $arch);
if ($ret[0] != 0) {
$callback->({data => "Error when updating the osimage tables: " . $ret[1]});
}
}
}
#sub get_tmpl_file_name {