pinfo("Undefine \"%s\" on %s" % (todelete, h)) dom.undefine() conn.close() if conf.do_lvm: for disk in disk_todelete: lvremove_cmd = ["lvremove", disk] if conf.do_cluster: lv_deactivate(disk, conf.cluster_nodes) pinfo("Remove disk : " + disk) if locking_type() == 4: vmc_lock(conf.lockfile, "vmc-delete") unlock() if input("Please confirm %s removal by typing \"Yes\": " % disk) == 'Yes': subprocess.call(lvremove_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) lock(4) vmc_unlock(conf.lockfile) else: if input("Please confirm %s removal by typing \"Yes\": " % disk) == 'Yes': subprocess.call(lvremove_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) else: for disk in disk_todelete: pinfo("Remove disk : " + disk) if input("Please confirm %s removal by typing \"Yes\": " % disk) == 'Yes': os.unlink(disk) os.remove(xml_file_path)
import libvirt from vmc.common import pinfo, perror, die from vmc.utils.openwide import vmc_unlock, vmc_lock import vmc.utils.lvm def usage(): print ("""Usage : %s Unlock LVM metadata -h, --help Display help information """ % os.path.basename(sys.argv[0])) try: dest = sys.argv[1] if dest == "--help" or dest == "-h": usage() except: pass conf = vmcConfig() if vmc.utils.lvm.locking_type() == 0: die("LVM metadata are already unlocked") vmc_lock(conf.lockfile, os.path.basename(sys.argv[0])) vmc.utils.lvm.unlock() pinfo("Don't forget to re-lock LVM metadata after operation") sys.exit(0)