diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index d5d09f35d9f6c98b4584ce2012248f28986af39d..2dc1900c0a80b39fa43eb21e9efcbcea2e56f742 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3283,6 +3283,7 @@ class LUOutOfBand(NoHooksLU):
"""
master_node = self.cfg.GetMasterNode()
+ node = self.node
logging.info("Executing out-of-band command '%s' using '%s' on %s",
self.op.command, self.oob_program, self.op.node_name)
@@ -3302,6 +3303,19 @@ class LUOutOfBand(NoHooksLU):
logging.warning("On node '%s' item '%s' has status '%s'",
self.op.node_name, item, status)
+ if self.op.command == constants.OOB_POWER_ON:
+ node.powered = True
+ elif self.op.command == constants.OOB_POWER_OFF:
+ node.powered = False
+ elif self.op.command == constants.OOB_POWER_STATUS:
+ powered = result.payload[constants.OOB_POWER_STATUS_POWERED]
+ if powered != self.node.powered:
+ logging.warning(("Recorded power state (%s) of node '%s' does not match"
+ " actual power state (%s)"), node.powered,
+ self.op.node_name, powered)
+
+ self.cfg.Update(node, feedback_fn)
+
return result.payload
def _CheckPayload(self, result):
diff --git a/lib/constants.py b/lib/constants.py
index 5dd9838a1474837d7b781f0995398632e2a738db..a402427f998f431d308c2b10fdb9a5ba5b25ca94 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -656,6 +656,8 @@ OOB_HEALTH = "health"
OOB_COMMANDS = frozenset([OOB_POWER_ON, OOB_POWER_OFF, OOB_POWER_CYCLE,
OOB_POWER_STATUS, OOB_HEALTH])
+OOB_POWER_STATUS_POWERED = "powered"
+
OOB_TIMEOUT = 60 # 60 seconds
OOB_STATUS_OK = "OK"