提交 1352b713 编写于 作者: N Narasimhan V

Adding a method to reactivate vg in lv_utils

lv_utils: adding a method to reactivate vg. It also has the option
to specify whether to export and import vg before activating or not.
Signed-off-by: NNarasimhan V <sim@linux.vnet.ibm.com>
上级 4a488ffd
......@@ -618,6 +618,34 @@ def lv_mount(vg_name, lv_name, mount_loc, create_filesystem=""):
raise LVException("Fail to mount logical volume: %s" % ex)
def vg_reactivate(vg_name, timeout=10, export=False):
"""
In case of unclean shutdowns some of the vgs is still active and merging
is postponed. Use this function to attempt to deactivate and reactivate
all of them to cause the merge to happen.
:param str vg_name: name of the volume group
:param int timeout: timeout between operations
:raises: :py:class:`LVException` if the logical volume is still active
"""
try:
process.run("vgchange -an %s" % vg_name, sudo=True)
time.sleep(timeout)
if export:
process.run("vgexport %s" % vg_name, sudo=True)
time.sleep(timeout)
process.run("vgimport %s" % vg_name, sudo=True)
time.sleep(timeout)
process.run("vgchange -ay %s" % vg_name, sudo=True)
time.sleep(timeout)
except process.CmdError:
log_msg = "Failed to reactivate %s - please, nuke the process that uses it first."
LOGGER.error(log_msg, vg_name)
raise LVException("The Volume group %s is still active" % vg_name)
def lv_umount(vg_name, lv_name):
"""
Unmount a Logical volume from a mount location.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册