-Have nodeset return errors to user on template parse problems
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@736 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
a3e77ea4b7
commit
223e981012
@ -9,6 +9,7 @@ use File::Path;
|
||||
use Data::Dumper;
|
||||
use Sys::Syslog;
|
||||
|
||||
my $tmplerr;
|
||||
my $table;
|
||||
my $key;
|
||||
my $field;
|
||||
@ -25,12 +26,12 @@ sub subvars {
|
||||
$idir = dirname($inf);
|
||||
open($inh,"<",$inf);
|
||||
unless ($inh) {
|
||||
return undef;
|
||||
return "Unable to open $inf, aborting";
|
||||
}
|
||||
mkpath(dirname($outf));
|
||||
open($outh,">",$outf);
|
||||
unless($outh) {
|
||||
return undef;
|
||||
return "Unable to open $outf for writing/creation, aborting";
|
||||
}
|
||||
my $inc;
|
||||
#First load input into memory..
|
||||
@ -72,9 +73,13 @@ sub subvars {
|
||||
$inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg;
|
||||
$inc =~ s/#XCATVAR:([^#]+)#/envvar($1)/eg;
|
||||
$inc =~ s/#ENV:([^#]+)#/envvar($1)/eg;
|
||||
if ($tmplerr) {
|
||||
close ($outh);
|
||||
return $tmplerr;
|
||||
}
|
||||
print $outh $inc;
|
||||
close($outh);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
sub includefile
|
||||
{
|
||||
@ -152,6 +157,13 @@ sub tabdb
|
||||
my $key = shift;
|
||||
my $field = shift;
|
||||
my $tabh = xCAT::Table->new($table);
|
||||
unless ($tabh) {
|
||||
$tmplerr="Unable to open table named $table";
|
||||
if ($table =~ /\.tab/) {
|
||||
$tmplerr .= " (.tab should not be specified as part of the table name in xCAT 2, as it seems to be the case here)";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
my $ent;
|
||||
if ($key eq "THISNODE" or $key eq '$NODE') {
|
||||
$ent = $tabh->getNodeAttribs($node,[$field]);
|
||||
@ -167,6 +179,7 @@ sub tabdb
|
||||
}
|
||||
$tabh->close;
|
||||
unless($ent and defined($ent->{$field})) {
|
||||
$tmplerr="Unable to find requested $field from $table in this context";
|
||||
return "";
|
||||
#return "#TABLEBAD:$table:field $field not found#";
|
||||
}
|
||||
|
@ -158,7 +158,11 @@ sub mkinstall {
|
||||
next;
|
||||
}
|
||||
#Call the Template class to do substitution to produce a kickstart file in the autoinst dir
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/centos/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
my $tmperr = xCAT::Template->subvars($::XCATROOT."/share/xcat/install/centos/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
if ($tmperr) {
|
||||
$callback->({node=>[{name=>[$node],error=>[$tmperr],errorcode=>[1]}]});
|
||||
next;
|
||||
}
|
||||
mkpath "/install/postscripts/";
|
||||
xCAT::Postage->writescript($node,"/install/postscripts/".$node);
|
||||
if (-r "/install/$os/$arch/images/pxeboot/vmlinuz"
|
||||
|
@ -195,14 +195,24 @@ sub mkinstall {
|
||||
}
|
||||
#Call the Template class to do substitution to produce a kickstart file in the autoinst dir
|
||||
|
||||
my $tmperr;
|
||||
if ( -r $::XCATROOT."/share/xcat/install/fedora/$profile.$os.$arch.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$os.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$os.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
} elsif ( -r $::XCATROOT."/share/xcat/install/fedora/$profile.$arch.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
} elsif ( -r $::XCATROOT."/share/xcat/install/fedora/$profile.$os.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$os.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/$profile.$os.tmpl","/install/autoinst/".$node,$node);
|
||||
} else {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/fedora/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
}
|
||||
if ($tmperr) {
|
||||
$callback->({
|
||||
node => [ {
|
||||
name=> [ $node ],
|
||||
error=> [ $tmperr ],
|
||||
errorcode => [ 1 ]
|
||||
} ]});
|
||||
next;
|
||||
}
|
||||
mkpath "/install/postscripts/";
|
||||
xCAT::Postage->writescript($node,"/install/postscripts/".$node);
|
||||
|
@ -156,14 +156,24 @@ sub mkinstall {
|
||||
}
|
||||
#Call the Template class to do substitution to produce a kickstart file in the autoinst dir
|
||||
|
||||
my $tmperr;
|
||||
if ( -r $::XCATROOT."/share/xcat/install/rh/$profile.$os.$arch.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$os.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$os.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
} elsif ( -r $::XCATROOT."/share/xcat/install/rh/$profile.$arch.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$arch.tmpl","/install/autoinst/".$node,$node);
|
||||
} elsif ( -r $::XCATROOT."/share/xcat/install/rh/$profile.$os.tmpl" ) {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$os.tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/$profile.$os.tmpl","/install/autoinst/".$node,$node);
|
||||
} else {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/rh/".$ent->{profile}.".tmpl","/install/autoinst/".$node,$node);
|
||||
}
|
||||
if ($tmperr) {
|
||||
$callback->({
|
||||
node => [ {
|
||||
name=> [ $node ],
|
||||
error=> [ $tmperr ],
|
||||
errorcode => [ 1 ]
|
||||
} ]});
|
||||
next;
|
||||
}
|
||||
mkpath "/install/postscripts/";
|
||||
xCAT::Postage->writescript($node,"/install/postscripts/".$node);
|
||||
|
@ -62,14 +62,24 @@ sub mkinstall {
|
||||
next;
|
||||
}
|
||||
#Call the Template class to do substitution to produce a kickstart file in the autoinst dir
|
||||
my $tmperr;
|
||||
if (-r $::XCATROOT."/share/xcat/install/sles/$profile.$os.$arch.tmpl") {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$os.$arch.tmpl","/install/autoinst/$node",$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$os.$arch.tmpl","/install/autoinst/$node",$node);
|
||||
} elsif (-r $::XCATROOT."/share/xcat/install/sles/$profile.$arch.tmpl") {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$arch.tmpl","/install/autoinst/$node",$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$arch.tmpl","/install/autoinst/$node",$node);
|
||||
} elsif (-r $::XCATROOT."/share/xcat/install/sles/$profile.$os.tmpl") {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$os.tmpl","/install/autoinst/$node",$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.$os.tmpl","/install/autoinst/$node",$node);
|
||||
} elsif (-r $::XCATROOT."/share/xcat/install/sles/$profile.tmpl") {
|
||||
xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.tmpl","/install/autoinst/$node",$node);
|
||||
$tmperr=xCAT::Template->subvars($::XCATROOT."/share/xcat/install/sles/$profile.tmpl","/install/autoinst/$node",$node);
|
||||
}
|
||||
if ($tmperr) {
|
||||
$callback->({
|
||||
node => [ {
|
||||
name=> [ $node ],
|
||||
error=> [ $tmperr ],
|
||||
errorcode => [ 1 ]
|
||||
} ]});
|
||||
next;
|
||||
}
|
||||
mkpath "/install/postscripts/";
|
||||
xCAT::Postage->writescript($node,"/install/postscripts/".$node);
|
||||
|
Loading…
Reference in New Issue
Block a user