On Fri, Jul 26, 2013 at 4:15 PM, Michele Tartara <[email protected]> wrote: > 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. >
Yeah, I have noticed here. I would send a new patch set that after tested. Thanks very much. -- Thanks Weiwei Jia (Harry Wei)
