On 13:02 Thu 24 Jun , Iustin Pop wrote: > On Wed, Jun 23, 2010 at 04:47:37PM +0300, [email protected] wrote: > > From: Apollon Oikonomopoulos <[email protected]> > > > > Add bdev_list RPC call to return all block devices under > > constants.BLOCKDEV_DIR > > and their sizes on multiple nodes. By default constants.BLOCKDEV_DIR is set > > to > > '/dev/disk', where persistent symlinks for block devices are expected to > > exist. > > Can you add (in the commit message) the rationale of why we need to > add this/how it will be used? > > I wonder if enumerating all disks might not be slow (e.g., on a single > disk, you might have 5 partitions, and thus already for a single disk > you have to make 6 blockdev calls). In which case, designing the call to > take an optional list of devices to query (if empty, enumerate all) > might be a good idea. > This is currently only used during disk adoption for DT_BLOCK. In this case, yes, it would make sense to get a list of block devices whose existence we need to verify.
> > Signed-off-by: Apollon Oikonomopoulos <[email protected]> > > --- > > daemons/ganeti-noded | 8 ++++++++ > > lib/backend.py | 26 ++++++++++++++++++++++++++ > > lib/constants.py | 1 + > > lib/rpc.py | 9 +++++++++ > > 4 files changed, 44 insertions(+), 0 deletions(-) > > > > diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded > > index 281b061..03539d4 100755 > > --- a/daemons/ganeti-noded > > +++ b/daemons/ganeti-noded > > @@ -409,6 +409,14 @@ class NodeHttpServer(http.server.HttpServer): > > export = params[0] > > return backend.RemoveExport(export) > > > > + # block device --------------------- > > + @staticmethod > > + def perspective_bdev_list(params): > > + """Query the list of block devices > > + > > + """ > > + return backend.GetBlockdevList() > > + > > # volume -------------------------- > > > > @staticmethod > > diff --git a/lib/backend.py b/lib/backend.py > > index 0a0d4cc..cc6542d 100644 > > --- a/lib/backend.py > > +++ b/lib/backend.py > > @@ -602,6 +602,32 @@ def VerifyNode(what, cluster_name): > > return result > > > > > > +def GetBlockdevList(): > > + """Compute the list of block devices and their size > > + > > + @rtype: dict > > + @return: > > + dictionary of all block devices under /dev/disk (key). The value is > > their > > + size in MiB. > > + > > + {'/dev/disk/by-uuid/123456-12321231-312312-312': 124} > > + > > + """ > > + blockdevs = {} > > + for root, dirs, files in os.walk(constants.BLOCKDEV_DIR): > > + for dev in files: > > + devpath = os.path.join(root,dev) > > + if stat.S_ISBLK(os.stat(devpath)[stat.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 > > + continue > > + > > + size = int(result.stdout) / (1024 * 1024) > > + blockdevs[devpath] = size > > + return blockdevs > > + > > + > > def GetVolumeList(vg_name): > > """Compute list of logical volumes and their size. > > > > diff --git a/lib/constants.py b/lib/constants.py > > index fec10e7..9311dcb 100644 > > --- a/lib/constants.py > > +++ b/lib/constants.py > > @@ -101,6 +101,7 @@ CRYPTO_KEYS_DIR = RUN_GANETI_DIR + "/crypto" > > CRYPTO_KEYS_DIR_MODE = SECURE_DIR_MODE > > IMPORT_EXPORT_DIR = RUN_GANETI_DIR + "/import-export" > > IMPORT_EXPORT_DIR_MODE = 0755 > > +BLOCKDEV_DIR = "/dev/disk" > > # keep RUN_GANETI_DIR first here, to make sure all get created when the > > node > > # daemon is started (this takes care of RUN_DIR being tmpfs) > > SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ] > > diff --git a/lib/rpc.py b/lib/rpc.py > > index c4a36c9..7b26c47 100644 > > --- a/lib/rpc.py > > +++ b/lib/rpc.py > > @@ -488,6 +488,15 @@ class RpcRunner(object): > > # > > > > @_RpcTimeout(_TMO_URGENT) > > + def call_bdev_list(self, node_list): > > + """Gets the list of block devices present on a node > > + > > + This is a multi-node call. > > + > > + """ > > + return self._MultiNodeCall(node_list, "bdev_list", []) > > I think this is not a _TMO_URGENT class… How often do will we run this > call? No, it's probably not. Currently it only gets called at instance creation and I'm not sure if it is of use anywhere else. Apollon
