add rootimgdir attr for sysclone osimage definition

This commit is contained in:
huweihua 2014-06-10 04:37:26 -04:00
parent 5e935ac943
commit 97538d1494

View File

@ -123,14 +123,14 @@ sub process_request {
# Handle image capture separately for s390x
if ($arch eq 's390x') {
eval { require xCAT_plugin::zvm; }; # Load z/VM plugin dynamically
xCAT_plugin::zvm->imageCapture($callback, $node, $os, $arch, $type, $profile, $osimg, $device);
xCAT_plugin::zvm->imageCapture($callback, $node, $os, $arch, $profile, $osimg, $device);
return;
}
my $shortname = xCAT::InstUtils->myxCATname();
my $rc;
$rc = sysclone_configserver($shortname, $callback, $doreq);
$rc = sysclone_configserver($shortname, $osimg, $callback, $doreq);
if($rc){
my $rsp = {};
$rsp->{data}->[0] = qq{Can not configure Imager Server on $shortname.};
@ -467,7 +467,7 @@ sub getplatform {
}
sub sysclone_configserver{
my ($server, $callback, $subreq) = @_;
my ($server, $osimage, $callback, $subreq) = @_;
# check if systemimager is installed on the imager server
my $rsp = {};
@ -514,9 +514,40 @@ sub sysclone_configserver{
{
mkpath($sysclone_overrides);
}
my $imagedir;
my $osimgtab = xCAT::Table->new('osimage');
my $entry = ($osimgtab->getAllAttribsWhere("imagename = '$osimage'", 'ALL' ))[0];
if(!$entry){
$imagedir = $sysclone_home . "/images/" . $osimage;
}else{
my $osimagetab = xCAT::Table->new('linuximage');
my $osimageentry = $osimagetab->getAttribs({imagename => $osimage}, 'rootimgdir');
if($osimageentry){
$imagedir = $osimageentry->{rootimgdir};
if (!(-e $imagedir)){
mkpath($imagedir);
}
}else{
$imagedir = $sysclone_home . "/images/" . $osimage;
$cmd = "chdef -t osimage $osimage rootimgdir=$imagedir";
$rc = `$cmd`;
}
}
$imagedir =~ s/^(\/.*)\/.+\/?$/$1/;
$imagedir =~ s/\//\\\\\//g;
$imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir;
my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`;
$olddir =~ s/\//\\\\\//g;
chomp($olddir);
$cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf";
$rc = `$cmd`;
# update /etc/systemimager/rsync_stubs/10header to generate new /etc/systemimager/rsyncd.conf
my $rc = `sed -i "s/\\/var\\/lib\\/systemimager/\\/install\\/sysclone/g" /etc/systemimager/rsync_stubs/10header`;
$rc = `sed -i "s/\\/var\\/lib\\/systemimager/\\/install\\/sysclone/g" /etc/systemimager/rsync_stubs/10header`;
$rc = `export PERL5LIB=/usr/lib/perl5/site_perl/;LANG=C si_mkrsyncd_conf`;
return 0;
@ -636,20 +667,15 @@ sub sysclone_createosimgdef{
my ($node, $server, $osimage, $callback, $subreq) = @_;
my $createnew = 0;
my %osimgdef;
my $DBname = xCAT::Utils->get_DBName; # support for DB2
my $osimgtab = xCAT::Table->new('osimage');
my $entry;
if ($DBname =~ /^DB2/) {
$entry = ($osimgtab->getAllAttribsWhere("\"imagename\" = '$osimage'", 'ALL' ))[0];
} else {
$entry = ($osimgtab->getAllAttribsWhere("imagename = '$osimage'", 'ALL' ))[0];
}
if($entry){
my $entry = ($osimgtab->getAllAttribsWhere("imagename = '$osimage'", 'ALL' ))[0];
if($entry){
my $rsp = {};
$rsp->{data}->[0] = qq{Using the existing osimage "$osimage" defined on $server.};
xCAT::MsgUtils->message("I", $rsp, $callback);
return 0;
}
}
# try to see if we can get the osimage def from golden client.
my $nttab = xCAT::Table->new('nodetype');
@ -683,6 +709,22 @@ sub sysclone_createosimgdef{
$osimgdef{$osimage}{template} = "";
$osimgdef{$osimage}{otherpkglist} = "";
$osimgdef{$osimage}{pkglist} = "";
if(!($imagedef{$oldimg}{rootimgdir})){
$imagedef{$oldimg}{rootimgdir} = $sysclone_home . "/images/" . $osimage;
my $imagedir = $imagedef{$oldimg}{rootimgdir};
$imagedir =~ s/^(\/.*)\/.+\/?$/$1/;
$imagedir =~ s/\//\\\\\//g;
$imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir;
my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`;
$olddir =~ s/\//\\\\\//g;
chomp($olddir);
my $cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf";
my $rc = `$cmd`;
}
}
} else {
$createnew = 1;
@ -706,6 +748,18 @@ sub sysclone_createosimgdef{
$osimgdef{$osimage}{osname} = "Linux";
$osimgdef{$osimage}{osvers} = $osver;
$osimgdef{$osimage}{osdistroname} = "$osver-$arch";
$osimgdef{$osimage}{rootimgdir} = $sysclone_home . "/images/" . $osimage;
my $imagedir = $osimgdef{$osimage}{rootimgdir};
$imagedir =~ s/^(\/.*)\/.+\/?$/$1/;
$imagedir =~ s/\//\\\\\//g;
$imagedir = "DEFAULT_IMAGE_DIR = ".$imagedir;
my $olddir = `more /etc/systemimager/systemimager.conf |grep DEFAULT_IMAGE_DIR`;
$olddir =~ s/\//\\\\\//g;
chomp($olddir);
my $cmd= "sed -i \"s/$olddir/$imagedir/\" /etc/systemimager/systemimager.conf";
my $rc = `$cmd`;
#$osimgdef{$osimage}{pkgdir} = "/install/$osver/$arch";
#$osimgdef{$osimage}{otherpkgdir} = "/install/post/otherpkgs/$osver/$arch";
}