diff --git a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_sensor.py b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_sensor.py index 7abd4c31d..12ccefaa7 100644 --- a/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_sensor.py +++ b/xCAT-openbmc-py/lib/python/agent/hwctl/executor/openbmc_sensor.py @@ -34,27 +34,26 @@ class OpenBMCSensorTask(ParallelNodesCommand): def _get_beacon_info(self, beacon_dict, display_type='full'): + led_label = 'LEDs' info_list = [] # display_type == 'full' for detailed output for 'rvitals leds' command # display_type == 'compact' for compact output for 'rbeacon stat' command if display_type == 'compact': - info_list.append('Front:%s Rear:%s' % (beacon_dict.get('front_id'), beacon_dict.get('rear_id', 'N/A'))) + info_list.append('Front:%s Rear:%s' % (beacon_dict.get('front_id'), beacon_dict.get('rear_id', 'N/A'))) return info_list - info_list.append('Front . . . . . : Power:%s Fault:%s Identify:%s' % - (beacon_dict.get('front_power', 'N/A'), - beacon_dict.get('front_fault', 'N/A'), - beacon_dict.get('front_id', 'N/A'))) - if (beacon_dict.get('fan0', 'N/A') == 'Off' and beacon_dict.get('fan1', 'N/A') == 'Off' and - beacon_dict.get('fan2', 'N/A') == 'Off' and beacon_dict.get('fan3', 'N/A') == 'Off'): - info_list.append('Front Fans . . : No LEDs On') - else: - info_list.append('Front Fans . . : fan0:%s fan1:%s fan2:%s fan3:%s' % - (beacon_dict.get('fan0', 'N/A'), beacon_dict.get('fan1', 'N/A'), - beacon_dict.get('fan2', 'N/A'), beacon_dict.get('fan3', 'N/A'))) - info_list.append('Rear . . . . . : Power:%s Fault:%s Identify:%s' % - (beacon_dict.get('rear_power', 'N/A'), - beacon_dict.get('rear_fault', 'N/A'), - beacon_dict.get('rear_id', 'N/A'))) + + for i in range(4): + info_list.append('%s Fan%s: %s' % (led_label, i, beacon_dict.get('fan' + str(i), 'N/A'))) + + led_types = ('Fault', 'Identify', 'Power') + for i in ('Front', 'Rear'): + for led_type in led_types: + tmp_type = led_type.lower() + if led_type == 'Identify': + tmp_type = 'id' + key_type = i.lower() + '_' + tmp_type + info_list.append('%s %s %s: %s' % (led_label, i, led_type, beacon_dict.get(key_type, 'N/A'))) + return info_list diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index f576e20a5..5a1723ef7 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1863,6 +1863,10 @@ sub parse_command_status { $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + if ($subcommand eq "all") { + $next_status{RVITALS_RESPONSE} = "RVITALS_LEDS_REQUEST"; + $next_status{RVITALS_LEDS_REQUEST} = "RVITALS_LEDS_RESPONSE"; + } } } @@ -4150,17 +4154,23 @@ sub rvitals_response { push (@sorted_output, $content_info); } else { # Full output for "rvitals leds" command - $content_info = "Front . . . . . : Power:$leds{front_power} Fault:$leds{front_fault} Identify:$leds{front_id}"; - push (@sorted_output, $content_info); - $content_info = "Rear . . . . . : Power:$leds{rear_power} Fault:$leds{rear_fault} Identify:$leds{rear_id}"; - push (@sorted_output, $content_info); - # Fans - if ($leds{fan0} =~ "Off" and $leds{fan1} =~ "Off" and $leds{fan2} eq "Off" and $leds{fan3} eq "Off") { - $content_info = "Front Fans . . : No LEDs On"; - } else { - $content_info = "Front Fans . . : fan0:$leds{fan0} fan1:$leds{fan1} fan2:$leds{fan2} fan3:$leds{fan3}"; - } - push (@sorted_output, $content_info); + my @front_rear = ("Front", "Rear"); + my @led_types = ("Power", "Fault", "Identify"); + foreach my $i (@front_rear) { + foreach my $led_type (@led_types) { + my $tmp_type = lc($led_type); + $tmp_type = "id" if ($led_type eq "Identify"); + my $key_type = lc($i) . "_" . $tmp_type; + $content_info = "LEDs $i $led_type: $leds{$key_type}"; + push (@sorted_output, $content_info); + } + } + # Fans + for (my $i = 0; $i < 4; $i++) { + my $tmp_key = "fan" . $i; + $content_info = "LEDs Fan$i: $leds{$tmp_key}"; + push (@sorted_output, $content_info); + } } }