summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2013-04-29 15:55:58 -0500
committerGeorge Kraft <george.kraft@calxeda.com>2013-04-29 15:55:58 -0500
commit8bff1c00e80d85b55efdbd905300f84610dfb75e (patch)
tree82adff0a0f96f42cfa346588409c35fec6d8ad03
parentc0fecd201d237acbb5a4da5124f6e48cce6d6159 (diff)
downloadcxmanage-8bff1c00e80d85b55efdbd905300f84610dfb75e.tar.gz
Node/Fabric: Add a "wait" flag to the mc_reset command
When set to True, the command will block until the node has actually finished resetting.
-rw-r--r--cxmanage_api/fabric.py7
-rw-r--r--cxmanage_api/node.py29
2 files changed, 33 insertions, 3 deletions
diff --git a/cxmanage_api/fabric.py b/cxmanage_api/fabric.py
index bea06fa..992dc21 100644
--- a/cxmanage_api/fabric.py
+++ b/cxmanage_api/fabric.py
@@ -254,17 +254,20 @@ class Fabric(object):
"""
self._run_command(async, "set_power_policy", state)
- def mc_reset(self, async=False):
+ def mc_reset(self, wait=False, async=False):
"""Resets the management controller on all nodes.
>>> fabric.mc_reset()
+ :param wait: Wait for the nodes to come back up.
+ :type wait: boolean
+
:param async: Flag that determines if the command result (dictionary)
is returned or a Command object (can get status, etc.).
:type async: boolean
"""
- self._run_command(async, "mc_reset")
+ self._run_command(async, "mc_reset", wait)
def get_sensors(self, search="", async=False):
"""Gets sensors from all nodes.
diff --git a/cxmanage_api/node.py b/cxmanage_api/node.py
index 9198cbc..c31322d 100644
--- a/cxmanage_api/node.py
+++ b/cxmanage_api/node.py
@@ -283,11 +283,14 @@ class Node(object):
except IpmiError as e:
raise IpmiError(self._parse_ipmierror(e))
- def mc_reset(self):
+ def mc_reset(self, wait=False):
"""Sends a Master Control reset command to the node.
>>> node.mc_reset()
+ :param wait: Wait for the node to come back up.
+ :type wait: boolean
+
:raises Exception: If the BMC command contains errors.
:raises IPMIError: If there is an IPMI error communicating with the BMC.
@@ -299,6 +302,30 @@ class Node(object):
except IpmiError as e:
raise IpmiError(self._parse_ipmierror(e))
+ if wait:
+ deadline = time.time() + 300.0
+
+ # Wait for it to go down...
+ while time.time() < deadline:
+ time.sleep(1)
+ try:
+ self.bmc.get_info_basic()
+ except IpmiError:
+ break
+ else:
+ raise Exception("Reset timed out")
+
+ # Now wait to come back up!
+ while time.time() < deadline:
+ time.sleep(1)
+ try:
+ self.bmc.get_info_basic()
+ break
+ except IpmiError:
+ pass
+ else:
+ raise Exception("Reset timed out")
+
def get_sensors(self, search=""):
"""Get a list of sensor objects that match search criteria.