Provide a mechanism for bundled xCAT instances to forbid image import without existing templates

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15792 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2013-04-02 19:19:30 +00:00
parent d3043285f2
commit 8360cddd12
5 changed files with 50 additions and 2 deletions

View File

@ -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

View File

@ -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=();

View File

@ -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");

View File

@ -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)
{

View File

@ -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]});