diff --git a/docs/source/guides/admin-guides/references/man1/rvitals.1.rst b/docs/source/guides/admin-guides/references/man1/rvitals.1.rst index 55d29d53b..e6929cdfc 100644 --- a/docs/source/guides/admin-guides/references/man1/rvitals.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rvitals.1.rst @@ -60,7 +60,7 @@ OpenPOWER server specific: ========================== -\ **rvitals**\ \ *noderange*\ {\ **temp | voltage | wattage | fanspeed | power | leds | all**\ } +\ **rvitals**\ \ *noderange*\ [\ **temp | voltage | wattage | fanspeed | power | leds | all**\ ] diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index cfad04bac..01ed1cb1c 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -76,7 +76,7 @@ my %usage = ( BMC specific: rvitals noderange {temp|voltage|wattage|fanspeed|power|leds|all} OpenPOWER server specific: - rvitals noderange {temp|voltage|wattage|fanspeed|power|leds|all} + rvitals noderange [temp|voltage|wattage|fanspeed|power|leds|all] MIC specific: rvitals noderange {thermal|all}", "reventlog" => diff --git a/xCAT-client/pods/man1/rvitals.1.pod b/xCAT-client/pods/man1/rvitals.1.pod index 3bce77fa8..32ff2fb81 100644 --- a/xCAT-client/pods/man1/rvitals.1.pod +++ b/xCAT-client/pods/man1/rvitals.1.pod @@ -28,7 +28,7 @@ B I {B|B|B|B|B|B I {B|B|B|B|B|B|B} +B I [B|B|B|B|B|B|B] =head1 B diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 2fb93bf51..8c46fd90c 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -168,6 +168,13 @@ my %status_info = ( RSPCONFIG_SET_RESPONSE => { process => \&rspconfig_response, }, + RVITALS_REQUEST => { + method => "GET", + init_url => "$openbmc_project_url/sensors/enumerate", + }, + RVITALS_RESPONSE => { + process => \&rvitals_response, + }, ); $::RESPONSE_OK = "200 OK"; @@ -361,7 +368,7 @@ sub parse_args { return ([ 1, "No option specified for $command" ]); } - if (scalar(@ARGV) > 1 and ($command =~ /rpower|rinv|rsetboot/)) { + if (scalar(@ARGV) > 1 and ($command =~ /rpower|rinv|rsetboot|rvitals/)) { return ([ 1, "Only one option is supported at the same time" ]); } @@ -429,6 +436,12 @@ sub parse_args { return ([ 1, "Unsupported command: $command $subcommand" ]); } } + } elsif ($command eq "rvitals") { + $check = unsupported($callback); if (ref($check) eq "ARRAY") { return $check; } + $subcommand = "all" if (!defined($ARGV[0])); + unless ($subcommand =~ /^temp$|^voltage$|^wattage$|^fanspeed$|^power$|^leds$|^all$/) { + return ([ 1, "Unsupported command: $command $subcommand" ]); + } } else { return ([ 1, "Command is not supported." ]); } @@ -562,6 +575,18 @@ sub parse_command_status { return 1; } + if ($command eq "rvitals") { + if (defined($ARGV[0])) { + $subcommand = $ARGV[0]; + } else { + $subcommand = "all"; + } + + $next_status{LOGIN_RESPONSE} = "RVITALS_REQUEST"; + $next_status{RVITALS_REQUEST} = "RVITALS_RESPONSE"; + $status_info{RVITALS_RESPONSE}{argv} = "$subcommand"; + } + print Dumper(\%next_status) . "\n"; return; } @@ -1090,4 +1115,48 @@ sub rspconfig_response { } } +#------------------------------------------------------- + +=head3 rvitals_response + + Deal with response of rvitals command + Input: + $node: nodename of current response + $response: Async return response + +=cut + +#------------------------------------------------------- +sub rvitals_response { + my $node = shift; + my $response = shift; + + my $response_info = decode_json $response->content; + + my $grep_string = $status_info{RVITALS_RESPONSE}{argv}; + my $src; + my $content_info; + my $sensor_value; + + xCAT::SvrUtils::sendmsg("Processing command rvitals $grep_string", $callback, $node); + + foreach my $key_url (keys %{$response_info->{data}}) { + my %content = %{ ${ $response_info->{data} }{$key_url} }; + #print Dumper(%{$response_info->{data}}) . "\n"; + #print Dumper(%content) . "\n"; + $sensor_value = $key_url . " " . $content{Value}; + xCAT::SvrUtils::sendmsg("$sensor_value", $callback, $node); + } + + if ($next_status{ $node_info{$node}{cur_status} }) { + $node_info{$node}{cur_status} = $next_status{ $node_info{$node}{cur_status} }; + gen_send_request($node); + } else { + $wait_node_num--; + } + + return; +} + + 1;