Commit cacfd1fd authored by Iustin Pop's avatar Iustin Pop
Browse files

Switch the blockdev_shutdown rpc to (status, data)

This converts the backend and cmdlib modules to a (status, data)
implementation of the blockdev_shutdown rpc call. bdev.py is not yet
converted, so we don't actually have error information.

We also fix a bug in _ShutdownInstanceDisks by not reusing a variable.

Reviewed-by: ultrotter
parent 53c14ef1
......@@ -1248,18 +1248,26 @@ def BlockdevShutdown(disk):
@return: the success of the operation
"""
msgs = []
r_dev = _RecursiveFindBD(disk)
if r_dev is not None:
r_path = r_dev.dev_path
result = r_dev.Shutdown()
try:
result = r_dev.Shutdown()
except errors.BlockDeviceError, err:
msgs.append(str(err))
result = False
if result:
DevCacheManager.RemoveCache(r_path)
else:
result = True
if disk.children:
for child in disk.children:
result = result and BlockdevShutdown(child)
return result
c_status, c_msg = BlockdevShutdown(child)
result = result and c_status
if c_msg: # not an empty message
msgs.append(c_msg)
return (result, "; ".join(msgs))
def BlockdevAddchildren(parent_cdev, new_cdevs):
......
......@@ -2572,17 +2572,18 @@ def _ShutdownInstanceDisks(lu, instance, ignore_primary=False):
ignored.
"""
result = True
all_result = True
for disk in instance.disks:
for node, top_disk in disk.ComputeNodeTree(instance.primary_node):
lu.cfg.SetDiskID(top_disk, node)
result = lu.rpc.call_blockdev_shutdown(node, top_disk)
if result.failed or not result.data:
logging.error("Could not shutdown block device %s on node %s",
disk.iv_name, node)
msg = result.RemoteFailMsg()
if msg:
lu.LogWarning("Could not shutdown block device %s on node %s: %s",
disk.iv_name, node, msg)
if not ignore_primary or node != instance.primary_node:
result = False
return result
all_result = False
return all_result
def _CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name):
......@@ -5197,9 +5198,10 @@ class LUReplaceDisks(LogicalUnit):
# we have new devices, shutdown the drbd on the old secondary
info("shutting down drbd for disk/%d on old node" % idx)
cfg.SetDiskID(dev, old_node)
result = self.rpc.call_blockdev_shutdown(old_node, dev)
if result.failed or not result.data:
warning("Failed to shutdown drbd for disk/%d on old node" % idx,
msg = self.rpc.call_blockdev_shutdown(old_node, dev).RemoteFailMsg()
if msg:
warning("Failed to shutdown drbd for disk/%d on old node: %s" %
(idx, msg),
hint="Please cleanup this device manually as soon as possible")
info("detaching primary drbds from the network (=> standalone)")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment