diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 1f2862f16adb0739bb6df81497097dba44d80b59..36e8e7053fcbb24ccac5f301defd0fef90771e46 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -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) + @staticmethod + 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 ---------- @staticmethod diff --git a/lib/backend.py b/lib/backend.py index afb39213acf56ca5d75cc0e0d06e6bf1cbb2a38c..c865b0fc1317654bafb0791ae1ccf21aa6823b9d 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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: + try: + rbd = _RecursiveFindBD(cf) + except errors.BlockDeviceError, err: + result.append(None) + continue + if rbd is None: + result.append(None) + else: + result.append(rbd.GetActualSize()) + return result + + def UploadFile(file_name, data, mode, uid, gid, atime, mtime): """Write a file to the filesystem. diff --git a/lib/rpc.py b/lib/rpc.py index 1ce44acbb8f42aabf3926e0029ad2650ac0dc54c..6392f50cb072f200eb32daafca8d807576b7c8be 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -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.