Commit 2be7273c authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos Committed by Iustin Pop
Browse files

Add bdev_sizes RPC call

The bdev_sizes multi-node RPC call returns the sizes of the requested
block devices on the desired nodes. Its intended use is to verify the
existence of a block device on a given node for shared block storage

Block device paths are expected to lie under constants.BLOCKDEV_DIR
("/dev/disk" by default), where persistent symlinks for block devices
are assumed to exist.
Signed-off-by: default avatarApollon Oikonomopoulos <>
[ small changes in]
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarIustin Pop <>
parent 2932dc44
......@@ -647,6 +647,44 @@ def VerifyNode(what, cluster_name):
return result
def GetBlockDevSizes(devices):
"""Return the size of the given block devices
@type devices: list
@param devices: list of block device nodes to query
@rtype: dict
dictionary of all block devices under /dev (key). The value is their
size in MiB.
{'/dev/disk/by-uuid/123456-12321231-312312-312': 124}
DEV_PREFIX = "/dev/"
blockdevs = {}
for devpath in devices:
if os.path.commonprefix([DEV_PREFIX, devpath]) != DEV_PREFIX:
st = os.stat(devpath)
except EnvironmentError, err:
logging.warning("Error stat()'ing device %s: %s", devpath, str(err))
if stat.S_ISBLK(st.st_mode):
result = utils.RunCmd(["blockdev", "--getsize64", devpath])
if result.failed:
# We don't want to fail, just do not list this device as available
logging.warning("Cannot get size for block device %s", devpath)
size = int(result.stdout) / (1024 * 1024)
blockdevs[devpath] = size
return blockdevs
def GetVolumeList(vg_names):
"""Compute list of logical volumes and their size.
......@@ -589,6 +589,15 @@ class RpcRunner(object):
# Begin RPC calls
def call_bdev_sizes(self, node_list, devices):
"""Gets the sizes of requested block devices present on a node
This is a multi-node call.
return self._MultiNodeCall(node_list, "bdev_sizes", [devices])
def call_lv_list(self, node_list, vg_name):
"""Gets the logical volumes present in a given volume group.
......@@ -457,6 +457,15 @@ class NodeHttpServer(http.server.HttpServer):
export = params[0]
return backend.RemoveExport(export)
# block device ---------------------
def perspective_bdev_sizes(params):
"""Query the list of block devices
devices = params[0]
return backend.GetBlockDevSizes(devices)
# volume --------------------------
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