On Fri, Jul 26, 2013 at 10:51 AM, Weiwei Jia <[email protected]> wrote:

> Add RPC calls to mount Gluster storage dir.
>
> Signed-off-by: Weiwei Jia <[email protected]>
> ---
>  lib/backend.py      |   32 ++++++++++++++++++++++++++++++++
>  lib/rpc_defs.py     |    5 +++++
>  lib/server/noded.py |   12 ++++++++++++
>  3 files changed, 49 insertions(+)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index 7063aa5..1985478 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -3230,6 +3230,38 @@ 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
> +  @param gluster_hostname: hostname of gluster server
> +  @type gluster_volname: str
> +  @param gluster_volname: volume name of gluster server
> +  @type gluster_storage_dir: str
>

These still have to be changed from "str" to "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)
>

And this is still wrong: if the path does not exists, it is just going to
fail silently, instead of providing any meaningful message or creating the
missing directory.


> +
> +
>
  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
>
>
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

Reply via email to