Commit 968a7623 authored by Iustin Pop's avatar Iustin Pop
Browse files

rpc: add rpc call for getting disk size

Note that this exports the disk size as bdev returns it, in bytes. The
value will be converted to MiB in cmdlib.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarGuido Trotter <>
parent fcff3897
......@@ -232,6 +232,14 @@ class NodeHttpServer(http.server.HttpServer):
disks = [objects.Disk.FromDict(cf) for cf in params[1]]
return backend.BlockdevClose(params[0], disks)
def perspective_blockdev_getsize(params):
"""Compute the sizes of the given block devices.
disks = [objects.Disk.FromDict(cf) for cf in params[0]]
return backend.BlockdevGetsize(disks)
# blockdev/drbd specific methods ----------
......@@ -1442,6 +1442,32 @@ def BlockdevFind(disk):
return (True, (rbd.dev_path, rbd.major, rbd.minor) + rbd.GetSyncStatus())
def BlockdevGetsize(disks):
"""Computes the size of the given disks.
If a disk is not found, returns None instead.
@type disks: list of L{objects.Disk}
@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
result = []
for cf in disks:
rbd = _RecursiveFindBD(cf)
except errors.BlockDeviceError, err:
if rbd is None:
return result
def UploadFile(file_name, data, mode, uid, gid, atime, mtime):
"""Write a file to the filesystem.
......@@ -807,6 +807,15 @@ class RpcRunner(object):
params = [instance_name, [cf.ToDict() for cf in disks]]
return self._SingleNodeCall(node, "blockdev_close", params)
def call_blockdev_getsizes(self, node, disks):
"""Returns the size of the given disks.
This is a single-node call.
params = [[cf.ToDict() for cf in disks]]
return self._SingleNodeCall(node, "blockdev_getsize", params)
def call_drbd_disconnect_net(self, node_list, nodes_ip, disks):
"""Disconnects the network of the given drbd devices.
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