diff --git a/lib/backend.py b/lib/backend.py index 2cb5ba1b7cdd59d412fa7daaf8cb120bd8207cce..b6f7ceb098a6182886f710489c54b66854389dd8 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1755,6 +1755,27 @@ def UploadFile(file_name, data, mode, uid, gid, atime, mtime): atime=atime, mtime=mtime) +def RunOob(oob_program, command, node, timeout): + """Executes oob_program with given command on given node. + + @param oob_program: The path to the executable oob_program + @param command: The command to invoke on oob_program + @param node: The node given as an argument to the program + @param timeout: Timeout after which we kill the oob program + + @return: stdout + @raise RPCFail: If execution fails for some reason + + """ + result = utils.RunCmd([oob_program, command, node], timeout=timeout) + + if result.failed: + _Fail("'%s' failed with reason '%s'; output: %s", result.cmd, + result.fail_reason, result.output) + + return result.stdout + + def WriteSsconfFiles(values): """Update all ssconf files. diff --git a/lib/constants.py b/lib/constants.py index cd6d4fe4bde23237355b621811c3fcbda8f9ab11..ffb0dabff5bfe8e9dcee24e92258a61dc9b1030e 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -645,6 +645,16 @@ NDS_PARAMETER_TYPES = { NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys()) +# OOB supported commands +OOB_POWER_ON = "power-on" +OOB_POWER_OFF = "power-off" +OOB_POWER_CYCLE = "power-cycle" +OOB_POWER_STATUS = "power-status" +OOB_HEALTH = "health" + +OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE, + OOB_POWER_STATUS, OOB_HEALTH]) + # Instance Parameters Profile PP_DEFAULT = "default"