def check(self):
        super(zstack_kvm_image_file_checker, self).check()
        image = self.test_obj.image
        backupStorages = image.backupStorageRefs
        bs_one = backupStorages[0]
        bs = test_lib.lib_get_backup_storage_by_uuid(bs_one.backupStorageUuid)
        if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE:
            host = test_lib.lib_get_backup_storage_host(bs_one.backupStorageUuid)
            image_url = backupStorages[0].installPath
            self.judge(test_lib.lib_check_file_exist(host, image_url))
        elif bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE:
            if self.test_obj.state == image_header.DELETED:
                #https://github.com/zstackorg/zstack/issues/93#issuecomment-130935998
                test_util.test_logger("skip ceph image delete check, since the image won't be deleted until no vms refer to it.")
                return self.judge(self.exp_result)

            ceph_host, username, password = test_lib.lib_get_ceph_info(os.environ.get('cephBackupStorageMonUrls'))
            image_installPath = bs_one.installPath.split('ceph://')[1]

            command = 'rbd info %s' % image_installPath
            if test_lib.lib_execute_ssh_cmd(ceph_host, username, password, command, 10):
                test_util.test_logger('Check result: [image:] %s [file:] %s exist on ceph [host name:] %s .' % (image.uuid, image_installPath, ceph_host))
                return self.judge(True)
            else:
                test_util.test_logger('Check result: [image:] %s [file:] %s does not exist on ceph [host name:] %s .' % (image.uuid, image_installPath, ceph_host))
                return self.judge(False)
    def check(self):
        super(zstack_kvm_image_file_checker, self).check()
        image = self.test_obj.image
        backupStorages = image.backupStorageRefs
        bs_one = backupStorages[0]
        bs = test_lib.lib_get_backup_storage_by_uuid(bs_one.backupStorageUuid)
        if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE:
            self.judge(test_lib.lib_check_backup_storage_image_file(image))

        elif hasattr(inventory, 'IMAGE_STORE_BACKUP_STORAGE_TYPE') and bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
            if self.test_obj.state == image_header.DELETED:
                test_util.test_logger("skip image store image delete check, since the image won't be deleted until no vms refer to it.")
                return self.judge(self.exp_result)
            self.judge(test_lib.lib_check_backup_storage_image_file(image))

        elif bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE:
            if self.test_obj.state == image_header.DELETED:
                #https://github.com/zstackorg/zstack/issues/93#issuecomment-130935998
                test_util.test_logger("skip ceph image delete check, since the image won't be deleted until no vms refer to it.")
                return self.judge(self.exp_result)

            if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(test_lib.scenario_file):
                import zstackwoodpecker.operations.scenario_operations as sce_ops
                sce_ops.replace_env_params_if_scenario()

            ceph_host, username, password = test_lib.lib_get_ceph_info(os.environ.get('cephBackupStorageMonUrls'))
            image_installPath = bs_one.installPath.split('ceph://')[1]

            command = 'rbd info %s' % image_installPath
            if test_lib.lib_execute_ssh_cmd(ceph_host, username, password, command, 10):
                test_util.test_logger('Check result: [image:] %s [file:] %s exist on ceph [host name:] %s .' % (image.uuid, image_installPath, ceph_host))
                return self.judge(True)
            else:
                test_util.test_logger('Check result: [image:] %s [file:] %s does not exist on ceph [host name:] %s .' % (image.uuid, image_installPath, ceph_host))
                return self.judge(False)
    def check_ceph(self, volume, volume_installPath, ps):
        monHost = ps.mons[0].hostname
        for key in os.environ.keys():
            if monHost in os.environ.get(key):
                ceph_host, username, password = \
                        test_lib.lib_get_ceph_info(os.environ.get(key))
                break
        else:
            ceph_host = monHost
            username = '******'
            password = '******'

        volume_installPath = volume_installPath.split('ceph://')[1]
        command = 'rbd info %s' % volume_installPath
        if test_lib.lib_execute_ssh_cmd(ceph_host, username, password, command,
                                        10):
            test_util.test_logger(
                'Check result: [volume:] %s [file:] %s exist on ceph [host name:] %s .'
                % (volume.uuid, volume_installPath, ceph_host))
            return self.judge(True)
        else:
            test_util.test_logger(
                'Check result: [volume:] %s [file:] %s does NOT exist on ceph [host name:] %s .'
                % (volume.uuid, volume_installPath, ceph_host))
            return self.judge(False)
    def check(self):
        super(zstack_kvm_image_file_checker, self).check()
        image = self.test_obj.image
        backupStorages = image.backupStorageRefs
        bs_one = backupStorages[0]
        bs = test_lib.lib_get_backup_storage_by_uuid(bs_one.backupStorageUuid)
        if bs.type == inventory.SFTP_BACKUP_STORAGE_TYPE:
            self.judge(test_lib.lib_check_backup_storage_image_file(image))

        elif hasattr(
                inventory, 'IMAGE_STORE_BACKUP_STORAGE_TYPE'
        ) and bs.type == inventory.IMAGE_STORE_BACKUP_STORAGE_TYPE:
            if self.test_obj.state == image_header.DELETED:
                test_util.test_logger(
                    "skip image store image delete check, since the image won't be deleted until no vms refer to it."
                )
                return self.judge(self.exp_result)
            self.judge(test_lib.lib_check_backup_storage_image_file(image))

        elif bs.type == inventory.CEPH_BACKUP_STORAGE_TYPE:
            if self.test_obj.state == image_header.DELETED:
                #https://github.com/zstackorg/zstack/issues/93#issuecomment-130935998
                test_util.test_logger(
                    "skip ceph image delete check, since the image won't be deleted until no vms refer to it."
                )
                return self.judge(self.exp_result)

            if test_lib.scenario_config != None and test_lib.scenario_file != None and os.path.exists(
                    test_lib.scenario_file):
                import zstackwoodpecker.operations.scenario_operations as sce_ops
                sce_ops.replace_env_params_if_scenario()

            ceph_host, username, password = test_lib.lib_get_ceph_info(
                os.environ.get('cephBackupStorageMonUrls'))
            image_installPath = bs_one.installPath.split('ceph://')[1]

            command = 'rbd info %s' % image_installPath
            if test_lib.lib_execute_ssh_cmd(ceph_host, username, password,
                                            command, 10):
                test_util.test_logger(
                    'Check result: [image:] %s [file:] %s exist on ceph [host name:] %s .'
                    % (image.uuid, image_installPath, ceph_host))
                return self.judge(True)
            else:
                test_util.test_logger(
                    'Check result: [image:] %s [file:] %s does not exist on ceph [host name:] %s .'
                    % (image.uuid, image_installPath, ceph_host))
                return self.judge(False)
    def check_ceph(self, volume, volume_installPath, ps):
        monHost = ps.mons[0].hostname
        for key in os.environ.keys():
            if monHost in os.environ.get(key):
                ceph_host, username, password = \
                        test_lib.lib_get_ceph_info(os.environ.get(key))
                break

        volume_installPath = volume_installPath.split('ceph://')[1]
        command = 'rbd info %s' % volume_installPath
        if test_lib.lib_execute_ssh_cmd(ceph_host, username, password, command, 10):
            test_util.test_logger('Check result: [volume:] %s [file:] %s exist on ceph [host name:] %s .' % (volume.uuid, volume_installPath, ceph_host))
            return self.judge(True)
        else:
            test_util.test_logger('Check result: [volume:] %s [file:] %s does NOT exist on ceph [host name:] %s .' % (volume.uuid, volume_installPath, ceph_host))
            return self.judge(False)