From a761e64c0caf8991cff5a96b734193252fbb5dbd Mon Sep 17 00:00:00 2001 From: yangsong Date: Wed, 12 Apr 2017 22:31:54 -0500 Subject: [PATCH] fix issue #2856: [DEV] nodes provisioned with redhat osimages created by xCAT 2.12.3 or earlier missed yum repo to MN in xCAT 2.12.4 or later (#2857) * fix issue [DEV] nodes provisioned with redhat osimages created by xCAT 2.12.3 or earlier missed yum repo to MN in xCAT 2.12.4 or later #2856 * fix issue [DEV] nodes provisioned with redhat osimages created by xCAT 2.12.3 or earlier missed yum repo to MN in xCAT 2.12.4 or later #2856 --- perl-xCAT/xCAT/Yum.pm | 8 ++++++-- xCAT-server/lib/perl/xCAT/Template.pm | 5 +++-- xCAT-server/lib/xcat/plugins/anaconda.pm | 9 +++++++++ xCAT-server/share/xcat/install/scripts/post.xcat | 6 +++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/perl-xCAT/xCAT/Yum.pm b/perl-xCAT/xCAT/Yum.pm index b8eeb8c02..71faef8c9 100644 --- a/perl-xCAT/xCAT/Yum.pm +++ b/perl-xCAT/xCAT/Yum.pm @@ -9,12 +9,16 @@ my $distname; my $arch; my $installpfx; +my $distrepopfx="/install/postscripts/repos"; + sub localize_yumrepo { my $self = shift; my $pkgdir = shift; $distname=shift; $arch=shift; - open($yumrepofile, ">", "$pkgdir/local-repository.tmpl"); + + mkpath("$distrepopfx/$pkgdir"); + open($yumrepofile, ">", "$distrepopfx/$pkgdir/local-repository.tmpl"); my %options = ( wanted => \&check_tofix, follow_fast => 1 @@ -27,7 +31,7 @@ sub localize_yumrepo { sub remove_yumrepo { my $self = shift; my $pkgdir = shift; - rmtree("$pkgdir/local-repository.tmpl"); + rmtree("$distrepopfx/$pkgdir/local-repository.tmpl"); } sub check_tofix { diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 06dc55b2b..d1415fa3a 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -303,11 +303,12 @@ sub subvars { $source_in_pre .= "\necho 'repo --name=pkg$c --baseurl=http://'\$nextserver'/$pkgdir' >> /tmp/repos"; $source .= "repo --name=pkg$c --baseurl=http://#TABLE:noderes:\$NODE:nfsserver#/$pkgdir\n"; #for rhels5.9 } - if( -f "$pkgdir/local-repository.tmpl"){ + my $distrepofile="/install/postscripts/repos/$pkgdir/local-repository.tmpl"; + if( -f "$distrepofile"){ my $repofd; my $repo_in_post; local $/=undef; - open($repofd,"<","$pkgdir/local-repository.tmpl"); + open($repofd,"<","$distrepofile"); $repo_in_post = <$repofd>; close($repofd); $repo_in_post =~ s#baseurl=#baseurl=http://$master/#g; diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 237a4e8b7..05bec81e5 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -1260,6 +1260,15 @@ sub mkinstall } } + unless(-f "/install/postscripts/repos/$pkgdir/local-repository.tmpl"){ + #fix issue #2856@github + #for the osimages created by <=xCAT 2.12.3 + #there is no local-repository.tmpl under pkgdir created on copycds + #generate local-repository.tmpl here if it does not exist + require xCAT::Yum; + xCAT::Yum->localize_yumrepo($pkgdir, $os, $arch); + } + my @missingparms; unless ($os) { if ($imagename) { push @missingparms, "osimage.osvers"; } diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 48024de9c..ba66f082b 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -410,9 +410,9 @@ export ARCH=#TABLE:nodetype:THISNODE:arch# export CONSOLEPORT=#TABLEBLANKOKAY:nodehm:THISNODE:serialport# #for redhat: -##place-holder for the code to save the repo info on compute node,pointing to the "pkgdir" of the osimage -##so that the provisioned node -##WRITEREPO# +#place-holder for the code to save the repo info on compute node,pointing to the "pkgdir" of the osimage +#so that the provisioned node has the repo pointed to the distro path on MN +#WRITEREPO# if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then msgutil_r "$MASTER_IP" "info" "running mypostscript" "/var/log/xcat/xcat.log"