From a7404f0c241d0e828ec1f44bbf096cd1652fa251 Mon Sep 17 00:00:00 2001 From: linggao Date: Mon, 6 Feb 2012 22:15:50 +0000 Subject: [PATCH] fixed the problem that gives error when noderes.nfsserver is not set for full disk install git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11491 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/Template.pm | 36 ++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 9b5a175c6..3c5da55e6 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -22,6 +22,13 @@ my $idir; my $node; my %loggedrealms; my $lastmachinepass; +my %tab_replacement=( + "noderes:nfsserver"=>"noderes:xcatmaster", + "noderes:tftpserver"=>"noderes:xcatmaster", + "noderes:xcatmaster"=>"site:key=master:value", + ); + + sub subvars { my $self = shift; @@ -412,7 +419,13 @@ sub tabdb $tabh->close; unless($ent and defined($ent->{$field})) { unless ($blankok) { - $tmplerr="Unable to find requested $field from $table, with $key"; + #$tmplerr="Unable to find requested $field from $table, with $key"; + my $rep=get_replacement($table,$key,$field); + if ($rep) { + return tabdb($rep->[0], $rep->[1], $rep->[2]); + } else { + $tmplerr="Unable to find requested $field from $table, with $key" + } } return ""; #return "#TABLEBAD:$table:field $field not found#"; @@ -462,4 +475,25 @@ sub tabdb #return "#TABLE:key not found#" } +sub get_replacement { + my $table=shift; + my $key=shift; + my $field=shift; + my $rep; + if (exists($tab_replacement{"$table:$field"})) { + my $repstr=$tab_replacement{"$table:$field"}; + if ($repstr) { + my @a=split(':', $repstr); + if (@a > 2) { + $rep=\@a; + } else { + $rep->[0]=$a[0]; + $rep->[1]=$key; + $rep->[2]=$a[1]; + } + } + } + return $rep; +} + 1;