def guestmount(self, mountpoint, disk_or_domain=None): """ Mount filesystems in a disk or domain to host mountpoint. @param disk_or_domain: if it is None, use default vm in params """ logging.info("Mounting filesystems...") if disk_or_domain is None: disk_or_domain = self.oldvm.name if not os.path.isdir(mountpoint): os.mkdir(mountpoint) if os.path.ismount(mountpoint): utils.run("umount -l %s" % mountpoint, ignore_status=True) inspector = "yes" == self.params.get("gm_inspector", "yes") readonly = "yes" == self.params.get("gm_readonly", "no") special_mountpoints = self.params.get("special_mountpoints", []) is_disk = "yes" == self.params.get("gm_is_disk", "no") options = {} options['ignore_status'] = True options['debug'] = True options['timeout'] = int(self.params.get("timeout", 240)) options['special_mountpoints'] = special_mountpoints options['is_disk'] = is_disk result = lgf.guestmount(disk_or_domain, mountpoint, inspector, readonly, **options) if result.exit_status: error_info = "Mount %s to %s failed." % (disk_or_domain, mountpoint) logging.error(result) return (False, error_info) return (True, mountpoint)
def guestmount(self, mountpoint, disk_or_domain=None): """ Mount filesystems in a disk or domain to host mountpoint. @param disk_or_domain: if it is None, use default vm in params """ logging.info("Mounting filesystems...") if disk_or_domain is None: disk_or_domain = self.oldvm.name if not os.path.isdir(mountpoint): os.mkdir(mountpoint) if os.path.ismount(mountpoint): utils.run("umount -l %s" % mountpoint, ignore_status=True) inspector = "yes" == self.params.get("gm_inspector", "yes") readonly = "yes" == self.params.get("gm_readonly", "no") special_mountpoints = self.params.get("special_mountpoints", []) is_disk = "yes" == self.params.get("gm_is_disk", "no") options = {} options['ignore_status'] = True options['debug'] = True options['timeout'] = int(self.params.get("timeout", 240)) options['special_mountpoints'] = special_mountpoints options['is_disk'] = is_disk result = lgf.guestmount(disk_or_domain, mountpoint, inspector, readonly, **options) if result.exit_status: error_info = "Mount %s to %s failed." % (disk_or_domain, mountpoint) logging.error(result) return (False, error_info) return (True, mountpoint)
def check_images_coredump(image, mntpnt, check_files, debugdir): """ Mount the images and check the coredump files :return: Format as Bool, List If the checked file exists return True, ["checked file name"] If not, return False [] """ found_coredump = False msgs_return = [] try: error.context("Mount the guest image %s to host mount point" % image, logging.info) status = lgf.guestmount(image, mntpnt, True, True, debug=True, is_disk=True) if status.exit_status: msgs_return.append("Could not mount guest image %s." % image) error.context(msgs_return[0], logging.error) else: found_coredump, msgs_return = coredump_exists(mntpnt, check_files, debugdir) finally: if os.path.ismount(mntpnt): error.context("guestunmount host mount point") lgf.lgf_command("guestunmount %s" % mntpnt) return found_coredump, msgs_return
def check_images_coredump(image, mntpnt, check_files, debugdir): """ Mount the images and check the coredump files :return: Format as Bool, List If the checked file exists return True, ["checked file name"] If not, return False [] """ found_coredump = False msgs_return = [] try: error.context("Mount the guest image %s to host mount point" % image, logging.info) status = lgf.guestmount(image, mntpnt, True, True, debug=True, is_disk=True) if status.exit_status: msgs_return.append("Could not mount guest image %s." % image) error.context(msgs_return[0], logging.error) else: found_coredump, msgs_return = coredump_exists( mntpnt, check_files, debugdir) finally: if os.path.ismount(mntpnt): error.context("guestunmount host mount point") lgf.lgf_command("guestunmount %s" % mntpnt) return found_coredump, msgs_return