On Fri, Jul 26, 2013 at 8:52 PM, Michele Tartara <[email protected]> wrote: > On Fri, Jul 26, 2013 at 12:54 PM, Weiwei Jia <[email protected]> wrote: >> >> Add RPC calls to mount Gluster storage dir. >> >> Signed-off-by: Weiwei Jia <[email protected]> >> --- >> lib/backend.py | 34 ++++++++++++++++++++++++++++++++++ >> lib/rpc_defs.py | 5 +++++ >> lib/server/noded.py | 12 ++++++++++++ >> 3 files changed, 51 insertions(+) >> >> diff --git a/lib/backend.py b/lib/backend.py >> index 7063aa5..c37c102 100644 >> --- a/lib/backend.py >> +++ b/lib/backend.py >> @@ -3230,6 +3230,40 @@ 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: string >> + @param gluster_hostname: hostname of gluster server >> + @type gluster_volname: string >> + @param gluster_volname: volume name of gluster server >> + @type gluster_storage_dir: string >> + @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) >> + >> + result = utils.RunCmd(["mount", "-t", "glusterfs", >> + "%s:/%s" % (gluster_hostname, gluster_volname), >> + gluster_storage_dir]) >> + >> + if result.failed: >> + raise errors.OpPrereqError("Could not mount glusterfs, error %s" % >> + result.output, ECODE_INVAL) >> + else: >> + _Fail("Gluster storage dir %s does not exist", gluster_storage_dir) >> + >> + >> 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 >> > > This seems to be ok. > No LGTM just because it is actually pointless on its own, so it will make > sense after looking at the interaction with the other patches that have to > follow. >
Okay, I would send the patch set with this patch. -- Thanks Weiwei Jia (Harry Wei)
