diff --git a/perl-xCAT/xCAT/PPC.pm b/perl-xCAT/xCAT/PPC.pm index b22e9723b..db89039d3 100644 --- a/perl-xCAT/xCAT/PPC.pm +++ b/perl-xCAT/xCAT/PPC.pm @@ -415,6 +415,12 @@ sub preprocess_nodes { return undef; } } + + #################### + # $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 ########################################## @@ -434,8 +440,22 @@ sub preprocess_nodes { my $hcp = @$d[3]; my $mtms = @$d[2]; + if ( $request->{command} eq "rflash" ) { + if(@$d[4] =~/^(fsp|lpar)$/) { + $f1 = 1; + } else { + $f2 = 1; + } + } + $nodehash{$hcp}{$mtms}{$node} = $d; } + + 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 ########################################## @@ -1034,19 +1054,52 @@ sub preprocess_request { #################### #suport for "rflash", copy the rpm and xml packages from user-spcefied-directory to /install/packages_fw ##################### - if ( $command eq "rflash" ) { + if ( $command eq "rflash" ) { + preprocess_for_rflash($req,$callback, \@exargs); + } + + + # find service nodes for the HCPs + # build an individual request for each service node + my $service = "xcat"; + my @hcps=keys(%hcp_hash); + my $sn = xCAT::Utils->get_ServiceNode(\@hcps, $service, "MN"); + + # build each request for each service node + foreach my $snkey (keys %$sn) + { + #print "snkey=$snkey\n"; + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $snkey; + my $hcps1=$sn->{$snkey}; + my @nodes=(); + foreach (@$hcps1) { + push @nodes, @{$hcp_hash{$_}{nodes}}; + } + $reqcopy->{node} = \@nodes; + #print "nodes=@nodes\n"; + push @requests, $reqcopy; + } + return \@requests; +} + +sub preprocess_for_rflash { + my $req = shift; + my $callback = shift; + my $exargs = shift; + my $packages_fw = "/install/packages_fw"; my $c = 0; my $packages_d; - foreach (@exargs) { + foreach (@$exargs) { $c++; if($_ eq "-p") { - $packages_d = $exargs[$c]; + $packages_d = $$exargs[$c]; last; } } if($packages_d ne $packages_fw ) { - $exargs[$c] = $packages_fw; + $$exargs[$c] = $packages_fw; if(! -d $packages_d) { $callback->({data=>["The directory $packages_d doesn't exist!"]}); $req = (); @@ -1113,36 +1166,10 @@ sub preprocess_request { } - $req->{arg} = \@exargs; + $req->{arg} = $exargs; } - } - - - # find service nodes for the HCPs - # build an individual request for each service node - my $service = "xcat"; - my @hcps=keys(%hcp_hash); - my $sn = xCAT::Utils->get_ServiceNode(\@hcps, $service, "MN"); - - # build each request for each service node - foreach my $snkey (keys %$sn) - { - #print "snkey=$snkey\n"; - my $reqcopy = {%$req}; - $reqcopy->{'_xcatdest'} = $snkey; - my $hcps1=$sn->{$snkey}; - my @nodes=(); - foreach (@$hcps1) { - push @nodes, @{$hcp_hash{$_}{nodes}}; - } - $reqcopy->{node} = \@nodes; - #print "nodes=@nodes\n"; - push @requests, $reqcopy; - } - return \@requests; } - ########################################################################## # Process request from xCat daemon ########################################################################## diff --git a/perl-xCAT/xCAT/PPCrflash.pm b/perl-xCAT/xCAT/PPCrflash.pm index dc0212982..04588e5d5 100644 --- a/perl-xCAT/xCAT/PPCrflash.pm +++ b/perl-xCAT/xCAT/PPCrflash.pm @@ -7,6 +7,7 @@ use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR); use xCAT::Usage; use xCAT::PPCinv; use xCAT::DSHCLI; +use xCAT::Table; use Getopt::Long; use File::Spec; use POSIX qw(tmpnam); @@ -304,6 +305,35 @@ sub get_lic_filenames { } + +sub get_one_mtms { + my $bpa = shift; + my $tab = xCAT::Table->new("ppc"); + my $msg ; + unless ($tab) { + $msg = "ERROR: Unable to open basic ppc table for configuration"; + return ("", $msg); + } + + ################################# + # Get node + ################################# + my @ent = $tab->getAllAttribsWhere("parent=\"$bpa\"", 'node'); + if (@ent < 0) { + $msg = "failed to get the CEC whose parent is $bpa!"; + return ("", $msg); + } + my $cec = $ent[0]->{node}; + $msg = "the first cec is $cec whose parent is $bpa!"; + + $cec =~ /(\w{6})\-([\w\-]{8})\-SN(\w{7})/; + my $mtms = "$2*$3"; +# print "the managed system is $mtms!\n"; + return ($mtms, $msg); +} + + + ########################## #Performs Licensed Internal Code (LIC) update support for HMC-attached POWER5 and POWER6 Systems ########################### @@ -435,13 +465,25 @@ sub rflash { } my ($volume,$directories,$file) = File::Spec->splitpath($rpm_file); push(@result,[$hmc, "Upgrade $mtms from release level:$release_level activated level:$active_level to $file successfully"]); - + + #If mtms is a bpa, we should change the managed_system to a cec whose parent is a bpa. + if($component eq "power") { + ($managed_system, $msg)= &get_one_mtms($name); + if($managed_system eq "") { + push(@value, [$hmc, $msg]); + return (\@value); + + } + dpush(\@value,[$hmc, $msg]); + } + } my $rpm_dest = $::POWER_DEST_DIR."/".$dirlist[0]; # The contents of the stanza file are slightly different depending # on the operation being performed. # + # $managed_system = "9125-F2A*0262652"; if( $upgrade_required ) { $stanza = "updlic::" . $managed_system . "::upgrade::::$rpm_dest"; } else { @@ -468,23 +510,26 @@ sub rflash { dpush(\@value, [$hmc,"user: $user"]);; # $password = @$cred[1] + - my $rpm_file_list = join(",", @rpm_files); - my $xml_file_list = join(",", @xml_files); + my $rpm_file_list = join(" ", @rpm_files); + my $xml_file_list = join(" ", @xml_files); ############################### #Prepare for "xdcp"-----runDcp_api ############################## my %options = (); $options{ 'user' } = $user; $options{ 'nodes' } = $hmc; + $options{ 'exit-status' } = 1; $options{ 'preserve' } = 1; $options{ 'source' } = "$tmp_file $rpm_file_list $xml_file_list"; $options{ 'target' } = "/tmp"; - - dpush(\@value, [$hmc,"invoking RunDcp_api()"]); - my @res = xCAT::DSHCLI->runDcp_api( \%options, 0 ); - if ($::RUNCMD_RC) { # error from dcp + + my @res = xCAT::DSHCLI->runDcp_api( \%options, 0); + my $Rc = shift(@res); + if ($::RUNCMD_RC || $Rc =~ /denied/) { # error from dcp my $rsp={}; + dpush(\@value, [$hmc,"invoking RunDcp_api()"]); $rsp->{data}->[0] = "Error from dsh. Return Code = $::RUNCMD_RC"; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); push(@value,[$hmc,$rsp->{data}->[0]]); @@ -494,9 +539,16 @@ sub rflash { return(\@value); } + my $r = (); + foreach $r (@res){ + push(@value, [$r]); + + } + + # print_var(@res); %options = (); - dpush(\@value,[$hmc, "copy files to $hmc complete"]); + push(@value,[$hmc, "copy files to $hmc complete"]); #`$::XDSH $hmc -K`; ############################################### @@ -512,7 +564,7 @@ sub rflash { # $options{ 'command' } = "ls -al"; @res = xCAT::DSHCLI->runDsh_api(\%options, 0); - if ($::RUNCMD_RC) { # error from dsh + if ($::RUNCMD_RC ) { # error from dsh my $rsp={}; $rsp->{data}->[0] = "Error from dsh. Return Code = $::RUNCMD_RC"; xCAT::MsgUtils->message("S", $rsp, $::CALLBACK, 1); diff --git a/xCAT-client/pods/man1/rflash.1.pod b/xCAT-client/pods/man1/rflash.1.pod index e30070d5a..4484df68e 100644 --- a/xCAT-client/pods/man1/rflash.1.pod +++ b/xCAT-client/pods/man1/rflash.1.pod @@ -4,7 +4,9 @@ B - Performs Licensed Internal Code (LIC) update support for HMC-attache =head1 B -B [B<-h>|B<--help>] I [B<-p> I] [B<--activate> B|B][B<--commit>|B<--recover>] [B<-v>] +B [B<-h>|B<--help>][B<-v>|B<--version>] + +B I B<-p> I [B<--activate> B|B][B<--commit>|B<--recover>] [B<-V>|B<--verbose>] =head1 B @@ -24,9 +26,7 @@ The flash chip of a POWER5 and POWER6 managed system or power subsystem stores f The B<--commit> flag is used to write the contents of the temporary side of the flash to the permanent side. This flag should be used after updating code and verifying correct system operation. The B<--recover> flag is used to write the permanent side of the flash chip back to the temporary side. This flag should be used to recover from a corrupt flash operation, so that the previously running code can be restored. -B The B<--commit> and B<--recover> two flags can't be used with B<--ativate> option at the same time. - -IBM recommends that you shutdown your Operating System images and power off your managed systems before applying disruptive updates to managed systems or power subsystems. +xCAT recommends that you shutdown your Operating System images and power off your managed systems before applying disruptive updates to managed systems or power subsystems. Any previously activated code on the affected systems will be automatically accepted into permanent flash by this procedure. @@ -36,7 +36,7 @@ B If the power subsystem is recycled, all of its attached managed s =over 7 -=item B<-h> +=item B<-h|--help> Writes the command’s usage statement to standard output. @@ -56,10 +56,14 @@ Used to commit the flash image in the temporary side of the chip to the permanen Used to recover the flash image in the permanent side of the chip to the temporary side for both managed systems and power subsystems. -=item B<-v> +=item B<-v|--version> Displays the command's version. +=item B<-V|--verbose> + +Verbose output. + =back =head1 B @@ -68,123 +72,27 @@ Displays the command's version. 1 An error has occurred. - =head1 B =over 4 -POWER5 and POWER6 Licensed Internal Code updates must meet the following B: - -(1)Enable the HMC to allow remote ssh connections. - -(2)Ensure that ssh is installed on the xCAT management node - -(3)The Lpar , CEC, or BPA has been defined in the nodelist, nodetype, ppc tables - -(4)Define the HMC related the above node as a node on the management node. For example, - -#nodeadd hmc01.clusters.com groups=hmc - -(5)Run the xdsh command to set up and generate the ssh keys on the xCAT management node and transfer the public key to the HMC. You must also manually configure the HMC to allow remote ssh connections. For example - -#xdsh hmc01.clusters.com -K - -or use other ways, for example: - -#ssh-keygen -t rsa; - -#ssh-keygen -t dsa; - -#cd /root/.ssh - -#ls; - -#firstkey=`cat id_dsa.pub` - -#ssh hscroot@c76v3hmc03.ppd.pok.ibm.com mkauthkeys -a \"$firstkey\" -Password: - -# secondkey=`cat id_rsa.pub` - -#ssh hscroot@c76v3hmc03.ppd.pok.ibm.com mkauthkeys -a \"$secondkey\" - -(6)If the firmware upgrade will be done through service node, the HMC or CEC and the corresponding service node have been add into the noderes table. - -(7)The update files are ready for the firmware upgrade. - -There are 2 B to show how to use this command. - =item 1 -To update only the power subsystem attached to a single HMC-attached pSeries CEC(Server-m_tmp-SNs_tmp), and recycle the power subsystem and all attached managed systems when the update is complete, and the Microcode update package and associated XML file are in /tmp/fw. +To update only the power subsystem attached to a single HMC-attached pSeries CEC(cec_name), and recycle the power subsystem and all attached managed systems when the update is complete, and the Microcode update package and associated XML file are in /tmp/fw, enter: -(1) Define the CEC as a device on the management node. - -B - -Modify the table nodehm - -B - -Modify the table nodetype: - -B - -Modify the table ppc: - -B - -Modify the tab vpd: - -B - -Set the account of the HMC(Modify the ppchcp): - -B - -(2) Generate the ssh keys on the xCAT management node and transfer the public key to the HMC to configure the HMC to allow remote ssh connections(Please see the item 5 of the prerequisites) - -(3)If a service node will be used, define the attribute values for specified service node(service node01) in servicenode table. (optional) - -(4)If the service node will be used, define the service node attribute values for the CEC. For example, (optional) - -B - -(5)Use rinv to check current code level - -B - -(6) Download the Microcode update package and associated XML file from the IBM Web site: I. Create the /tmp/fw directory, if necessary, and copy the downloaded files to the /tmp/fw directory. - -(7) Run the rflash command with the --activate flag to specify the update mode to perform the updates. - -B - -B: - -(1)You Need check your update is concurrent or disruptive here!! other commands sample: rflash Server-m_tmp-SNs_tmp -p /tmp/fw --activate concurrent - -(2)If the noderange is BPA/Lpar, the upgrade steps are the same as the CEC's - -(3)System p5 and p6 updates can require time to complete and there is no visual indication that the command is proceeding. +B I I<-p /tmp/fw> I<--activate disruptive> =item 2 -To commit currently activated LIC updates(copy T to P) for HMC-attached System p5 and p6 CEC +To update only the power subsystem attached to a single HMC-attached pSeries node, and recycle the power subsystem and all attached managed systems when the update is complete, and the Microcode update package and associated XML file are in /tmp/fw, enter: -(1-5) The 1-5 steps are the same as the (1-5) steps in B +B I I<-p /tmp/fw> I<--activate disruptive> -(6)Check the output of the step 5 that whether the LIC will be committed. If yes, run the step(7) +=item 3 -(7)Run the rflash command with “--commit” flag to finish the work +To commit a firmware update to permanent flash on an HMC-attached CEC, enter: -B - -B: - -(1)If the noderange is BPA/Lpar, the commit steps are the same as the CEC's. - -(2)If recover the installed LIC updates , the steps are the same as the (1-6) steps of this B. Only the last step is different. +B I I<--commit> =back