This RPC replaces the existing one that only returned disk size.
Signed-off-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
return rbd.GetSyncStatus()
-def BlockdevGetsize(disks):
+def BlockdevGetdimensions(disks):
"""Computes the size of the given disks.
If a disk is not found, returns None instead.
@param disks: the list of disk to compute the size for
@rtype: list
@return: list with elements None if the disk cannot be found,
- otherwise the size
+ otherwise the pair (size, spindles), where spindles is None if the
+ device doesn't support that
"""
result = []
if rbd is None:
result.append(None)
else:
- result.append(rbd.GetActualSize())
+ result.append(rbd.GetActualDimensions())
return result
newl = [v[2].Copy() for v in dskl]
for dsk in newl:
self.cfg.SetDiskID(dsk, node)
- result = self.rpc.call_blockdev_getsize(node, newl)
+ result = self.rpc.call_blockdev_getdimensions(node, newl)
if result.fail_msg:
- self.LogWarning("Failure in blockdev_getsize call to node"
+ self.LogWarning("Failure in blockdev_getdimensions call to node"
" %s, ignoring", node)
continue
if len(result.payload) != len(dskl):
self.LogWarning("Invalid result from node %s, ignoring node results",
node)
continue
- for ((instance, idx, disk), size) in zip(dskl, result.payload):
- if size is None:
+ for ((instance, idx, disk), dimensions) in zip(dskl, result.payload):
+ if dimensions is None:
self.LogWarning("Disk %d of instance %s did not return size"
" information, ignoring", idx, instance.name)
continue
+ if not isinstance(dimensions, (tuple, list)):
+ self.LogWarning("Disk %d of instance %s did not return valid"
+ " dimension information, ignoring", idx,
+ instance.name)
+ continue
+ (size, _) = dimensions
if not isinstance(size, (int, long)):
self.LogWarning("Disk %d of instance %s did not return valid"
" size information, ignoring", idx, instance.name)
if wipe_disks:
# Get disk size from primary node for wiping
- result = self.rpc.call_blockdev_getsize(instance.primary_node, [disk])
+ result = self.rpc.call_blockdev_getdimensions(instance.primary_node,
+ [disk])
result.Raise("Failed to retrieve disk size from node '%s'" %
instance.primary_node)
- (disk_size_in_bytes, ) = result.payload
+ (disk_dimensions, ) = result.payload
- if disk_size_in_bytes is None:
+ if disk_dimensions is None:
raise errors.OpExecError("Failed to retrieve disk size from primary"
" node '%s'" % instance.primary_node)
+ (disk_size_in_bytes, _) = disk_dimensions
old_disk_size = _DiskSizeInBytesToMebibytes(self, disk_size_in_bytes)
("instance_name", None, None),
("disks", ED_OBJECT_DICT_LIST, None),
], None, None, "Closes the given block devices"),
- ("blockdev_getsize", SINGLE, None, constants.RPC_TMO_NORMAL, [
+ ("blockdev_getdimensions", SINGLE, None, constants.RPC_TMO_NORMAL, [
("disks", ED_OBJECT_DICT_LIST, None),
- ], None, None, "Returns the size of the given disks"),
+ ], None, None, "Returns size and spindles of the given disks"),
("drbd_disconnect_net", MULTI, None, constants.RPC_TMO_NORMAL, [
("nodes_ip", None, None),
("disks", ED_OBJECT_DICT_LIST, None),
return backend.BlockdevClose(params[0], disks)
@staticmethod
- def perspective_blockdev_getsize(params):
+ def perspective_blockdev_getdimensions(params):
"""Compute the sizes of the given block devices.
"""
disks = [objects.Disk.FromDict(cf) for cf in params[0]]
- return backend.BlockdevGetsize(disks)
+ return backend.BlockdevGetdimensions(disks)
@staticmethod
def perspective_blockdev_export(params):