---
 lib/cmdlib.py    |   16 ++++++++++++++++
 lib/constants.py |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 2dda843..770f205 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3265,6 +3265,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)
@@ -3284,6 +3285,21 @@ 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
+
+    if self.op.command == constants.OOB_POWER_OFF:
+      node.powered = False
+
+    if 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 eae9ce6..108042d 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"
-- 
1.7.3.1

Reply via email to