mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-08-27 09:06:39 +00:00
fix(packimage): report the missing image name instead of a rejected option
packimage rejects -o, -p and -a before anything else runs, which leaves three things below it that cannot be reached. The branch handling a missing image name asks for -o and reports "Please specify a os version with the -o flag", so passing the option is rejected and omitting it is reported as the option being absent. The check for those options alongside an image name re-tests a condition already rejected, and the block that built an image from them can no longer be entered. Report the missing image name instead, and drop the parts that cannot run. Passing -o, -p or -a is rejected exactly as before, and packing a named image is unchanged.
This commit is contained in:
@@ -132,10 +132,6 @@ sub process_request {
|
||||
|
||||
if (@ARGV > 0) {
|
||||
$imagename = $ARGV[0];
|
||||
if ($arch or $osver or $profile) {
|
||||
$callback->({ error => ["-o, -p and -a options are not allowed when a image name is specified."], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
|
||||
# load the module in memory
|
||||
eval { require("$::XCATROOT/lib/perl/xCAT/Table.pm") };
|
||||
@@ -186,21 +182,8 @@ sub process_request {
|
||||
$exlistloc = $ref1->{'exlist'};
|
||||
$destdir = $ref1->{'rootimgdir'};
|
||||
} else {
|
||||
$provmethod = "netboot";
|
||||
unless ($osver) {
|
||||
$callback->({ error => ["Please specify a os version with the -o flag"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
unless ($arch) {
|
||||
$arch = `uname -m`;
|
||||
chomp($arch);
|
||||
$arch = "x86" if ($arch =~ /i.86$/);
|
||||
}
|
||||
|
||||
unless ($profile) {
|
||||
$callback->({ error => ["Please specify a profile name with -p flag"], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
$callback->({ error => ["An image name is required, use 'packimage <osimage name>'."], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
|
||||
unless ($destdir) {
|
||||
@@ -233,17 +216,6 @@ sub process_request {
|
||||
return 1;
|
||||
}
|
||||
my $oldpath = cwd();
|
||||
unless ($imagename) {
|
||||
$exlistloc = xCAT::SvrUtils->get_exlist_file_name("$installroot/custom/netboot/$distname", $profile, $osver, $arch);
|
||||
unless ($exlistloc) { $exlistloc = xCAT::SvrUtils->get_exlist_file_name("$::XCATROOT/share/xcat/netboot/$distname", $profile, $osver, $arch); }
|
||||
|
||||
#save the settings into DB, it will not update if the image already exist
|
||||
my @ret = xCAT::SvrUtils->update_tables_with_diskless_image($osver, $arch, $profile, "netboot");
|
||||
unless ($ret[0] eq 0) {
|
||||
$callback->({ error => [ "Error when updating the osimage tables: " . $ret[1] ], errorcode => [1] });
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#before generating rootimg.$suffix, copy $installroot/postscripts into the image at /xcatpost
|
||||
if (-e "$rootimg_dir/xcatpost") {
|
||||
|
||||
Reference in New Issue
Block a user