diff --git a/xCAT-server/lib/perl/xCAT/SvrUtils.pm b/xCAT-server/lib/perl/xCAT/SvrUtils.pm index 96e0c117d..a5514382d 100644 --- a/xCAT-server/lib/perl/xCAT/SvrUtils.pm +++ b/xCAT-server/lib/perl/xCAT/SvrUtils.pm @@ -554,6 +554,7 @@ sub update_tables_with_templates my $arch = shift; #like ppc64, x86, x86_64 my $ospkgdir=shift; my $osdistroname=shift; + my %args = @_; my $osname=$osver;; #like sles, rh, centos, windows my $ostype="Linux"; #like Linux, Windows @@ -606,6 +607,11 @@ sub update_tables_with_templates foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' + if ($tmpf =~ /[^\.]*\.([^\.]*)\.([^\.]*)\./) { # osver *and* arch specific, make sure they match + unless ($1 eq $osver and $2 eq $arch) { next; } + } elsif ($tmpf =~ /[^\.]*\.([^\.]*)\./) { #osver *or* arch specific, make sure one matches + unless ($1 eq $osver or $2 eq $arch) { next; } + } $tmpf =~ /^([^\.]*)\..*$/; $tmpf = $1; #print "$tmpf\n"; @@ -615,6 +621,11 @@ sub update_tables_with_templates foreach (@tmplfiles) { my $tmpf=basename($_); #get the profile name out of the file, TODO: this does not work if the profile name contains the '.' + if ($tmpf =~ /[^\.]*\.([^\.]*)\.([^\.]*)\./) { # osver *and* arch specific, make sure they match + unless ($1 eq $osver and $2 eq $arch) { next; } + } elsif ($tmpf =~ /[^\.]*\.([^\.]*)\./) { #osver *or* arch specific, make sure one matches + unless ($1 eq $osver or $2 eq $arch) { next; } + } $tmpf =~ /^([^\.]*)\..*$/; $tmpf = $1; $profiles{$tmpf}=1; @@ -623,6 +634,13 @@ sub update_tables_with_templates #update the osimage and linuximage table my $osimagetab; my $linuximagetab; + if ($args{checkonly}) { + if (keys %profiles) { + return (0,""); + } else { + return (1,"Missing template files"); + } + } foreach my $profile (keys %profiles) { #print "profile=$profile\n"; #get template file diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index bbeb0b5d8..fec51667f 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -2064,12 +2064,21 @@ sub copycd %{$request} = (); #clear request we've got it. + my $disccopiedin=0; + my $osdistroname=$distname."-".$arch; my $defaultpath="$installroot/$distname/$arch"; unless($path) { $path=$defaultpath; } + if ($::XCATSITEVALS{osimagerequired}){ + my ($nohaveimages,$errstr) = xCAT::SvrUtils->update_tables_with_templates($distname, $arch,$path,$osdistroname,checkonly=>1); + if ($nohaveimages) { + $callback->({error => "No Templates found to support $distname($arch)"}); + return; + } + } #tranverse the directory structure of the os media and get the fingerprint my @filelist=(); diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index e974b9c80..ea7bf99a0 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -4222,6 +4222,13 @@ sub copycd { } unless ($found) { return; } #not our media + if ($::XCATSITEVALS{osimagerequired}){ + my $haveimages=xCAT::SvrUtils->update_tables_with_templates($distname, $arch,"","",checkonly=>1); + unless ($haveimages) { + $callback->({error => "No Templates found to support $distname($arch)"}); + } + } + xCAT::SvrUtils::sendmsg("Copying media to $installroot/$distname/$arch/", $output_handler); my $omask = umask 0022; mkpath("$installroot/$distname/$arch"); diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 4e9a6028b..0e957f932 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -1328,6 +1328,14 @@ sub copycd { $path=$defaultpath; } + my $osdistroname=$distname."-".$arch; + if ($::XCATSITEVALS{osimagerequired}){ + my ($nohaveimages,$errstr) = xCAT::SvrUtils->update_tables_with_templates($distname, $arch,$path,$osdistroname,checkonly=>1); + if ($nohaveimages) { + $callback->({error => "No Templates found to support $distname($arch)"}); + return; + } + } my $ospkgpath= "$path/$discnumber"; @@ -1346,7 +1354,6 @@ sub copycd #check whether the os media has already been copied in my $disccopiedin=0; - my $osdistroname=$distname."-".$arch; my $tabosdistro=xCAT::Table->new('osdistro',-create=>1); if($tabosdistro) { diff --git a/xCAT-server/lib/xcat/plugins/windows.pm b/xCAT-server/lib/xcat/plugins/windows.pm index 8df86ef51..603e427b5 100644 --- a/xCAT-server/lib/xcat/plugins/windows.pm +++ b/xCAT-server/lib/xcat/plugins/windows.pm @@ -634,6 +634,14 @@ sub copycd { $path=$defaultpath; } + my $osdistroname=$distname."-".$arch; + if ($::XCATSITEVALS{osimagerequired}){ + my ($nohaveimages,$errstr) = xCAT::SvrUtils->update_tables_with_templates($distname, $arch,$path,$osdistroname,checkonly=>1); + if ($nohaveimages) { + $callback->({error => "No Templates found to support $distname($arch)"}); + return; + } + } $callback->( {data => "Copying media to $path"}); @@ -718,7 +726,6 @@ sub copycd else { $callback->({data => "Media copy operation successful"}); - my $osdistroname=$distname."-".$arch; my @ret=xCAT::SvrUtils->update_osdistro_table($distname,$arch,$path,$osdistroname); if ($ret[0] != 0) { $callback->({data => "Error when updating the osdistro tables: " . $ret[1]});