From d1a01cc53fa5d85f9bd8fd756460f8aaeae50812 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 14 Dec 2009 18:32:00 +0000 Subject: [PATCH] -Support multiple rvitals arguments for IPMI git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4769 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/ipmi.pm.2 | 66 +++++++++++++++----------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm.2 b/xCAT-server/lib/xcat/plugins/ipmi.pm.2 index 66a98528b..872df8ce4 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm.2 +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm.2 @@ -4447,11 +4447,13 @@ sub checkleds { sub vitals { my $subcommand = shift; + my @textfilters = split /,/,$subcommand; + unless (scalar @textfilters) { @textfilters = ("all"); } my $rc = 0; my $text; my $key; - my @sensor_filters=(0x00); + my %sensor_filters=(); my @output; my $reading; my $unitdesc; @@ -4462,36 +4464,38 @@ sub vitals { my $doall; $doall=0; $rc=0; + #filters: defined in sensor type codes and data table + # 1 == temp, 2 == voltage 3== current (we lump in wattage here for lack of a better spot), 4 == fan - if($subcommand eq "all") { - @sensor_filters=(0x01); #,0x02,0x03,0x04); + if(grep { $_ eq "all"} @textfilters) { + $sensor_filters{1}=1; #,0x02,0x03,0x04); rather than filtering, unfiltered results + $sensor_filters{energy}=1; $doall=1; } - elsif($subcommand =~ /temp/) { - @sensor_filters=(0x01); + if(grep /temp/,@textfilters) { + $sensor_filters{0x01}=1; } - elsif($subcommand eq "voltage") { - @sensor_filters=(0x02); + if(grep /volt/,@textfilters) { + $sensor_filters{0x02}=1; } - elsif($subcommand =~ /watt/) { - @sensor_filters=(0x03); + if(grep /watt/,@textfilters) { + $sensor_filters{0x03}=1; } - elsif($subcommand eq "fanspeed") { - @sensor_filters=(0x04); + if(grep /fan/,@textfilters) { + $sensor_filters{0x04}=1; } - elsif($subcommand eq "power") { - ($rc,$text) = power("stat"); - $text = sprintf($format,"Power Status:",$text); - return($rc,$text); + if(grep /power/,@textfilters) { #power does not really include energy, but most people use 'power' to mean both + $sensor_filters{0x03}=1; + $sensor_filters{powerstate}=1; + $sensor_filters{energy}=1; } - elsif($subcommand eq "leds") { - my @cleds; - ($rc,@cleds) = checkleds(); - foreach $text (@cleds) { - push(@output,$text); - } + if(grep /energy/,@textfilters) { + $sensor_filters{energy}=1; } - else { + if(grep /led/,@textfilters) { + $sensor_filters{leds}=1; + } + unless (keys %sensor_filters) { return(1,"unsupported command vitals $subcommand"); } @@ -4500,8 +4504,9 @@ sub vitals { return($rc,$text); } - foreach(@sensor_filters) { + foreach(keys %sensor_filters) { my $filter = $_; + if ($filter eq "energy" or $filter eq "leds") { next; } foreach $key (sort {$sdr_hash{$a}->id_string cmp $sdr_hash{$b}->id_string} keys %sdr_hash) { my $sdr = $sdr_hash{$key}; @@ -4585,15 +4590,20 @@ sub vitals { } } - if($subcommand eq "all") { + if($sensor_filters{leds}) { my @cleds; + ($rc,@cleds) = checkleds(); + push @output,@cleds; + } + if ($sensor_filters{powerstate}) { ($rc,$text) = power("stat"); $text = sprintf($format,"Power Status:",$text,""); push(@output,$text); - ($rc,@cleds) = checkleds(); - push @output,@cleds; - ($rc,@cleds)=readenergy(); - push @output,@cleds; + } + if ($sensor_filters{energy}) { + my @energies; + ($rc,@energies)=readenergy(); + push @output,@energies; } return($rc,@output);