From 922b1b4a55ee67d68a9e50e848b7341c42a7d9c7 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sat, 13 Sep 2008 20:17:17 +0000 Subject: [PATCH] -Rework blade LED code to be less wordy when LEDs out and faster in retrieving them git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2162 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/blade.pm | 71 +++++++++++++++++++-------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 158fc124f..a2f39d2b5 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -796,42 +796,73 @@ sub vitals { push @output,"$tmp"; } + my %ledresults=(); + my $ledstring=""; + if (grep /led/,@vitems) { + my @bindset = ( + [$erroroid,$slot], + [$beaconoid,$slot], + [$infooid,$slot], + [$kvmoid,$slot], + [$mtoid,$slot], + ); + my $bindlist = new SNMP::VarList(@bindset); + $session->get($bindlist); + foreach (@$bindlist) { + $ledresults{$_->[0] .".". $_->[1]}=$_->[2]; + } + } if (grep /errorled/,@vitems) { - my $stat = $session->get([$erroroid.".".$slot]); - if ($stat==0) { $stat = "off"; } elsif ($stat==1) { $stat = "on"; } - $tmp="Error led: ".$stat; - push @output,"$tmp"; + my $stat = $ledresults{".".$erroroid.".".$slot}; #$session->get([$erroroid.".".$slot]); + if ($stat==1) { + $ledstring=1; + push @output,"Error LED: on"; + } + #$tmp="Error led: ".$stat; } if (grep /beaconled/,@vitems) { - my $stat = $session->get([$beaconoid.".".$slot]); - if ($stat==0) { $stat = "off"; } elsif ($stat==1) { $stat = "on"; } + my $stat = $ledresults{".".$beaconoid.".".$slot}; #$session->get([$beaconoid.".".$slot]); + if ($stat==1) { $stat = "on"; } elsif ($stat==2) { $stat = "blinking"; } - $tmp="Beacon led: ".$stat; - push @output,"$tmp"; + if ($stat) { + $ledstring=1; + $tmp="Beacon led: ".$stat; + push @output,"$tmp"; + } } if (grep /infoled/,@vitems) { - my $stat = $session->get([$infooid.".".$slot]); - if ($stat==0) { $stat = "off"; } elsif ($stat==1) { $stat = "on"; } - $tmp="Info led: ".$stat; - push @output,"$tmp"; + my $stat = $ledresults{".".$infooid.".".$slot}; #$session->get([$infooid.".".$slot]); + if ($stat==1) { + $ledstring=1; + push @output,"Info led: on"; + } } if (grep /kvmled/,@vitems) { - my $stat = $session->get([$kvmoid.".".$slot]); - if ($stat==0) { $stat = "off"; } elsif ($stat==1) { $stat = "on"; } + my $stat = $ledresults{".".$kvmoid.".".$slot}; #$session->get([$kvmoid.".".$slot]); + if ($stat==1) { $stat = "on"; } elsif ($stat==2) { $stat = "blinking"; } - $tmp="KVM led: ".$stat; - push @output,$tmp; + if ($stat) { + $ledstring=1; + $tmp="KVM led: ".$stat; + push @output,$tmp; + } } if (grep /mtled/,@vitems) { - my $stat = $session->get([$mtoid.".".$slot]); - if ($stat==0) { $stat = "off"; } elsif ($stat==1) { $stat = "on"; } + my $stat = $ledresults{".".$mtoid.".".$slot}; #$session->get([$mtoid.".".$slot]); + if ($stat==1) { $stat = "on"; } elsif ($stat==2) { $stat = "blinking"; } - $tmp="MT led: ".$stat; - push @output,"$tmp"; + if ($stat) { + $ledstring=1; + $tmp="MT led: ".$stat; + push @output,"$tmp"; + } + } + if (grep /led/,@vitems and not $ledstring) { + push @output,"No active LEDS"; } } else { #-- chassis query