From 8b91ce3f31542aecfb3a51999076ae2061f44487 Mon Sep 17 00:00:00 2001 From: vallard Date: Tue, 23 Nov 2010 19:00:09 +0000 Subject: [PATCH] added postage command to show postscripts for node on command line git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8248 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/getpostscript.pm | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/getpostscript.pm b/xCAT-server/lib/xcat/plugins/getpostscript.pm index 9cd6b66b7..0aa00622d 100644 --- a/xCAT-server/lib/xcat/plugins/getpostscript.pm +++ b/xCAT-server/lib/xcat/plugins/getpostscript.pm @@ -26,7 +26,10 @@ Return list of commands handled by this plugin sub handled_commands { - return {'getpostscript' => "getpostscript"}; + return { + 'getpostscript' => "getpostscript", + 'postage' => "getpostscript" + }; } @@ -52,6 +55,11 @@ sub process_request my @nodes=@$nodes; # do your processing here # return info + + if($command eq 'postage'){ + return postage($nodes, $callback); + } + my $client; if ($request->{'_xcat_clienthost'}) { $client = $request->{'_xcat_clienthost'}->[0]; @@ -73,3 +81,39 @@ sub process_request $callback->($rsp); } +sub postage { + my $nodes = shift; + my $callback = shift; + require xCAT::Postage; + foreach my $node (@$nodes){ + my @scriptcontents = xCAT::Postage::makescript($node,'postscripts',$callback); + my $ps = 0; + my $pbs = 0; + foreach(@scriptcontents){ + chomp($_); + if($_ =~ "postscripts-start-here"){ + $ps = 1; + next; + + } + if($_ =~ "postscripts-end-here"){ + $ps = 0; + next; + } + if($_ =~ "postbootscripts-start-here"){ + $pbs = 1; + next; + } + if($_ =~ "postbootscripts-end-here"){ + $pbs = 0; + next; + } + if($ps eq 1){ + $callback->({info => ["$node: postscript: $_"]}); + } + if($pbs eq 1){ + $callback->({info => ["$node: postbootscript: $_"]}); + } + } + } +}