From 5a395d4da65cac49de696fa88c510ffa98eb6ac2 Mon Sep 17 00:00:00 2001 From: jjhua Date: Fri, 12 Oct 2012 06:31:26 +0000 Subject: [PATCH] To support site.precreatemypostscripts=1 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13990 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/Postage.pm | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 889b5ad46..05145fdc4 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -92,6 +92,33 @@ sub writescript close($script); chmod 0755, $scriptfile; } + + +sub create_mypostscript_or_not { + my $request = shift; + my $callback = shift; + my $subreq = shift; + my $nodes = $request->{node}; + + my $tftpdir = xCAT::TableUtils::getTftpDir(); + system("rm -rf $tftpdir/mypostscripts"); + #if precreatemypostscripts=1, create each mypostscript for each node + my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts"); + if ($entries[0] ) { + $entries[0] =~ tr/a-z/A-Z/; + if ($entries[0] =~ /^(1|YES)$/ ) { + require xCAT::Postage; + my $state; + if ($request->{scripttype}) { $state = $request->{scripttype}->[0];} + xCAT::Postage::makescript($nodes, $state, $callback); + } + } + +} + + + + #---------------------------------------------------------------------------- @@ -118,6 +145,14 @@ sub makescript my $nodesetstate = shift; # install or netboot my $callback = shift; + #create the mypostscript for each node once according to the template + if(ref($node) eq "ARRAY") { + require xCAT::Template; + xCAT::Template->subvars_for_mypostscript($node, $nodesetstate, $callback); + return; + } + + my @scriptd; my ($master, $ps, $os, $arch, $profile);