mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-12 17:30:19 +00:00
Do not query noderes table in subvars subroutine
This patch refactor the interface to get xcatmaster and tftpserver attributes in the subvars subroutine to improve the performance. partial-issue: #3958
This commit is contained in:
@ -56,6 +56,7 @@ sub subvars {
|
||||
my $media_dir = shift;
|
||||
my $platform = shift;
|
||||
my $partitionfileval = shift;
|
||||
my $tmpl_hash = shift;
|
||||
my %namedargs = @_; #further expansion of this function will be named arguments, should have happened sooner.
|
||||
|
||||
unless ($namedargs{reusemachinepass}) {
|
||||
@ -88,10 +89,8 @@ sub subvars {
|
||||
my $master;
|
||||
|
||||
#the "xcatmaster" attribute of the node
|
||||
my $noderestab = xCAT::Table->new('noderes');
|
||||
my $et = $noderestab->getNodeAttribs($node, ['xcatmaster']);
|
||||
if ($et and $et->{'xcatmaster'}) {
|
||||
$master = $et->{'xcatmaster'};
|
||||
if ($tmpl_hash->{'xcatmaster'}) {
|
||||
$master = $tmpl_hash->{'xcatmaster'};
|
||||
}
|
||||
|
||||
unless ($master) {
|
||||
@ -375,9 +374,7 @@ sub subvars {
|
||||
$inc =~ s/#UNCOMMENTOENABLESSH#/ /g;
|
||||
}
|
||||
|
||||
my $nrtab = xCAT::Table->new("noderes");
|
||||
my $tftpserver = $nrtab->getNodeAttribs($node, ['tftpserver']);
|
||||
my $sles_sdk_media = "http://" . $tftpserver->{tftpserver} . $media_dir . "/sdk1";
|
||||
my $sles_sdk_media = "http://" . $tmpl_hash->{tftpserver} . $media_dir . "/sdk1";
|
||||
|
||||
$inc =~ s/#SLES_SDK_MEDIA#/$sles_sdk_media/eg;
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ sub mkinstall
|
||||
my $mactab = xCAT::Table->new('mac');
|
||||
my %osents = %{ $ostab->getNodesAttribs(\@nodes, [ 'profile', 'os', 'arch', 'provmethod' ]) };
|
||||
my %rents = %{ $restab->getNodesAttribs(\@nodes,
|
||||
[ 'xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic' ]) };
|
||||
[ 'xcatmaster', 'nfsserver', 'tftpdir', 'primarynic', 'installnic', 'tftpserver' ]) };
|
||||
my %hents = %{ $hmtab->getNodesAttribs(\@nodes,
|
||||
[ 'serialport', 'serialspeed', 'serialflow' ]) };
|
||||
my %macents = %{ $mactab->getNodesAttribs(\@nodes, ['mac']) };
|
||||
@ -1068,14 +1068,19 @@ sub mkinstall
|
||||
my $netdrivers;
|
||||
my $driverupdatesrc;
|
||||
my $osupdir;
|
||||
my %tmpl_hash;
|
||||
|
||||
my $ient = $rents{$node}->[0];
|
||||
if ($ient and $ient->{xcatmaster})
|
||||
{
|
||||
$xcatmaster = $ient->{xcatmaster};
|
||||
$tmpl_hash{"xcatmaster"} = $xcatmaster;
|
||||
} else {
|
||||
$xcatmaster = '!myipfn!';
|
||||
}
|
||||
if ($ient and $ient->{tftpserver}) {
|
||||
$tmpl_hash{"tftpserver"} = $ient->{tftpserver};
|
||||
}
|
||||
|
||||
my $osinst;
|
||||
if ($rents{$node}->[0] and $rents{$node}->[0]->{tftpdir}) {
|
||||
@ -1330,6 +1335,7 @@ sub mkinstall
|
||||
$pkgdir,
|
||||
$platform,
|
||||
$partfile,
|
||||
\%tmpl_hash,
|
||||
$os
|
||||
);
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ sub mkinstall {
|
||||
my %osents = %{ $ostab->getNodesAttribs(\@nodes, [ 'profile', 'os', 'arch', 'provmethod' ]) };
|
||||
my %rents =
|
||||
%{ $restab->getNodesAttribs(\@nodes,
|
||||
[ 'xcatmaster', 'nfsserver', 'primarynic', 'installnic' ]) };
|
||||
[ 'xcatmaster', 'nfsserver', 'primarynic', 'installnic', 'tftpserver' ]) };
|
||||
my %hents =
|
||||
%{ $hmtab->getNodesAttribs(\@nodes,
|
||||
[ 'serialport', 'serialspeed', 'serialflow' ]) };
|
||||
@ -537,6 +537,15 @@ sub mkinstall {
|
||||
my $pkglistfile;
|
||||
my $imagename; # set it if running of 'nodeset osimage=xxx'
|
||||
my $platform;
|
||||
my %tmpl_hash;
|
||||
|
||||
my $ient = $rents{$node}->[0];
|
||||
if ($ient and $ient->{xcatmaster}) {
|
||||
$tmpl_hash{"xcatmaster"} = $ient->{xcatmaster};
|
||||
}
|
||||
if ($ient and $ient->{tftpserver}) {
|
||||
$tmpl_hash{"tftpserver"} = $ient->{tftpserver};
|
||||
}
|
||||
|
||||
my $osinst;
|
||||
my $ent = $osents{$node}->[0]; #$ostab->getNodeAttribs($node, ['profile', 'os', 'arch']);
|
||||
@ -732,7 +741,8 @@ sub mkinstall {
|
||||
$pkglistfile,
|
||||
$pkgdir,
|
||||
$platform,
|
||||
$partitionfile
|
||||
$partitionfile,
|
||||
\%tmpl_hash
|
||||
);
|
||||
}
|
||||
|
||||
@ -752,14 +762,20 @@ sub mkinstall {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
$partitionfile
|
||||
$partitionfile,
|
||||
\%tmpl_hash
|
||||
);
|
||||
}
|
||||
|
||||
if (-r "$postscript") {
|
||||
$posterr = xCAT::Template->subvars($postscript,
|
||||
"$installroot/autoinst/" . $node . ".post",
|
||||
$node
|
||||
$node,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
\%tmpl_hash
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4856,7 +4856,7 @@ sub esxi_kickstart_from_template {
|
||||
}
|
||||
my $tmperr;
|
||||
if (-r "$template") {
|
||||
$tmperr = xCAT::Template->subvars($template, "$installdir/autoinst/" . $args{node}, $args{node}, undef);
|
||||
$tmperr = xCAT::Template->subvars($template, "$installdir/autoinst/" . $args{node}, $args{node}, undef, undef, undef, $args{tmpl_hash});
|
||||
} else {
|
||||
$tmperr = "Unable to find template in /install/custom/install/$plat or $::XCATROOT/share/xcat/install/$plat (for $args{profile}/$args{os}/$args{arch} combination)";
|
||||
}
|
||||
@ -4937,7 +4937,7 @@ sub mkcommonboot {
|
||||
my $restab = xCAT::Table->new('noderes', -create => 0);
|
||||
my $resents;
|
||||
if ($restab) {
|
||||
$resents = $restab->getNodesAttribs(\@nodes, [ 'tftpdir', 'nfsserver' ]);
|
||||
$resents = $restab->getNodesAttribs(\@nodes, [ 'tftpdir', 'nfsserver', 'xcatmaster', 'tftpserver']);
|
||||
}
|
||||
|
||||
my %tablecolumnsneededforaddkcmdline;
|
||||
@ -4967,6 +4967,8 @@ sub mkcommonboot {
|
||||
my $osver = $ent->{'os'};
|
||||
my $tftpdir;
|
||||
my $ksserver;
|
||||
my %tmpl_hash;
|
||||
|
||||
if ($resents and $resents->{$node}->[0]->{nfsserver}) {
|
||||
$ksserver = $resents->{$node}->[0]->{nfsserver};
|
||||
} else {
|
||||
@ -4978,6 +4980,12 @@ sub mkcommonboot {
|
||||
} else {
|
||||
$tftpdir = $globaltftpdir;
|
||||
}
|
||||
if ($resents and $resents->{$node}->[0]->{xcatmaster} ) {
|
||||
$tmpl_hash{"xcatmaster"} = $resents->{$node}->[0]->{xcatmaster};
|
||||
}
|
||||
if ($resents and $resents->{$node}->[0]->{tftpserver}) {
|
||||
$tmpl_hash{"tftpserver"} = $resents->{$node}->[0]->{tftpserver};
|
||||
}
|
||||
|
||||
#if($arch ne 'x86'){
|
||||
# xCAT::SvrUtils::sendmsg([1,"VMware ESX hypervisors are x86, please change the nodetype.arch value to x86 instead of $arch for $node before proceeding:
|
||||
@ -5106,7 +5114,7 @@ sub mkcommonboot {
|
||||
$append .= " xcatd=$ksserver:3001";
|
||||
if ($bootmode eq "install") {
|
||||
$append .= " ks=http://$ksserver/install/autoinst/$node";
|
||||
esxi_kickstart_from_template(node => $node, os => $osver, arch => $arch, profile => $profile);
|
||||
esxi_kickstart_from_template(node => $node, os => $osver, arch => $arch, profile => $profile, tmpl_hash => \%tmpl_hash);
|
||||
}
|
||||
if ($bootmode ne "install" and $serialconfig->{$node}) { #don't do it for install, installer croaks currently
|
||||
my $comport = 1;
|
||||
|
@ -804,7 +804,7 @@ sub mkinstall
|
||||
\@nodes,
|
||||
[
|
||||
'nfsserver', 'tftpdir', 'xcatmaster',
|
||||
'primarynic', 'installnic'
|
||||
'primarynic', 'installnic', 'tftpserver'
|
||||
]
|
||||
);
|
||||
my $hments =
|
||||
@ -868,6 +868,7 @@ sub mkinstall
|
||||
my $driverupdatesrc;
|
||||
my $osupdir;
|
||||
my $imagename; # set it if running of 'nodeset osimage=xxx'
|
||||
my %tmpl_hash;
|
||||
|
||||
if ($resents->{$node} and $resents->{$node}->[0]->{tftpdir}) {
|
||||
$tftpdir = $resents->{$node}->[0]->{tftpdir};
|
||||
@ -875,6 +876,13 @@ sub mkinstall
|
||||
$tftpdir = $globaltftpdir;
|
||||
}
|
||||
|
||||
if ($resents and $resents->{$node}->[0]->{xcatmaster} ) {
|
||||
$tmpl_hash{"xcatmaster"} = $resents->{$node}->[0]->{xcatmaster};
|
||||
}
|
||||
if ($resents and $resents->{$node}->[0]->{tftpserver}) {
|
||||
$tmpl_hash{"tftpserver"} = $resents->{$node}->[0]->{tftpserver};
|
||||
}
|
||||
|
||||
xCAT::MsgUtils->trace($verbose_on_off, "d", "sles->mkinstall: tftpdir=$tftpdir");
|
||||
|
||||
if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) {
|
||||
@ -1060,7 +1068,8 @@ sub mkinstall
|
||||
$pkglistfile,
|
||||
$tmppkgdir,
|
||||
$os,
|
||||
$partfile
|
||||
$partfile,
|
||||
\%tmpl_hash
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -243,6 +243,8 @@ sub mkinstall
|
||||
my $bootparams = ${$request->{bootparams}};
|
||||
my $hmtab = xCAT::Table->new('nodehm');
|
||||
my $vpdtab = xCAT::Table->new('vpd');
|
||||
my $restab = xCAT::Table->new('noderes');
|
||||
my $resents = $restab->getNodesAttribs(\@nodes, ['xcatmaster', 'tftpserver']);
|
||||
my $vpdhash = $vpdtab->getNodesAttribs(\@nodes, ['uuid']);
|
||||
my %img_hash = ();
|
||||
my $winimagetab;
|
||||
@ -282,6 +284,14 @@ sub mkinstall
|
||||
my $partfile;
|
||||
my $installto;
|
||||
my $winpepath;
|
||||
my %tmpl_hash;
|
||||
|
||||
if ($resents and $resents->{$node}->[0]->{xcatmaster} ) {
|
||||
$tmpl_hash{"xcatmaster"} = $resents->{$node}->[0]->{xcatmaster};
|
||||
}
|
||||
if ($resents and $resents->{$node}->[0]->{tftpserver}) {
|
||||
$tmpl_hash{"tftpserver"} = $resents->{$node}->[0]->{tftpserver};
|
||||
}
|
||||
|
||||
my $ent = $osents->{$node}->[0];
|
||||
if ($ent and $ent->{provmethod} and ($ent->{provmethod} ne 'install') and ($ent->{provmethod} ne 'netboot') and ($ent->{provmethod} ne 'statelite')) {
|
||||
@ -465,7 +475,7 @@ sub mkinstall
|
||||
$tmplfile,
|
||||
"$installroot/autoinst/$node.xml",
|
||||
$node,
|
||||
0);
|
||||
0,undef ,undef, undef, \%tmpl_hash);
|
||||
}
|
||||
|
||||
if ($tmperr) {
|
||||
|
Reference in New Issue
Block a user