diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 8e439243b..b50f800b9 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -494,6 +494,13 @@ my %status_info = ( RVITALS_RESPONSE => { process => \&rvitals_response, }, + RVITALS_LEDS_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/led/physical/enumerate", + }, + RVITALS_LEDS_RESPONSE => { + process => \&rvitals_response, + }, RSPCONFIG_API_CONFIG_ON_REQUEST => { method => "PUT", init_url => "$openbmc_project_url", @@ -1124,7 +1131,7 @@ sub parse_args { } } elsif ($command eq "rvitals") { $subcommand = "all" if (!defined($ARGV[0])); - unless ($subcommand =~ /^temp$|^voltage$|^wattage$|^fanspeed$|^power$|^altitude$|^all$/) { + unless ($subcommand =~ /^leds$|^temp$|^voltage$|^wattage$|^fanspeed$|^power$|^altitude$|^all$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rflash") { @@ -1627,9 +1634,15 @@ sub parse_command_status { $subcommand = "all"; } - $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; - $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; - $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + if ($subcommand eq "leds") { + $next_status{LOGIN_RESPONSE} = "RVITALS_LEDS_REQUEST"; + $next_status{RVITALS_LEDS_REQUEST} = "RVITALS_LEDS_RESPONSE"; + $status_info{RVITALS_LEDS_RESPONSE}{argv} = "$subcommand"; + } else { + $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; + $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; + $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + } } if ($command eq "rflash") { @@ -3605,7 +3618,12 @@ sub rvitals_response { my $response_info = decode_json $response->content; - my $grep_string = $status_info{RVITALS_RESPONSE}{argv}; + my $grep_string; + if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { + $grep_string = $status_info{RVITALS_LEDS_RESPONSE}{argv}; + } else { + $grep_string = $status_info{RVITALS_RESPONSE}{argv}; + } my $src; my $content_info; my @sorted_output; @@ -3613,43 +3631,52 @@ sub rvitals_response { foreach my $key_url (keys %{$response_info->{data}}) { my %content = %{ ${ $response_info->{data} }{$key_url} }; - # - # Skip over attributes that are not asked to be printed - # - if ($grep_string =~ "temp") { - unless ( $content{Unit} =~ "DegreesC") { next; } - } - if ($grep_string =~ "voltage") { - unless ( $content{Unit} =~ "Volts") { next; } - } - if ($grep_string =~ "wattage") { - unless ( $content{Unit} =~ "Watts") { next; } - } - if ($grep_string =~ "fanspeed") { - unless ( $content{Unit} =~ "RPMS") { next; } - } - if ($grep_string =~ "power") { - unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } - } - if ($grep_string =~ "altitude") { - unless ( $content{Unit} =~ "Meters" ) { next; } - } - my $label = (split(/\//, $key_url))[ -1 ]; # replace underscore with space, uppercase the first letter $label =~ s/_/ /g; $label =~ s/\b(\w)/\U$1/g; + my $calc_value = undef; - # - # Calculate the adjusted value based on the scale attribute - # - my $calc_value = $content{Value}; - if ( $content{Scale} != 0 ) { - $calc_value = ($content{Value} * (10 ** $content{Scale})); + if ($node_info{$node}{cur_status} =~ "RVITALS_LEDS_RESPONSE") { + + # Print out Led info + $calc_value = (split(/\./, $content{State}))[-1]; + $content_info = $label . ": " . $calc_value ; + } else { + # print out Sensor info + # + # Skip over attributes that are not asked to be printed + # + if ($grep_string =~ "temp") { + unless ( $content{Unit} =~ "DegreesC") { next; } + } + if ($grep_string =~ "voltage") { + unless ( $content{Unit} =~ "Volts") { next; } + } + if ($grep_string =~ "wattage") { + unless ( $content{Unit} =~ "Watts") { next; } + } + if ($grep_string =~ "fanspeed") { + unless ( $content{Unit} =~ "RPMS") { next; } + } + if ($grep_string =~ "power") { + unless ( $content{Unit} =~ "Amperes" || $content{Unit} =~ "Joules" || $content{Unit} =~ "Watts" ) { next; } + } + if ($grep_string =~ "altitude") { + unless ( $content{Unit} =~ "Meters" ) { next; } + } + + # + # Calculate the adjusted value based on the scale attribute + # + $calc_value = $content{Value}; + if ( $content{Scale} != 0 ) { + $calc_value = ($content{Value} * (10 ** $content{Scale})); + } + + $content_info = $label . ": " . $calc_value . " " . $sensor_units{ $content{Unit} }; } - - $content_info = $label . ": " . $calc_value . " " . $sensor_units{ $content{Unit} }; push (@sorted_output, $content_info); #Save output in array } # If sorted array has any contents, sort it and print it