added --dryrun flag for genimage

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16049 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2013-04-23 19:16:55 +00:00
parent 0b1d186caf
commit 6c4ed80d83
3 changed files with 33 additions and 7 deletions

View File

@ -40,6 +40,7 @@ my $kerneldir;
my $mode;
my $interactive;
my $onlyinitrd;
my $dryrun;
#-----------------------------------------------------------------------------
=head3 print_usage - usage message
@ -51,8 +52,9 @@ sub print_usage
{
print "Usage:\n";
print " genimage\n\n";
print ' genimage -o <osver> [-a <arch>] -p <profile> -i <nodebootif> -n <nodenetdrivers> [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive]'."\n\n";
print ' genimage [-o <osver>] [-a <arch>] [-p <profile>] [-i <nodebootif>] [-n <nodenetdrivers>] [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] <imagename>'."\n\n";
print " genimage --dryrun\n\n";
print ' genimage -o <osver> [-a <arch>] -p <profile> -i <nodebootif> -n <nodenetdrivers> [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun]'."\n\n";
print ' genimage [-o <osver>] [-a <arch>] [-p <profile>] [-i <nodebootif>] [-n <nodenetdrivers>] [--onlyinitrd] [-r <otherifaces>] [-k <kernelver>] [-g <krpmver>] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>] [--interactive] [--dryrun] <imagename>'."\n\n";
print " --permission is used for statelite only\n";
print " -g is used for SLES only\n\n";
print " -m is used for urbuntu, debian and fedora12 only\n\n";
@ -62,7 +64,7 @@ sub print_usage
print " genimage -i eth0 -n tg3 -o sles11 -p compute\n";
print " genimage -i eth0 -n tg3 -o sles11 -p compute --onlyinitrd\n";
print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o centos5.1 -p compute --interactive\n";
print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute\n";
print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --dryrun\n";
print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot --permission 777\n";
print " genimage -i eth0 -n tg3 --interactive myimagename\n";
print " genimage myimagename\n";
@ -83,7 +85,8 @@ if (!GetOptions(
'permission=s' => \$permission,
'kerneldir=s' => \$kerneldir,
'interactive' => \$interactive,
'onlyinitrd' => \$onlyinitrd,
'onlyinitrd' => \$onlyinitrd,
'dryrun' => \$dryrun,
'h|help' => \$help,
'v|version' => \$version,
)) {
@ -395,6 +398,10 @@ if ($onlyinitrd) {
push @arg, "--onlyinitrd";
}
if ($dryrun) {
push @arg, "--dryrun";
}
my $cmdref;
push (@{$cmdref->{arg}}, @arg);
$cmdref->{command}->[0] = "genimage";
@ -403,6 +410,7 @@ if (!$interactive) {
xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response);
exit $xCAT::Client::EXITCODE;
} else {
if ($dryrun) { exit 0; }
#when in interactive mode, first call genimage.pm get info from DB,
xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response);

View File

@ -6,9 +6,9 @@ B<genimage> - Generates a stateless image to be used for a diskless install.
B<genimage>
B<genimage> B<-o> I<osver> [B<-a> I<arch>] B<-p> I<profile> B<-i> I<nodebootif> B<-n> I<nodenetdrivers> [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>]
B<genimage> B<-o> I<osver> [B<-a> I<arch>] B<-p> I<profile> B<-i> I<nodebootif> B<-n> I<nodenetdrivers> [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>]
B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] I<imagename>
B<genimage> [B<-o> I<osver>] [B<-a> I<arch>] [B<-p> I<profile>] [B<-i> I<nodebootif>] [B<-n> I<nodenetdrivers>] [B<--onlyinitrd>] [B<-r> I<otherifaces>] [B<-k> I<kernelver>] [B<-g> I<krpmver>] [B<-m> I<statelite>] [B<-l> I<rootlimitsize>] [B<--permission> I<permission>] [B<--interactive>] [B<--dryrun>] I<imagename>
B<genimage> [B<-h> | B<--help> | B<-v> | B<--version>]
@ -142,6 +142,11 @@ This flag is for Ubuntu, Debian and Fedora12 only. Use this flag to specify if y
This flag allows the user to answer questions from yum/zypper command when installing rpms into the image. If it is not specified, '-y' will be passed to the yum command and '--non-interactive --no-gpg-checks' will be passed to the zypper command as default answers.
=item B<--dryrun>
This flag shows the underlying call to the os specific genimage function. The user can copy and the paste the output to run the command on another machine that does not have xCAT installed.
=item B<-t> I<tmplimit>
(Deprecated) This flag allows the user to setup the /tmp and the /var/tmp file system sizes. This flag is no longer supported. You can overwrite any file system size using the .postinstall script where you can create a new /etc/fstab file.
@ -212,6 +217,11 @@ To regenerate the initrd for a fedora8 image for a compute node architecture x86
genimage --onlyinitrd -i eth0 -n tg3,bnx2 -o fedora8 -p compute
=item 10
genimage --dryrun myimagename
=back

View File

@ -67,6 +67,7 @@ sub process_request {
my $interactive;
my $onlyinitrd;
my $tempfile;
my $dryrun;
GetOptions(
'a=s' => \$arch,
@ -85,6 +86,7 @@ sub process_request {
'interactive' => \$interactive,
'onlyinitrd' => \$onlyinitrd,
'tempfile=s' => \$tempfile,
'dryrun' => \$dryrun,
);
my $osimagetab;
@ -298,7 +300,9 @@ sub process_request {
if ($otherpkglist) { $cmd .= " --otherpkglist $otherpkglist"; }
if ($postinstall_filename) { $cmd .= " --postinstall $postinstall_filename"; }
if ($destdir) { $cmd .= " --rootimgdir $destdir"; }
if ($tempfile) { $cmd .= " --tempfile $tempfile"; }
if ($tempfile) {
if (!$dryrun) { $cmd .= " --tempfile $tempfile"; }
}
if ($driverupdatesrc) { $cmd .= " --driverupdatesrc $driverupdatesrc"; }
if ($imagename) {
@ -337,6 +341,10 @@ sub process_request {
$callback->({error=>["NO temp file provided to store the genimage command."]});
return;
}
#it only shows the underlying command without actually running the command
if ($dryrun) { return; }
if ($interactive) {
return; #back to the client, client will run