Commit d363797e authored by René Nussbaumer's avatar René Nussbaumer
Browse files

gnt-node power: Mark also offline when powering off


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 1ef6e776
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# C0103: Invalid name gnt-node # C0103: Invalid name gnt-node
from ganeti.cli import * from ganeti.cli import *
from ganeti import cli
from ganeti import bootstrap from ganeti import bootstrap
from ganeti import opcodes from ganeti import opcodes
from ganeti import utils from ganeti import utils
...@@ -476,8 +477,21 @@ def PowerNode(opts, args): ...@@ -476,8 +477,21 @@ def PowerNode(opts, args):
oob_command = "power-%s" % command oob_command = "power-%s" % command
op = opcodes.OpOobCommand(node_name=node, command=oob_command) opcodelist = []
result = SubmitOpCode(op, opts=opts) if oob_command == constants.OOB_POWER_OFF:
opcodelist.append(opcodes.OpSetNodeParams(node_name=node, offline=True,
auto_promote=opts.auto_promote))
opcodelist.append(opcodes.OpOobCommand(node_name=node, command=oob_command))
cli.SetGenericOpcodeOpts(opcodelist, opts)
job_id = cli.SendJob(opcodelist)
# We just want the OOB Opcode status
# If it fails PollJob gives us the error message in it
result = cli.PollJob(job_id)[-1]
if result: if result:
if oob_command == constants.OOB_POWER_STATUS: if oob_command == constants.OOB_POWER_STATUS:
text = "The machine is %spowered" text = "The machine is %spowered"
...@@ -735,7 +749,8 @@ commands = { ...@@ -735,7 +749,8 @@ commands = {
PowerNode, PowerNode,
[ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS), [ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS),
ArgNode(min=1, max=1)], ArgNode(min=1, max=1)],
[], "on|off|cycle|status <node>", [SUBMIT_OPT, AUTO_PROMOTE_OPT, PRIORITY_OPT],
"on|off|cycle|status <node>",
"Change power state of node by calling out-of-band helper."), "Change power state of node by calling out-of-band helper."),
'remove': ( 'remove': (
RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT, PRIORITY_OPT], RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT, PRIORITY_OPT],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment