From cdd52eb6d99871a2609054718cbb59da156645f4 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 28 Jan 2020 15:06:20 -0500 Subject: [PATCH] OpenBMC rvitals command to handle varable number of fans --- .../manage_clusters/common/parallel_cmd.rst | 2 +- xCAT-server/lib/xcat/plugins/openbmc.pm | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst b/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst index 07b52060a..a079f6082 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/parallel_cmd.rst @@ -31,7 +31,7 @@ Examples for xdsh - To run the ``ps`` command on node targets node1 and run the remote command with the ``-v`` and ``-t`` flag, enter: :: - xdsh node1,node2 -o"-v -t" ps =item * + xdsh node1,node2 -o "-v -t" ps - To execute the commands contained in myfile in the XCAT context on several node targets, with a fanout of 1, enter: :: diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 55a69df29..6681768f9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -4409,6 +4409,7 @@ sub rvitals_response { my @sorted_output; my %leds = (); + my $number_of_fan_leds = 0; foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; @@ -4425,10 +4426,11 @@ sub rvitals_response { $calc_value = (split(/\./, $content{State}))[-1]; $content_info = $label . ": " . $calc_value ; - if ($key_url =~ "fan0") { $leds{fan0} = $calc_value; } - if ($key_url =~ "fan1") { $leds{fan1} = $calc_value; } - if ($key_url =~ "fan2") { $leds{fan2} = $calc_value; } - if ($key_url =~ "fan3") { $leds{fan3} = $calc_value; } + # There could be multiple fan LEDs. Match a string "fan" followed by digits, but only at the end of a string + if ($key_url =~ /fan(\d+)$/) { + $leds{"fan" . $1} = $calc_value; + $number_of_fan_leds++; + } if ($key_url =~ "front_id") { $leds{front_id} = $calc_value; } if ($key_url =~ "front_fault") { $leds{front_fault} = $calc_value; } if ($key_url =~ "front_power") { $leds{front_power} = $calc_value; } @@ -4500,7 +4502,7 @@ sub rvitals_response { } } # Fans - for (my $i = 0; $i < 4; $i++) { + for (my $i = 0; $i < $number_of_fan_leds; $i++) { my $tmp_key = "fan" . $i; $content_info = "LEDs Fan$i: $leds{$tmp_key}"; push (@sorted_output, $content_info);