From 19a0470374a7aecec8d1829bbb67f9e14cf865ea Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 11 Jul 2017 22:14:58 -0400 Subject: [PATCH 1/3] Add rpower bmcreboot command for openbmc --- xCAT-server/lib/xcat/plugins/openbmc.pm | 31 ++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index 48f584900..45613a4a3 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -31,12 +31,13 @@ use xCAT_monitoring::monitorctrl; $::VERBOSE = 0; # String constants for rpower states -$::POWER_STATE_OFF="off"; -$::POWER_STATE_ON="on"; -$::POWER_STATE_POWERING_OFF="powering-off"; -$::POWER_STATE_POWERING_ON="powering-on"; -$::POWER_STATE_QUIESCED="quiesced"; -$::POWER_STATE_RESET="reset"; +$::POWER_STATE_OFF = "off"; +$::POWER_STATE_ON = "on"; +$::POWER_STATE_POWERING_OFF = "powering-off"; +$::POWER_STATE_POWERING_ON = "powering-on"; +$::POWER_STATE_QUIESCED = "quiesced"; +$::POWER_STATE_RESET = "reset"; +$::POWER_STATE_REBOOT = "reboot"; $::UPLOAD_FILE=""; $::NO_ATTRIBUTES_RETURNED="No attributes returned from the BMC."; @@ -152,6 +153,11 @@ my %status_info = ( process => \&rinv_response, }, + RPOWER_BMCREBOOT_REQUEST => { + method => "PUT", + init_url => "$openbmc_project_url/state/bmc0/attr/RequestedBMCTransition", + data => "xyz.openbmc_project.State.BMC.Transition.Reboot", + }, RPOWER_ON_REQUEST => { method => "PUT", init_url => "$openbmc_project_url/state/host0/attr/RequestedHostTransition", @@ -446,7 +452,7 @@ sub parse_args { } if ($command eq "rpower") { - unless ($subcommand =~ /^on$|^off$|^softoff$|^reset$|^boot$|^bmcstate$|^status$|^stat$|^state$/) { + unless ($subcommand =~ /^on$|^off$|^softoff$|^reset$|^boot$|^bmcreboot$|^bmcstate$|^status$|^stat$|^state$/) { return ([ 1, "Unsupported command: $command $subcommand" ]); } } elsif ($command eq "rinv") { @@ -592,6 +598,10 @@ sub parse_command_status { $next_status{RPOWER_ON_REQUEST} = "RPOWER_ON_RESPONSE"; $next_status{RPOWER_STATUS_RESPONSE}{ON} = "RPOWER_RESET_REQUEST"; $next_status{RPOWER_RESET_REQUEST} = "RPOWER_RESET_RESPONSE"; + } elsif ($subcommand eq "bmcreboot") { + $next_status{LOGIN_RESPONSE} = "RPOWER_BMCREBOOT_REQUEST"; + $next_status{RPOWER_BMCREBOOT_REQUEST} = "RPOWER_RESET_RESPONSE"; + $status_info{RPOWER_RESET_RESPONSE}{argv} = "$subcommand"; } } @@ -1026,7 +1036,12 @@ sub rpower_response { if ($node_info{$node}{cur_status} eq "RPOWER_RESET_RESPONSE") { if ($response_info->{'message'} eq $::RESPONSE_OK) { - xCAT::SvrUtils::sendmsg("$::POWER_STATE_RESET", $callback, $node); + if (defined $status_info{RPOWER_RESET_RESPONSE}{argv} and $status_info{RPOWER_RESET_RESPONSE}{argv} =~ /bmcreboot$/) { + my $bmc_node = "$node BMC"; + xCAT::SvrUtils::sendmsg("$::POWER_STATE_REBOOT", $callback, $bmc_node); + } else { + xCAT::SvrUtils::sendmsg("$::POWER_STATE_RESET", $callback, $node); + } $new_status{$::STATUS_POWERING_ON} = [$node]; } } From d84490af02f61bd79656ede5f2218859c75c7bd2 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 12 Jul 2017 21:09:15 -0400 Subject: [PATCH 2/3] add related docs --- docs/source/guides/admin-guides/references/man1/rpower.1.rst | 2 +- perl-xCAT/xCAT/Usage.pm | 4 ++-- xCAT-client/pods/man1/rpower.1.pod | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rpower.1.rst b/docs/source/guides/admin-guides/references/man1/rpower.1.rst index 535687134..52dc597c1 100644 --- a/docs/source/guides/admin-guides/references/man1/rpower.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rpower.1.rst @@ -45,7 +45,7 @@ OpenPOWER OpenBMC: ================== -\ **rpower**\ \ *noderange*\ [\ **off | on | softoff | reset | boot | bmcstate | stat | state | status**\ ] +\ **rpower**\ \ *noderange*\ [\ **off | on | softoff | reset | boot | bmcreboot | bmcstate | stat | state | status**\ ] PPC (with IVM or HMC) specific: diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 4ca8093c0..f69ce7dab 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -29,10 +29,10 @@ my %usage = ( rpower noderange [on|off|softoff|reset|boot|stat|state|status|wake|suspend [-w timeout] [-o] [-r]] rpower noderange [pduon|pduoff|pdustat] OpenPOWER BMC: - rpower noderange [on|off|softoff|reset|boot|bmcstate|stat|state|status] + rpower noderange [on|off|reset|boot|stat|state|status] rpower noderange [pduon|pduoff|pdustat] OpenPOWER OpenBMC: - rpower noderange [on|off|reset|boot|stat|state|status] + rpower noderange [on|off|softoff|reset|boot|bmcreboot|bmcstate|stat|state|status] KVM Virtualization specific: rpower [boot] [ -c ] PPC (with IVM or HMC) specific: diff --git a/xCAT-client/pods/man1/rpower.1.pod b/xCAT-client/pods/man1/rpower.1.pod index 4939196db..24fd01e82 100644 --- a/xCAT-client/pods/man1/rpower.1.pod +++ b/xCAT-client/pods/man1/rpower.1.pod @@ -22,7 +22,7 @@ B I [B|B|B|B] =head2 OpenPOWER OpenBMC: -B I [B|B|B|B|B|B|B|B|B] +B I [B|B|B|B|B|B|B|B|B|B] =head2 PPC (with IVM or HMC) specific: From 882d47c2b5fe863da7a89564a69906da3210e9d0 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 13 Jul 2017 20:57:42 -0400 Subject: [PATCH 3/3] add describe of bmcreboot --- .../source/guides/admin-guides/references/man1/rpower.1.rst | 6 ++++++ xCAT-client/pods/man1/rpower.1.pod | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docs/source/guides/admin-guides/references/man1/rpower.1.rst b/docs/source/guides/admin-guides/references/man1/rpower.1.rst index 52dc597c1..1dee1d74a 100644 --- a/docs/source/guides/admin-guides/references/man1/rpower.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rpower.1.rst @@ -380,6 +380,12 @@ OPTIONS +\ **bmcreboot**\ + + To reboot BMC. + + + \ **bmcstate**\ To get state of the BMC. diff --git a/xCAT-client/pods/man1/rpower.1.pod b/xCAT-client/pods/man1/rpower.1.pod index 24fd01e82..2c5683fb1 100644 --- a/xCAT-client/pods/man1/rpower.1.pod +++ b/xCAT-client/pods/man1/rpower.1.pod @@ -247,6 +247,10 @@ To pause all processes in the instance. To unpause all processes in the instance. +=item B + +To reboot BMC. + =item B To get state of the BMC.