add support for updatenode -g flag to generate mypostcripts files
This commit is contained in:
		@@ -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 <noderange> [-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.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user