From 116368143d5f7516c03647096839a9bbf1fdb664 Mon Sep 17 00:00:00 2001 From: jjhua Date: Tue, 14 Jul 2009 09:15:29 +0000 Subject: [PATCH] move the special case for rflash from PPC.pm to PPCrflash.pm git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3768 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCrflash.pm | 75 +++++++++++++++++++++++++++----- xCAT-server/lib/perl/xCAT/PPC.pm | 29 +----------- 2 files changed, 64 insertions(+), 40 deletions(-) diff --git a/perl-xCAT/xCAT/PPCrflash.pm b/perl-xCAT/xCAT/PPCrflash.pm index 84cf64988..ca6ff3b0e 100644 --- a/perl-xCAT/xCAT/PPCrflash.pm +++ b/perl-xCAT/xCAT/PPCrflash.pm @@ -151,21 +151,25 @@ sub parse_args { } ############################################# - # Option -V for verbose output - ############################################# - if ( exists( $opt{V} )) { + # Option -V for verbose output + ############################################ + if ( exists( $opt{V} )) { $verbose = 1; - } + } - #################### - #suport for "rflash", copy the rpm and xml packages from user-spcefied-directory to /install/packages_fw - ##################### - if ( (!exists($opt{commit})) && (!exists($opt{ recover }))) { - if( preprocess_for_rflash($request, \%opt) == -1) { + #################### + #suport for "rflash", copy the rpm and xml packages from user-spcefied-directory to /install/packages_fw + ##################### + if ( (!exists($opt{commit})) && (!exists($opt{ recover }))) { + if( preprocess_for_rflash($request, \%opt) == -1) { return( usage() ); - } - } - + } + } + + if(noderange_validate($request) == -1) { + return(usage()); + } + send_msg($request, 1, "It may take considerable time to complete, depending on the number of systems being updated and the workload on the target HMC. In particular, power subsystem updates may take an hour or more if there are many attached managed systems. Please waiting."); #################################### @@ -207,7 +211,54 @@ sub send_msg { } } +##################################### +#When run rflash with the \"commit\" or \"recover\" operation, the noderange cannot be BPA and can only be CEC or LPAR. +##################################### +sub noderange_validate { + my $request = shift; + #my $opt = shift; + my $noderange = $request->{node}; + #my $t = print_var($request, "request"); + #print $t; + #################### + ## $f1 and $f2 are the flags for rflash, to check if there are BPAs and CECs at the same time. + ################## + my $f1 = 0; + my $f2 = 0; + ########################################### + # Group nodes + ########################################### + foreach my $node ( @$noderange ) { + my $type = undef; + my $sitetab = xCAT::Table->new( 'nodetype' ); + if ( defined( $sitetab )) { + my ($ent) = $sitetab->getAttribs({ node=>$node},'nodetype'); + if ( defined($ent) ) { + $type = $ent->{nodetype}; + } + } + #print "type:$type\n"; + if( $type =~/^(fsp|lpar)$/) { + $f1 = 1; + } else { + $f2 = 1; + my $exargs=$request->{arg}; + #my $t = print_var($exargs, "exargs"); + #print $t; + if ( grep(/commit/,@$exargs) != 0 || grep(/recover/,@$exargs) != 0) { + send_msg( $request, 1, "When run \"rflash\" with the \"commit\" or \"recover\" operation, the noderange cannot be BPA and can only be CEC or LPAR."); + send_msg( $request, 1, "And then, it will do the operation for both managed systems and power subsystems."); + return -1; + } + } + } + + if($f1 * $f2) { + send_msg( $request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); + return -1; + } +} sub preprocess_for_rflash { diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 3a9963127..9dbfc1573 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -530,11 +530,6 @@ sub preprocess_nodes { } } - #################### - # $f1 and $f2 are the flags for rflash, to check if there are BPAs and CECs at the same time. - ################# - my $f1 = 0; - my $f2 = 0; ########################################## # Group nodes ########################################## @@ -553,24 +548,7 @@ sub preprocess_nodes { ###################################### my $hcp = @$d[3]; my $mtms = @$d[2]; - ###################################### - # Special case for rflash - ###################################### - if ( $request->{command} eq "rflash" ) { - if(@$d[4] =~/^(fsp|lpar)$/) { - $f1 = 1; - } else { - $f2 = 1; - my $exargs=$request->{arg}; - my $t= xCAT::PPCrflash::print_var($exargs, "exargs"); - if ( grep(/commit/,@$exargs) != 0 || grep(/recover/,@$exargs) != 0) { - send_msg( $request, 1, "When run \"rflash\" with the \"commit\" or \"recover\" operation, the noderange cannot be BPA and can only be CEC or LPAR."); - send_msg( $request, 1, "And then, it will do the operation for both managed systems and power subsystems."); - return undef; - } - - } - } + ###################################### # Special case for mkconn ###################################### @@ -588,11 +566,6 @@ sub preprocess_nodes { } } - if($f1 * $f2) { - send_msg( $request, 1, "The argument noderange of rflash can't be BPA and CEC(or LPAR) at the same time"); - return undef; - } - ########################################## # Get userid and password ##########################################