cli.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:gluster-georep-tools 作者: aravindavk 项目源码 文件源码
def glustermount(hostname, volname):
    """
    Context manager for Mounting Gluster Volume
    Use as
        with glustermount(HOSTNAME, VOLNAME) as MNT:
            # Do your stuff
    Automatically unmounts it in case of Exceptions/out of context
    """
    mnt = tempfile.mkdtemp(prefix="georepsetup_")
    execute(["glusterfs",
             "--xlator-option=\"*dht.lookup-unhashed=off\"",
             "--volfile-server", hostname,
             "--volfile-id", volname,
             "-l", SESSION_MOUNT_LOG_FILE,
             "--client-pid=-1",
             mnt],
            failure_msg="Unable to Mount Gluster Volume "
            "{0}:{1}".format(hostname, volname))
    if os.path.ismount(mnt):
        yield mnt
    else:
        output_notok("Unable to Mount Gluster Volume "
                     "{0}:{1}".format(hostname, volname))
    cleanup(hostname, volname, mnt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号