On Fri, Jul 26, 2013 at 5:59 AM, Weiwei Jia <[email protected]> wrote:
> Add RPC calls to mount Gluster storage directory. > > Signed-off-by: Weiwei Jia <[email protected]> > --- > lib/backend.py | 31 +++++++++++++++++++++++++++++++ > lib/rpc_defs.py | 5 +++++ > lib/server/noded.py | 12 ++++++++++++ > 3 files changed, 48 insertions(+) > > diff --git a/lib/backend.py b/lib/backend.py > index 7063aa5..c61a1e8 100644 > --- a/lib/backend.py > +++ b/lib/backend.py > @@ -3230,6 +3230,37 @@ def CreateFileStorageDir(file_storage_dir): > file_storage_dir, err, exc=True) > > > +def MountGlusterStorageDir(gluster_hostname, > + gluster_volname, > + gluster_storage_dir): > + """Mount gluster storage directory. > + > + @type gluster_hostname: str > Write this as "string", instead of "str". The same holds for the following ones. + @param gluster_hostname: hostname of gluster server > + @type gluster_volname: str > + @param gluster_volname: volume name of gluster server > + @type gluster_storage_dir: str > + @param gluster_storage_dir: directory to mount > + > + @rtype: tuple > + @return: tuple with first element a boolean indicating whether dir > + mount was successful or not + > + """ > + gluster_storage_dir = _TransformFileStorageDir(gluster_storage_dir) > + if os.path.exists(gluster_storage_dir): > + if not os.path.isdir(gluster_storage_dir): > + _Fail("Specified gluster storage dir '%s' is not a directory", > + gluster_storage_dir) > + else: + result = utils.RunCmd(["mount", "-t", "glusterfs", > + "%s:/%s" % (gluster_hostname, gluster_volname), > + gluster_storage_dir]) > Look at the the logic of your code: if path exists: do other checks else: mount the volume in that NON EXISTING path (???) This isn't going to work. The directory should exist before you can mount something into it. > + if result.failed: > + raise errors.OpPrereqError("Could not mount glusterfs, error %s" % > + result.output) > + > + def RemoveFileStorageDir(file_storage_dir): > """Remove file storage directory. > > diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py > index ffb5ceb..83416c9 100644 > --- a/lib/rpc_defs.py > +++ b/lib/rpc_defs.py > @@ -190,6 +190,11 @@ _FILE_STORAGE_CALLS = [ > ("file_storage_dir_create", SINGLE, None, constants.RPC_TMO_FAST, [ > ("file_storage_dir", None, "File storage directory"), > ], None, None, "Create the given file storage directory"), > + ("mount_gluster_storage_dir", SINGLE, None, constants.RPC_TMO_FAST, [ > + ("gluster_hostname", None, "gluster host name"), > + ("gluster_volname", None, "gluster volume name"), > + ("gluster_storage_dir", None, "gluster storage directory"), > + ], None, None, "Mount the given gluster storage directory"), > ("file_storage_dir_remove", SINGLE, None, constants.RPC_TMO_FAST, [ > ("file_storage_dir", None, "File storage directory"), > ], None, None, "Remove the given file storage directory"), > diff --git a/lib/server/noded.py b/lib/server/noded.py > index ecc7c95..75229d7 100644 > --- a/lib/server/noded.py > +++ b/lib/server/noded.py > @@ -982,6 +982,18 @@ class > NodeRequestHandler(http.server.HttpServerHandler): > return backend.CreateFileStorageDir(file_storage_dir) > > @staticmethod > + def perspective_mount_gluster_storage_dir(params): > + """Mount the gluster storage directory. > + > + """ > + gluster_hostname = params[0] > + gluster_volname = params[1] > + gluster_storage_dir = params[2] > + return backend.MountGlusterStorageDir(gluster_hostname, > + gluster_volname, > + gluster_storage_dir) > + > + @staticmethod > def perspective_file_storage_dir_remove(params): > """Remove the file storage directory. > > -- > 1.7.10.4 > > Thanks, Michele -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
