X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/792af3ad1138c34c9839f3b6c7c2e9de78e4c120..dd94e9f63f6200172a4cbf3b835679ee55f4bc66:/lib/client/gnt_node.py diff --git a/lib/client/gnt_node.py b/lib/client/gnt_node.py index 7f9e29f..24a9b25 100644 --- a/lib/client/gnt_node.py +++ b/lib/client/gnt_node.py @@ -27,6 +27,7 @@ # C0103: Invalid name gnt-node from ganeti.cli import * +from ganeti import cli from ganeti import bootstrap from ganeti import opcodes from ganeti import utils @@ -476,8 +477,21 @@ def PowerNode(opts, args): oob_command = "power-%s" % command - op = opcodes.OpOobCommand(node_name=node, command=oob_command) - result = SubmitOpCode(op, opts=opts) + opcodelist = [] + 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 oob_command == constants.OOB_POWER_STATUS: text = "The machine is %spowered" @@ -666,7 +680,8 @@ def SetNodeParams(opts, args): secondary_ip=opts.secondary_ip, force=opts.force, ndparams=opts.ndparams, - auto_promote=opts.auto_promote) + auto_promote=opts.auto_promote, + powered=opts.node_powered) # even if here we process the result, we allow submit only result = SubmitOrSend(op, opts) @@ -725,7 +740,8 @@ commands = { SetNodeParams, ARGS_ONE_NODE, [FORCE_OPT, SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT, CAPAB_MASTER_OPT, CAPAB_VM_OPT, SECONDARY_IP_OPT, - AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT], + AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT, + NODE_POWERED_OPT], "", "Alters the parameters of a node"), 'powercycle': ( PowercycleNode, ARGS_ONE_NODE, @@ -735,7 +751,8 @@ commands = { PowerNode, [ArgChoice(min=1, max=1, choices=_LIST_POWER_COMMANDS), ArgNode(min=1, max=1)], - [], "on|off|cycle|status ", + [SUBMIT_OPT, AUTO_PROMOTE_OPT, PRIORITY_OPT], + "on|off|cycle|status ", "Change power state of node by calling out-of-band helper."), 'remove': ( RemoveNode, ARGS_ONE_NODE, [DRY_RUN_OPT, PRIORITY_OPT],