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)
评论列表
文章目录