From 2a38296b67df5673e5743adef0fc6611683a2357 Mon Sep 17 00:00:00 2001 From: linggao Date: Tue, 23 Apr 2013 19:13:15 +0000 Subject: [PATCH] added --dryrun flag for genimage git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@16048 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/genimage | 16 ++++++++++++---- xCAT-client/pods/man1/genimage.1.pod | 14 ++++++++++++-- xCAT-server/lib/xcat/plugins/genimage.pm | 10 +++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/xCAT-client/bin/genimage b/xCAT-client/bin/genimage index eaf7465a0..f64844a81 100755 --- a/xCAT-client/bin/genimage +++ b/xCAT-client/bin/genimage @@ -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 [-a ] -p -i -n [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive]'."\n\n"; - print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] '."\n\n"; + print " genimage --dryrun\n\n"; + print ' genimage -o [-a ] -p -i -n [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun]'."\n\n"; + print ' genimage [-o ] [-a ] [-p ] [-i ] [-n ] [--onlyinitrd] [-r ] [-k ] [-g ] [-m statelite] [-l rootlimitsize] [-t tmplimitsize] [--permission ] [--interactive] [--dryrun] '."\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); diff --git a/xCAT-client/pods/man1/genimage.1.pod b/xCAT-client/pods/man1/genimage.1.pod index 4678fd108..1003bbf21 100644 --- a/xCAT-client/pods/man1/genimage.1.pod +++ b/xCAT-client/pods/man1/genimage.1.pod @@ -6,9 +6,9 @@ B - Generates a stateless image to be used for a diskless install. B -B B<-o> I [B<-a> I] B<-p> I B<-i> I B<-n> I [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] +B B<-o> I [B<-a> I] B<-p> I B<-i> I B<-n> I [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] -B [B<-o> I] [B<-a> I] [B<-p> I] [B<-i> I] [B<-n> I] [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] I +B [B<-o> I] [B<-a> I] [B<-p> I] [B<-i> I] [B<-n> I] [B<--onlyinitrd>] [B<-r> I] [B<-k> I] [B<-g> I] [B<-m> I] [B<-l> I] [B<--permission> I] [B<--interactive>] [B<--dryrun>] I B [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 (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 diff --git a/xCAT-server/lib/xcat/plugins/genimage.pm b/xCAT-server/lib/xcat/plugins/genimage.pm index 4939d195c..10d1a03f5 100644 --- a/xCAT-server/lib/xcat/plugins/genimage.pm +++ b/xCAT-server/lib/xcat/plugins/genimage.pm @@ -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