1.Display system p LED values via rvitals; 2.Add option onstandby to rpower to power on CEC in standby mode
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2840 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -51,11 +51,21 @@ my %powercmd = ( | ||||
|   sys  => {  | ||||
|       reset =>"chsysstate -r %s -m %s -o off --immed --restart", | ||||
|       on    =>"chsysstate -r %s -m %s -o on", | ||||
|       onstandby =>"chsysstate -r %s -m %s -o onstandby", | ||||
|       off   =>"chsysstate -r %s -m %s -o off", | ||||
|       boot  =>"undetermined" } | ||||
| ); | ||||
|  | ||||
|  | ||||
| ############################################## | ||||
| # lsrefcode supported formats | ||||
| ############################################## | ||||
| my %lsrefcode = ( | ||||
|   fsp => { | ||||
|       pri =>"lsrefcode -r sys -m %s -s p", | ||||
|       sec =>"lsrefcode -r sys -m %s -s s", | ||||
|   }, | ||||
|   lpar   =>"lsrefcode -r lpar -m %s --filter lpar_ids=%s", | ||||
| ); | ||||
|  | ||||
| ########################################################################## | ||||
| # Logon to remote server | ||||
| @@ -288,6 +298,39 @@ sub chsyscfg { | ||||
|     return( $result ); | ||||
| } | ||||
|  | ||||
| ########################################################################## | ||||
| # List reference codes for resources (lpars, managed system, etc) | ||||
| ########################################################################## | ||||
| sub lsrefcode { | ||||
|  | ||||
|     my $exp = shift; | ||||
|     my $res = shift; | ||||
|     my $d1  = shift; | ||||
|     my $d2  = shift; | ||||
|     my $cmd = undef; | ||||
|     my @cmds = undef; | ||||
|     my $result = undef; | ||||
|     my @values; | ||||
|  | ||||
|     ################################### | ||||
|     # Select command   | ||||
|     ################################### | ||||
|     if($res eq 'fsp'){ | ||||
|         $cmds[0] = sprintf($lsrefcode{$res}{pri}, $d1); | ||||
|         $cmds[1] = sprintf($lsrefcode{$res}{sec}, $d1); | ||||
|     } elsif($res eq 'lpar'){ | ||||
|         $cmds[0] = sprintf($lsrefcode{$res}, $d1, $d2); | ||||
|     } | ||||
|  | ||||
|     ################################### | ||||
|     # Send command | ||||
|     ################################### | ||||
|     foreach $cmd (@cmds){ | ||||
|         $result = send_cmd( $exp, $cmd ); | ||||
|         push @values, $result; | ||||
|     } | ||||
|     return \@values; | ||||
| } | ||||
|  | ||||
| ########################################################################## | ||||
| # Creates a logical partition on the managed system  | ||||
| @@ -906,7 +949,6 @@ sub send_cmd { | ||||
|     ########################################## | ||||
|     $ssh->clear_accum(); | ||||
|     $ssh->send( "$cmd; echo Rc=\$\?\r" ); | ||||
|  | ||||
|     ########################################## | ||||
|     # The first element is the number of the | ||||
|     # pattern or string that matched, the | ||||
|   | ||||
| @@ -15,7 +15,7 @@ sub parse_args { | ||||
|     my $command = $request->{command}; | ||||
|     my $args    = $request->{arg}; | ||||
|     my %opt     = (); | ||||
|     my @rpower  = qw(on off stat state reset boot of); | ||||
|     my @rpower  = qw(on onstandby off stat state reset boot of); | ||||
|  | ||||
|     ############################################# | ||||
|     # Responds with usage statement | ||||
|   | ||||
| @@ -16,7 +16,7 @@ sub parse_args { | ||||
|     my $command = $request->{command}; | ||||
|     my $args    = $request->{arg}; | ||||
|     my %opt     = (); | ||||
|     my @rvitals = qw(temp voltage power state all); | ||||
|     my @rvitals = qw(temp voltage power lcds state all); | ||||
|  | ||||
|     ############################################# | ||||
|     # Responds with usage statement | ||||
| @@ -128,6 +128,37 @@ sub enumerate_temp { | ||||
|     return( [SUCCESS,\%outhash] ); | ||||
| } | ||||
|  | ||||
| ########################################################################## | ||||
| # Returns refcode | ||||
| ########################################################################## | ||||
| sub enumerate_lcds { | ||||
|  | ||||
|     my $exp = shift; | ||||
|     my $d = shift; | ||||
|     my $mtms = @$d[2]; | ||||
|     my $Rc = undef; | ||||
|     my $value = undef; | ||||
|     my $nodetype = @$d[4]; | ||||
|     my $lpar_id = @$d[0]; | ||||
|     my @refcode = (); | ||||
|      | ||||
|     my $values = xCAT::PPCcli::lsrefcode($exp, $nodetype, $mtms, $lpar_id); | ||||
|     foreach $value (@$values){ | ||||
|         #Return error | ||||
|         $Rc = shift @$value; | ||||
|         if ($Rc != SUCCESS){ | ||||
|             push @refcode, ( [$Rc, @$value[0]] ); | ||||
|         } else { | ||||
|             if( @$value[0] =~ /refcode=(\w+)/){ | ||||
|                   push @refcode, ( [$Rc, $1] ); | ||||
| 	    } else { | ||||
|                   push @refcode, ( [$Rc, @$value[0]]); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return \@refcode; | ||||
| } | ||||
|  | ||||
|  | ||||
| ########################################################################## | ||||
| @@ -292,7 +323,43 @@ sub power { | ||||
| sub state { | ||||
|     return( xCAT::PPCpower::state(@_,"System State: ")); | ||||
| } | ||||
|   | ||||
| ########################################################################### | ||||
| # Returns system LCD status (LCD1, LCD2) | ||||
| ########################################################################## | ||||
| sub lcds { | ||||
|     my $request = shift; | ||||
|     my $hash    = shift; | ||||
|     my $exp     = shift; | ||||
|     my $hwtype  = @$exp[2]; | ||||
|     my @result  = (); | ||||
|     my $text = "Current LCD:"; | ||||
|     my $prefix  = "Current LCD%d: %s"; | ||||
|     my $rcode = undef; | ||||
|     my $refcodes = undef; | ||||
|     my $Rc = undef; | ||||
|     my $num = undef; | ||||
|     my $value = undef; | ||||
|  | ||||
|     while (my ($mtms,$h) = each(%$hash) ) { | ||||
|         while(my ($name, $d) = each(%$h) ){ | ||||
|             #Support HMC only | ||||
|             if($hwtype ne 'hmc'){ | ||||
|                 push @result, [$name, "$text Not available(NO HMC)", 1]; | ||||
|                 next; | ||||
|             } | ||||
|             $refcodes = enumerate_lcds($exp, $d); | ||||
|             $num = 1; | ||||
|             foreach $rcode (@$refcodes){ | ||||
|                 $Rc = shift(@$rcode); | ||||
|                 $value = sprintf($prefix, $num, @$rcode[0]); | ||||
|                 push @result, [$name, $value, $Rc]; | ||||
|                 $num = $num + 1; | ||||
| 	    } | ||||
|         } | ||||
|     } | ||||
|     return \@result; | ||||
| } | ||||
|  | ||||
|  | ||||
| ########################################################################## | ||||
| # Returns all vitals | ||||
| @@ -303,7 +370,8 @@ sub all { | ||||
|         @{temp(@_)},  | ||||
|         @{voltage(@_)},  | ||||
|         @{state(@_)}, | ||||
|         @{power(@_)}  | ||||
|         @{power(@_)}, | ||||
| 	@{lcds(@_)},  | ||||
|     );  | ||||
|     return( \@values ); | ||||
| } | ||||
|   | ||||
| @@ -20,16 +20,18 @@ my %usage = ( | ||||
| "Usage: rnetboot <noderange> [-f][-V|--verbose] | ||||
|        rnetboot [-h|--help|-v|--version]", | ||||
|     "rpower" =>  | ||||
| "Usage: rpower <noderange> [--nodeps][on|off|reset|stat|state|boot|cycle|softoff] [-V|--verbose] | ||||
| "Usage: rpower <noderange> [--nodeps][on|onstandby|off|reset|stat|state|boot|cycle|softoff] [-V|--verbose] | ||||
|        rpower [-h|--help|-v|--version] | ||||
|      PPC (with IVM or HMC) specific: | ||||
|        rpower <noderange> [--nodeps] [of] [-V|--verbose] | ||||
|      PPC (HMC) specific: | ||||
|        rpower <noderange> [onstandby] [-V|--verbose] | ||||
| ", | ||||
|     "rbeacon" =>  | ||||
| "Usage: rbeacon <noderange> [on|off|stat] [-V|--verbose] | ||||
|        rbeacon [-h|--help|-v|--version]", | ||||
|     "rvitals" =>  | ||||
| "Usage: rvitals <noderange> [all|temp|wattage|voltage|fanspeed|power|leds|state] [-V|--verbose] | ||||
| "Usage: rvitals <noderange> [all|temp|wattage|voltage|fanspeed|power|leds|lcds|state] [-V|--verbose] | ||||
|        rvitals [-h|--help|-v|--version]", | ||||
|     "reventlog" =>  | ||||
| "Usage: reventlog <noderange> [all|clear|<number of entries to retrieve>] [-V|--verbose] | ||||
|   | ||||
| @@ -4,7 +4,7 @@ B<rpower> - remote power control of nodes | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|  | ||||
| B<rpower> I<noderange> [B<--nodeps>] {B<on>|B<off>|B<stat>|B<state>|B<reset>|B<boot>|B<cycle>|B<softoff>} | ||||
| B<rpower> I<noderange> [B<--nodeps>] {B<on>|B<onstandby>|B<off>|B<stat>|B<state>|B<reset>|B<boot>|B<cycle>|B<softoff>} | ||||
|  | ||||
| B<rpower> [B<-h>|B<--help>|B<-v>|B<--version>] | ||||
|  | ||||
| @@ -12,6 +12,10 @@ B<rpower> [B<-h>|B<--help>|B<-v>|B<--version>] | ||||
|  | ||||
| B<rpower> I<noderange> [B<--nodeps>] {B<of>} | ||||
|  | ||||
| =head2 PPC (with HMC) specific: | ||||
|  | ||||
| B<rpower> I<noderange> [B<onstandby>] | ||||
|  | ||||
| =head1 DESCRIPTION | ||||
|  | ||||
| B<rpower> controls the power for a single or range of nodes,  via the out-of-band path. | ||||
| @@ -24,6 +28,10 @@ B<rpower> controls the power for a single or range of nodes,  via the out-of-ban | ||||
|  | ||||
| Turn power on. | ||||
|  | ||||
| =item B<onstandby> | ||||
|  | ||||
| Turn power on to standby state | ||||
|  | ||||
| =item B<softoff> | ||||
|  | ||||
| Attempt to request clean shutdown of OS (may not detect failures in completing command) | ||||
|   | ||||
| @@ -4,7 +4,7 @@ B<rvitals> - remote hardware vitals | ||||
|  | ||||
| =head1 B<Synopsis> | ||||
|  | ||||
| B<rvitals> I<noderange> {B<temp>|B<voltage>|B<wattage>|B<fanspeed>|B<power>|B<leds>|B<summary>|B<all>} | ||||
| B<rvitals> I<noderange> {B<temp>|B<voltage>|B<wattage>|B<fanspeed>|B<power>|B<leds>|B<lcds>|B<summary>|B<all>} | ||||
|  | ||||
| B<rvitals> [B<-h>|B<--help>|B<-v>|B<--version>] | ||||
|  | ||||
| @@ -59,6 +59,10 @@ unless the Service Processor flash gets updated. | ||||
|  | ||||
| Retrieves the system state. | ||||
|  | ||||
| =item B<lcds> | ||||
|  | ||||
| Retrieves LCDs status. | ||||
|  | ||||
| =item B<all> | ||||
|  | ||||
| All of the above. | ||||
| @@ -95,6 +99,7 @@ B<rvitals> I<node5> I<all> | ||||
|  node5: Fan 5 Percent of max:   100% | ||||
|  node5: Fan 6 Percent of max:   100% | ||||
|  node5: Current Power Status On | ||||
|  node5: Current LCD1: SuSE Linux | ||||
|  node5: Power On Seconds  11855915 | ||||
|  node5: Number of Reboots   930 | ||||
|  node5: System State Booting OS or in unsupported OS | ||||
|   | ||||
		Reference in New Issue
	
	Block a user