def enable_volume_quota():
"""
Enable quotas on the volume
"""
# Gather our action parameters
vol = action_get("volume")
usage_limit = action_get("usage-limit")
parsed_usage_limit = int(usage_limit)
path = action_get("path")
# Turn quotas on if not already enabled
quotas_enabled = volume.volume_quotas_enabled(vol)
if quotas_enabled.is_err():
action_fail("Enable quota failed: {}".format(quotas_enabled.value))
if not quotas_enabled.value:
try:
volume.volume_enable_quotas(vol)
except GlusterCmdException as e:
action_fail("Enable quotas failed: {}".format(e))
try:
volume.volume_add_quota(vol, path, parsed_usage_limit)
except GlusterCmdException as e:
action_fail("Add quota failed: {}".format(e))
评论列表
文章目录