2009-11-07 22:09:57 +00:00
|
|
|
#!/usr/bin/perl
|
2009-12-17 21:06:41 +00:00
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT =
|
|
|
|
$ENV{'XCATROOT'} ? $ENV{'XCATROOT'}
|
|
|
|
: -d '/opt/xcat' ? '/opt/xcat'
|
|
|
|
: '/usr';
|
|
|
|
}
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2009-11-07 22:09:57 +00:00
|
|
|
use strict;
|
2009-12-17 21:06:41 +00:00
|
|
|
|
|
|
|
use Getopt::Long;
|
|
|
|
require xCAT::MsgUtils;
|
|
|
|
require xCAT::DSHCLI;
|
2011-07-07 16:11:10 +00:00
|
|
|
require xCAT::Client;
|
|
|
|
|
2009-12-17 21:06:41 +00:00
|
|
|
use xCAT::Utils;
|
2013-06-18 08:08:03 +00:00
|
|
|
use xCAT::TableUtils;
|
2009-11-07 22:09:57 +00:00
|
|
|
use File::Basename;
|
2011-07-07 16:11:10 +00:00
|
|
|
|
2009-11-07 22:09:57 +00:00
|
|
|
$::XCATROOT = "/opt/xcat";
|
|
|
|
my $os = "";
|
|
|
|
my $profile = "";
|
|
|
|
my $interface = "";
|
2009-12-17 21:06:41 +00:00
|
|
|
my $version;
|
2009-11-07 22:09:57 +00:00
|
|
|
my $drivers = "";
|
|
|
|
my $otherInterfaces = "";
|
|
|
|
my $kernel = "";
|
|
|
|
my @oses; # available OSes.
|
|
|
|
my @profiles; # available profiles
|
|
|
|
my $profDir; # root where you do ./genimage from
|
|
|
|
my $help;
|
|
|
|
my $match = 0;
|
2010-09-02 17:22:17 +00:00
|
|
|
my $imagename;
|
|
|
|
my $arch;
|
2010-09-17 18:47:13 +00:00
|
|
|
my $permission;
|
2011-07-07 16:11:10 +00:00
|
|
|
my $rootlimit;
|
|
|
|
my $tmplimit;
|
|
|
|
my $krpmver;
|
|
|
|
my $kerneldir;
|
2011-07-07 20:38:17 +00:00
|
|
|
my $mode;
|
2012-03-27 19:28:49 +00:00
|
|
|
my $interactive;
|
2012-10-22 08:47:48 +00:00
|
|
|
my $onlyinitrd;
|
2013-04-23 19:16:55 +00:00
|
|
|
my $dryrun;
|
2009-12-17 21:06:41 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2009-12-17 21:06:41 +00:00
|
|
|
=head3 print_usage - usage message
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
sub print_usage
|
|
|
|
{
|
2011-07-07 16:11:10 +00:00
|
|
|
print "Usage:\n";
|
2011-09-13 19:51:47 +00:00
|
|
|
print " genimage\n\n";
|
2013-04-23 19:16:55 +00:00
|
|
|
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";
|
2011-07-07 16:11:10 +00:00
|
|
|
print " --permission is used for statelite only\n";
|
|
|
|
print " -g is used for SLES only\n\n";
|
2011-07-07 20:48:25 +00:00
|
|
|
print " -m is used for urbuntu, debian and fedora12 only\n\n";
|
2011-07-07 16:11:10 +00:00
|
|
|
print "Examples:\n";
|
2011-09-13 19:51:47 +00:00
|
|
|
print " genimage\n";
|
2012-03-27 19:28:49 +00:00
|
|
|
print " genimage --interactive\n";
|
2011-07-07 16:11:10 +00:00
|
|
|
print " genimage -i eth0 -n tg3 -o sles11 -p compute\n";
|
2012-10-22 08:47:48 +00:00
|
|
|
print " genimage -i eth0 -n tg3 -o sles11 -p compute --onlyinitrd\n";
|
2012-03-27 19:28:49 +00:00
|
|
|
print " genimage -i eth0 -r eth1,eth2 -n tg3,bnx2 -o centos5.1 -p compute --interactive\n";
|
2013-04-23 19:16:55 +00:00
|
|
|
print " genimage -i eth0 -n tg3,bnx2 -o sles11 -p compute --dryrun\n";
|
2011-07-07 16:11:10 +00:00
|
|
|
print " genimage -i eth0 -n igb,e1000e,e1000,bnx2,tg3 -o centos5.4 -p nfsroot --permission 777\n";
|
2012-03-27 19:28:49 +00:00
|
|
|
print " genimage -i eth0 -n tg3 --interactive myimagename\n";
|
2011-07-07 16:11:10 +00:00
|
|
|
print " genimage myimagename\n";
|
2009-12-17 21:06:41 +00:00
|
|
|
}
|
2011-07-07 16:11:10 +00:00
|
|
|
|
2009-12-17 21:06:41 +00:00
|
|
|
if (!GetOptions(
|
2011-07-07 16:11:10 +00:00
|
|
|
'a=s' => \$arch,
|
|
|
|
'p=s' => \$profile,
|
|
|
|
'o=s' => \$os,
|
|
|
|
'n=s' => \$drivers,
|
|
|
|
'i=s' => \$interface,
|
|
|
|
'r=s' => \$otherInterfaces,
|
|
|
|
'l=s' => \$rootlimit,
|
|
|
|
't=s' => \$tmplimit,
|
|
|
|
'k=s' => \$kernel,
|
|
|
|
'g=s' => \$krpmver,
|
2011-07-07 20:38:17 +00:00
|
|
|
'm=s' => \$mode,
|
2011-07-07 16:11:10 +00:00
|
|
|
'permission=s' => \$permission,
|
2012-03-27 19:28:49 +00:00
|
|
|
'kerneldir=s' => \$kerneldir,
|
|
|
|
'interactive' => \$interactive,
|
2013-04-23 19:16:55 +00:00
|
|
|
'onlyinitrd' => \$onlyinitrd,
|
|
|
|
'dryrun' => \$dryrun,
|
2011-07-07 16:11:10 +00:00
|
|
|
'h|help' => \$help,
|
|
|
|
'v|version' => \$version,
|
2009-12-17 21:06:41 +00:00
|
|
|
)) {
|
|
|
|
&print_usage;
|
|
|
|
exit 1;
|
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
|
|
|
|
if($help){
|
2011-07-07 16:11:10 +00:00
|
|
|
&print_usage;
|
|
|
|
exit 0;
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2009-12-17 21:06:41 +00:00
|
|
|
if ($version){
|
2011-07-07 16:11:10 +00:00
|
|
|
my $version = xCAT::Utils->Version();
|
|
|
|
xCAT::MsgUtils->message("N", $version);
|
|
|
|
exit 0;
|
2009-12-17 21:06:41 +00:00
|
|
|
|
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
if (@ARGV > 0) {
|
|
|
|
$imagename=$ARGV[0];
|
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2010-09-02 17:22:17 +00:00
|
|
|
if ((!$imagename) && (!$profile) && (!$os) && (!$arch)) {
|
|
|
|
my $tmpimgs=`lsdef -t osimage -w provmethod=~'/statelite|netboot/' |cut -d' ' -f1`;
|
|
|
|
if ($? == 0) {
|
|
|
|
if (($tmpimgs) && ($tmpimgs !~ /^Could/)) { #Could is returned when the osimage table is empty
|
|
|
|
my @images=split('\n', $tmpimgs);
|
|
|
|
print "Do you want to re-genarate an existing image from the osimage table? ";
|
2011-07-07 16:11:10 +00:00
|
|
|
print "[y/n] ";
|
2010-09-02 17:22:17 +00:00
|
|
|
my $conf = <stdin>;
|
|
|
|
chomp($conf);
|
|
|
|
if($conf ne "" && $conf !~/N|n|[Nn][Oo]/) {
|
|
|
|
$match = 0;
|
|
|
|
while(1){
|
|
|
|
print "Available images: \n";
|
|
|
|
foreach(sort @images){
|
|
|
|
print " $_\n";
|
|
|
|
}
|
|
|
|
# default is the first image cause in many cases
|
|
|
|
print "Which image do you want to re-generate? [";
|
2011-07-07 16:11:10 +00:00
|
|
|
print $images[0];
|
2010-09-02 17:22:17 +00:00
|
|
|
print "] ";
|
|
|
|
|
|
|
|
my $img = <stdin>;
|
|
|
|
chomp($img);
|
|
|
|
if($img eq ""){
|
2012-03-27 19:28:49 +00:00
|
|
|
$imagename = $images[0];
|
2009-11-07 22:09:57 +00:00
|
|
|
last;
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
|
|
|
foreach(@images){
|
|
|
|
if($img eq $_){
|
|
|
|
$imagename=$img;
|
|
|
|
$match = 1;
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
|
|
|
if ($match) {
|
2009-11-07 22:09:57 +00:00
|
|
|
last;
|
2010-09-02 17:22:17 +00:00
|
|
|
} else {
|
2011-07-07 16:11:10 +00:00
|
|
|
print "$img is not found in the osimage table.\n";
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# get the install directory
|
2013-06-18 08:08:03 +00:00
|
|
|
my @entries = xCAT::TableUtils->get_site_attribute("installdir");
|
|
|
|
my $installdir = $entries[0];
|
2010-09-02 17:22:17 +00:00
|
|
|
chomp($installdir);
|
|
|
|
# lots of error checking to make sure it exists.
|
|
|
|
if($installdir eq ''){
|
|
|
|
print "Could not get install directory from site table. Assuming your OSes are stored in '/install'\n";
|
|
|
|
$installdir = "/install";
|
|
|
|
}
|
|
|
|
|
|
|
|
unless(-d $installdir){
|
|
|
|
print "The directory where your OS distributions resides: $installdir does not exist. Please check site table\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2010-09-17 18:47:13 +00:00
|
|
|
if ((!$imagename) && (!$os)){
|
2010-09-02 17:22:17 +00:00
|
|
|
my @dircontents = `ls $installdir`;
|
|
|
|
chomp(@dircontents);
|
|
|
|
foreach (@dircontents) {
|
|
|
|
if($_ =~ /(rhel|fedora|sl|centos|suse)/){
|
|
|
|
push @oses,$_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($#oses eq -1){
|
|
|
|
print "There are no OS repositories in $installdir. Please run copycds for the OS first.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# now they have the OSes, make sure they select one that is available
|
|
|
|
$match = 0;
|
|
|
|
while(1){
|
|
|
|
print "Available OSes: \n";
|
|
|
|
foreach(@oses){
|
|
|
|
print " $_\n";
|
|
|
|
}
|
|
|
|
# default is the first OS cause in many cases, they'll only have 1.
|
|
|
|
print "Which OS do you want to build a image for? [";
|
2011-07-07 16:11:10 +00:00
|
|
|
print $oses[0] ;
|
2010-09-02 17:22:17 +00:00
|
|
|
print "] ";
|
|
|
|
|
|
|
|
$os = <stdin>;
|
2009-11-07 22:09:57 +00:00
|
|
|
chomp($os);
|
2010-09-02 17:22:17 +00:00
|
|
|
if($os eq ""){
|
2012-03-27 19:28:49 +00:00
|
|
|
$os = $oses[0];
|
2010-09-02 17:22:17 +00:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
foreach(@oses){
|
|
|
|
if($os eq $_){
|
|
|
|
$match = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($match){
|
|
|
|
last;
|
|
|
|
}else{
|
2011-07-07 16:11:10 +00:00
|
|
|
print "$os is not found in '$installdir'\n";
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
chomp($os);
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2012-10-24 15:37:47 +00:00
|
|
|
if ($os) { print " OS: $os\n"; }
|
2010-09-02 17:22:17 +00:00
|
|
|
|
2009-11-07 22:09:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
### Get the Profile ####
|
|
|
|
my $osfamily = $os;
|
|
|
|
$osfamily =~ s/\d+//g;
|
|
|
|
$osfamily =~ s/\.//g;
|
|
|
|
if($osfamily =~ /rh/){
|
2010-09-02 17:22:17 +00:00
|
|
|
$osfamily = "rh";
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2010-08-17 23:35:09 +00:00
|
|
|
# OS version on s390x can contain 'sp', e.g. sles11sp1
|
|
|
|
# If the $osfamily contains 'sles' and 'sp', the $osfamily = sles
|
|
|
|
if ($osfamily =~ /sles/ && $osfamily =~ /sp/) {
|
2010-09-02 17:22:17 +00:00
|
|
|
$osfamily = "sles";
|
2010-08-17 23:35:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-07 22:09:57 +00:00
|
|
|
#print "OSfamily: $osfamily\n";
|
|
|
|
$profDir = "$::XCATROOT/share/xcat/netboot/$osfamily";
|
|
|
|
unless(-d $profDir){
|
2011-07-07 16:11:10 +00:00
|
|
|
print "Unable to find genimage script in $profDir\n";
|
2010-09-02 17:22:17 +00:00
|
|
|
exit 1;
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2010-09-17 18:47:13 +00:00
|
|
|
if ((!$imagename) && (!$profile)){
|
2010-09-02 17:22:17 +00:00
|
|
|
my $profDir2 = "$installdir/custom/netboot/$osfamily";
|
|
|
|
my @proList = `ls $profDir/*.pkglist`;
|
|
|
|
if (-d $profDir2) {
|
|
|
|
@proList = (@proList, `ls $profDir2/*.pkglist`);
|
|
|
|
}
|
|
|
|
my %seen = ();
|
|
|
|
foreach (@proList) {
|
|
|
|
my $f = basename($_);
|
|
|
|
$f =~ s/([^\.]*).*/$1/;
|
|
|
|
chomp($f);
|
|
|
|
$seen{$f}++;
|
|
|
|
}
|
|
|
|
@profiles = sort keys %seen;
|
|
|
|
if($#profiles eq -1){
|
2011-07-07 16:11:10 +00:00
|
|
|
print "There are no profiles in $::XCATROOT/share/xcat/netboot/$osfamily.\n";
|
2010-09-02 17:22:17 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
$match = 0;
|
|
|
|
while(1){
|
2011-07-07 16:11:10 +00:00
|
|
|
print "Available Profiles for $os: \n";
|
2010-09-02 17:22:17 +00:00
|
|
|
foreach(@profiles){
|
|
|
|
print " $_\n";
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
# default is the first OS cause in many cases, they'll only have 1.
|
|
|
|
print "Which profile do you want to use for $os? [";
|
2011-07-07 16:11:10 +00:00
|
|
|
print "$profiles[0] ";
|
2010-09-02 17:22:17 +00:00
|
|
|
print "] ";
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2010-09-02 17:22:17 +00:00
|
|
|
$profile = <stdin>;
|
|
|
|
chomp($profile);
|
|
|
|
if($profile eq ""){
|
|
|
|
$profile = $profiles[0];
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
foreach(@profiles){
|
|
|
|
if($profile eq $_){
|
|
|
|
$match = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($match eq 1){
|
|
|
|
last;
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2012-10-24 15:37:47 +00:00
|
|
|
if ($profile) { print " Profile: $profile\n"; }
|
2009-11-07 22:09:57 +00:00
|
|
|
|
|
|
|
# get the interface
|
2010-09-17 18:47:13 +00:00
|
|
|
if ((!$imagename) && (!$interface)){
|
2010-09-02 17:22:17 +00:00
|
|
|
while(1){
|
|
|
|
print "Which network interface do you want the image to boot from? [";
|
2011-07-07 16:11:10 +00:00
|
|
|
print "eth0";
|
2010-09-02 17:22:17 +00:00
|
|
|
print "] ";
|
|
|
|
$interface = <stdin>;
|
|
|
|
chomp($interface);
|
|
|
|
if($interface eq ""){
|
|
|
|
$interface = "eth0";
|
|
|
|
last;
|
|
|
|
}else{
|
|
|
|
print "You want your stateless machines to boot off of ";
|
|
|
|
print "$interface";
|
|
|
|
print "? ";
|
2011-07-07 16:11:10 +00:00
|
|
|
print "[Y/n] ";
|
2010-09-02 17:22:17 +00:00
|
|
|
my $conf = <stdin>;
|
|
|
|
chomp($conf);
|
|
|
|
if($conf eq ""){
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
if($conf =~ /Y|y|[Yy][Ee][Ss]/){
|
|
|
|
last;
|
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2012-10-24 15:37:47 +00:00
|
|
|
if ($interface) { print " Interface: $interface\n"; }
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
print "Generating image: \n";
|
|
|
|
my @arg;
|
|
|
|
if ($imagename) {
|
|
|
|
push @arg, "$imagename";
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
2011-07-07 16:11:10 +00:00
|
|
|
|
|
|
|
if ($interface) {
|
|
|
|
push @arg, "-i";
|
|
|
|
push @arg, "$interface";
|
|
|
|
}
|
|
|
|
if ($drivers) {
|
|
|
|
push @arg, "-n";
|
|
|
|
push @arg, "$drivers";
|
|
|
|
}
|
|
|
|
if ($os) {
|
|
|
|
push @arg, "-o";
|
|
|
|
push @arg, "$os";
|
|
|
|
}
|
|
|
|
if ($profile) {
|
|
|
|
push @arg, "-p";
|
|
|
|
push @arg, "$profile";
|
|
|
|
}
|
|
|
|
if ($arch) {
|
|
|
|
push @arg, "-a";
|
|
|
|
push @arg, "$arch";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($kernel) {
|
|
|
|
push @arg, "-k";
|
|
|
|
push @arg, "$kernel";
|
|
|
|
}
|
|
|
|
|
2009-11-07 22:09:57 +00:00
|
|
|
if($otherInterfaces){
|
2011-07-07 16:11:10 +00:00
|
|
|
push @arg, "-r";
|
|
|
|
push @arg, "$otherInterfaces";
|
|
|
|
}
|
2009-11-07 22:09:57 +00:00
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
if ($permission) {
|
|
|
|
push @arg, "--permission";
|
|
|
|
push @arg, "$permission";
|
2009-11-07 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
if ($rootlimit) {
|
|
|
|
push @arg, "-l";
|
|
|
|
push @arg, "$rootlimit";
|
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
if($tmplimit) {
|
|
|
|
push @arg, "-t";
|
|
|
|
push @arg, "$tmplimit";
|
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
if ($krpmver) {
|
|
|
|
push @arg, "-g";
|
|
|
|
push @arg, "$krpmver";
|
|
|
|
}
|
|
|
|
|
2011-07-07 20:38:17 +00:00
|
|
|
if ($mode) {
|
|
|
|
push @arg, "-m";
|
|
|
|
push @arg, "$mode";
|
|
|
|
}
|
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
if ($kerneldir) {
|
|
|
|
push @arg, "--kerneldir";
|
|
|
|
push @arg, "$kerneldir";
|
2009-12-15 20:27:36 +00:00
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
|
2012-03-27 19:28:49 +00:00
|
|
|
my $tempfile="/tmp/xcat_genimage.$$";
|
|
|
|
push @arg, "--tempfile"; #this is the file that contains the output
|
|
|
|
push @arg, "$tempfile";
|
|
|
|
|
|
|
|
if ($interactive) {
|
|
|
|
push @arg, "--interactive";
|
|
|
|
}
|
2011-07-07 16:11:10 +00:00
|
|
|
|
2012-10-22 08:47:48 +00:00
|
|
|
|
|
|
|
if ($onlyinitrd) {
|
|
|
|
push @arg, "--onlyinitrd";
|
|
|
|
}
|
|
|
|
|
2013-04-23 19:16:55 +00:00
|
|
|
if ($dryrun) {
|
|
|
|
push @arg, "--dryrun";
|
|
|
|
}
|
|
|
|
|
2011-07-07 16:11:10 +00:00
|
|
|
my $cmdref;
|
|
|
|
push (@{$cmdref->{arg}}, @arg);
|
|
|
|
$cmdref->{command}->[0] = "genimage";
|
|
|
|
|
2012-03-27 19:28:49 +00:00
|
|
|
if (!$interactive) {
|
|
|
|
xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response);
|
|
|
|
exit $xCAT::Client::EXITCODE;
|
|
|
|
} else {
|
2013-04-23 19:16:55 +00:00
|
|
|
if ($dryrun) { exit 0; }
|
2012-03-27 19:28:49 +00:00
|
|
|
#when in interactive mode, first call genimage.pm get info from DB,
|
|
|
|
xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response);
|
|
|
|
|
|
|
|
#then call the specific genimage under /opt/xcat/share...
|
|
|
|
if (-f $tempfile) {
|
|
|
|
my $cmdname;
|
|
|
|
#read the command name
|
|
|
|
open(FILE1, "<$tempfile");
|
|
|
|
my @output = <FILE1>;
|
|
|
|
if (@output >0) {
|
|
|
|
$cmdname=$output[0];
|
|
|
|
} else {
|
|
|
|
close FILE1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
close FILE1;
|
|
|
|
|
|
|
|
# run the specific genimage command
|
|
|
|
#print "cmdname=$cmdname\n";
|
|
|
|
system("$cmdname");
|
|
|
|
|
|
|
|
#then call genimage.pm to save the DB
|
|
|
|
my @arg1;
|
|
|
|
push @arg1, $tempfile;
|
|
|
|
my $request;
|
|
|
|
push (@{$request->{arg}}, @arg1);
|
|
|
|
$request->{command}->[0] = "saveimgdata";
|
|
|
|
xCAT::Client::submit_request($request, \&xCAT::Client::handle_response);
|
|
|
|
exit $xCAT::Client::EXITCODE;
|
|
|
|
} else {
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
2010-09-02 17:22:17 +00:00
|
|
|
|