From 0f0046ca9d73dc43d432ad9fe7fef401cfd81513 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 5 Aug 2013 09:36:08 -0400 Subject: [PATCH] add support for updatenode -g flag to generate mypostcripts files --- perl-xCAT/xCAT/Usage.pm | 5 ++- xCAT-client/bin/updatenode | 1 + xCAT-server/lib/xcat/plugins/updatenode.pm | 43 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 10d370aa0..52e362627 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -343,7 +343,7 @@ my %usage = ( renergy noderange [-V] { cappingstatus={on | enable | off | disable} | {cappingwatt|cappingvalue}=watt }", "updatenode" => "Usage: - updatenode [-h|--help|-v|--version] + updatenode [-h|--help|-v|--version | -g|--genmypost] or updatenode [-V|--verbose] [-k|--security] [-s|--sn] or @@ -368,6 +368,9 @@ Options: [-f|--snsync] Performs File Syncing to the service nodes that service the nodes in the noderange. + [-g|--genmypost] Will generate a new mypostscript file for the + the nodes in the noderange, if site precreatemypostscripts is 1 or YES. + [-l|--user] User name to run the updatenode command. It overrides the current user which is the default. diff --git a/xCAT-client/bin/updatenode b/xCAT-client/bin/updatenode index b0c14fe5c..35e7efd99 100755 --- a/xCAT-client/bin/updatenode +++ b/xCAT-client/bin/updatenode @@ -88,6 +88,7 @@ if ( 'v|version' => \$::VERSION, 'V|verbose' => \$::VERBOSE, 'F|sync' => \$::FILESYNC, + 'g|genmypost' => \$::GENMYPOST, 'f|snsync' => \$::SNFILESYNC, 'l|user:s' => \$::USER, 'S|sw' => \$::SWMAINTENANCE, diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 7295b26b7..a8e03b1ad 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -218,6 +218,7 @@ sub preprocess_updatenode 'v|version' => \$::VERSION, 'V|verbose' => \$::VERBOSE, 'F|sync' => \$::FILESYNC, + 'g|genmypost' => \$::GENMYPOST, 'l|user:s' => \$::USER, 'f|snsync' => \$::SNFILESYNC, 'S|sw' => \$::SWMAINTENANCE, @@ -249,6 +250,38 @@ sub preprocess_updatenode $callback->($rsp); return; } + # Just generate mypostscripts file and get out + if ($::GENMYPOST) + { + my @entries = xCAT::TableUtils->get_site_attribute("precreatemypostscripts"); + if ($entries[0] ) { + $entries[0] =~ tr/a-z/A-Z/; + if ($entries[0] =~ /^(1|YES)$/ ) { + + my $notmpfiles=1; + my $nofiles=0; + xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles); + my $rsp = {}; + $rsp->{data}->[0] = "Generated new mypostscript files"; + $callback->($rsp); + } else { # not valid unless precreatemypostscripts enabled + my $rsp = {}; + $rsp->{error}->[0] = + "This option is only valid if site table precreatemypostscripts attribute is 1 or YES"; + $rsp->{errorcode}->[0] =1; + $callback->($rsp); + return ; + } + } else { # not in the site table + my $rsp = {}; + $rsp->{error}->[0] = + "This option is only valid if site table precreatemypostscripts attribute is 1 or YES"; + $rsp->{errorcode}->[0] =1; + $callback->($rsp); + return ; + } + return 0; + } # -c must work with -S for AIX node if ($::CMDLINE && !$::SWMAINTENANCE) @@ -1267,6 +1300,7 @@ sub updatenoderunps # Note order of parameters to xcatdsklspost #is important and cannot be changed my $runpscmd; + if ($::SETSERVER){ $runpscmd = "$installdir/postscripts/xcatdsklspost $mode -M $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"; @@ -1274,6 +1308,11 @@ sub updatenoderunps $runpscmd = "$installdir/postscripts/xcatdsklspost $mode -m $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c" } + # add verbose flag + if ($::VERBOSE){ + $runpscmd .= " -V"; + } + push @$args1,"--nodestatus"; # return nodestatus if (defined($::fanout)) { # fanout push @$args1,"-f" ; @@ -1596,6 +1635,10 @@ sub updatenodesoftware $cmd = "$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs' --tftp $tftpdir"; } + # add verbose flag + if ($::VERBOSE){ + $cmd .= " -V"; + } # build xdsh command push @$args1,"--nodestatus"; # return nodestatus