From 2809799defe98f7e31e7a7dd26ed1262032d5c85 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 3 Feb 2012 19:58:11 +0000 Subject: [PATCH] If we are faced with a system without an AC energy reading, we were missing the chance to init the precision data. Now init it regardless git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11472 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/ipmi.pm | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index c9665eb4e..11cdd48c5 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -3805,6 +3805,14 @@ sub readenergy { initiem($sessdata); } sub readenergy_withiem { + my $sessdata = shift; + $sessdata->{iem}->prep_get_precision(); + $sessdata->{iemcallback} = \&got_precision; + execute_iem_commands($sessdata); #this gets all precision data initialized for AC and DC + # we need not make use of the generic extraction function, so we call execute_iem instead of process_data + #sorry the perl api I wrote sucks.. +} +sub got_precision { my $sessdata = shift; $sessdata->{iem}->prep_get_ac_energy(); $sessdata->{iemcallback} = \&got_ac_energy; @@ -3812,21 +3820,22 @@ sub readenergy_withiem { } sub got_ac_energy { my $sessdata = shift; - if ($sessdata->{abortediem}) { + unless ($sessdata->{abortediem}) { + $sessdata->{iemtextdata} .= sprintf(" +/-%.1f%%",$sessdata->{iem}->energy_ac_precision()*0.1); #note while \x{B1} would be cool, it's non-trivial to support + xCAT::SvrUtils::sendmsg($sessdata->{iemtextdata},$callback,$sessdata->{node},%allerrornodes); $sessdata->{abortediem}=0; + } + #this would be 'if sessdata->{abortediem}'. Thus far this is only triggered in the case of a system that fairly obviously + #shouldn't have an AC meter. As a consequence, don't output data that would suggest a user might actually get it + #in that case, another entity can provide a measure of the AC usage, but only an aggregate measure not an individual measure # $sessdata->{iemtextdata} = "AC Energy Usage: "; # if ($sessdata->{abortediemreason}) { # $sessdata->{iemtextdata} .= $sessdata->{abortediemreason}; # } # xCAT::SvrUtils::sendmsg($sessdata->{iemtextdata},$callback,$sessdata->{node},%allerrornodes); - $sessdata->{iem}->prep_get_dc_energy(); - $sessdata->{iemcallback} = \&got_dc_energy; - process_data_from_iem($sessdata); - return; - } - $sessdata->{iem}->prep_get_precision(); - $sessdata->{iemcallback} = \&got_ac_energy_with_precision; - execute_iem_commands($sessdata); #this gets all precision data initialized + $sessdata->{iem}->prep_get_dc_energy(); + $sessdata->{iemcallback} = \&got_dc_energy; + process_data_from_iem($sessdata); } sub got_ac_energy_with_precision { my $sessdata=shift;