Search in sources :

Example 1 with QemuImageInfo

use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.

the class GetUnregisteredDiskQuery method fetchQcowCompat.

private boolean fetchQcowCompat(Guid storagePoolId, Guid storageDomainId, Guid diskId, Guid volumeId, DiskImage newDiskImage) {
    if (newDiskImage.getVolumeFormat().equals(VolumeFormat.COW)) {
        StoragePool sp = storagePoolDao.get(storagePoolId);
        QemuImageInfo qemuImageInfo = null;
        if (sp != null && FeatureSupported.qcowCompatSupported(sp.getCompatibilityVersion())) {
            try {
                qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(storagePoolId, storageDomainId, diskId, volumeId, null, true);
            } catch (Exception e) {
            // do nothing, an exception string will be returned since qemuImageInfo is null.
            }
            if (qemuImageInfo == null) {
                getQueryReturnValue().setExceptionString("Failed to fetch qemu image info from storage");
                return false;
            }
            newDiskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
        }
    }
    return true;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QemuImageInfo(org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo) DecoderException(org.apache.commons.codec.DecoderException) IOException(java.io.IOException)

Example 2 with QemuImageInfo

use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.

the class GetQemuImageInfoVDSCommand method buildImageEntity.

public QemuImageInfo buildImageEntity(Map<String, Object> struct) {
    QemuImageInfo qemuImageInfo = new QemuImageInfo();
    try {
        qemuImageInfo.setImageId(getParameters().getImageId());
        qemuImageInfo.setImageGroupId(getParameters().getImageGroupId());
        qemuImageInfo.setStorageDomainId(getParameters().getStorageDomainId());
        qemuImageInfo.setStoragePoolId(getParameters().getStoragePoolId());
        if (struct.containsKey("compat")) {
            qemuImageInfo.setQcowCompat(QcowCompat.forCompatValue(struct.get("compat").toString()));
        }
        if (struct.containsKey("format")) {
            qemuImageInfo.setQemuVolumeFormat(EnumUtils.valueOf(QemuVolumeFormat.class, struct.get("format").toString(), true));
        }
        if (struct.containsKey("backingfile")) {
            qemuImageInfo.setBackingFile(struct.get("backingfile").toString());
        }
        if (struct.containsKey("virtualsize")) {
            qemuImageInfo.setSize(Long.parseLong(struct.get("virtualsize").toString()));
        }
        if (struct.containsKey("clustersize")) {
            qemuImageInfo.setClusterSize(Long.parseLong(struct.get("clustersize").toString()));
        }
    } catch (RuntimeException ex) {
        log.error("Failed building Qemu image: {}", ex.getMessage());
        printReturnValue();
        log.debug("Exception", ex);
        qemuImageInfo = null;
    }
    return qemuImageInfo;
}
Also used : QemuVolumeFormat(org.ovirt.engine.core.common.businessentities.storage.QemuVolumeFormat) QemuImageInfo(org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo)

Example 3 with QemuImageInfo

use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.

the class ImportVmTemplateCommand method setQcowCompat.

protected void setQcowCompat(DiskImage diskImage) {
    diskImage.setQcowCompat(QcowCompat.QCOW2_V2);
    if (FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
        QemuImageInfo qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(diskImage.getStoragePoolId(), diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId(), null, true);
        if (qemuImageInfo != null) {
            diskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
        }
    }
    imageDao.update(diskImage.getImage());
}
Also used : QemuImageInfo(org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo)

Example 4 with QemuImageInfo

use of org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo in project ovirt-engine by oVirt.

the class ImportVmCommand method setQcowCompat.

protected void setQcowCompat(DiskImage diskImage) {
    diskImage.setQcowCompat(QcowCompat.QCOW2_V2);
    if (FeatureSupported.qcowCompatSupported(getStoragePool().getCompatibilityVersion())) {
        QemuImageInfo qemuImageInfo = imagesHandler.getQemuImageInfoFromVdsm(diskImage.getStoragePoolId(), diskImage.getStorageIds().get(0), diskImage.getId(), diskImage.getImageId(), null, true);
        if (qemuImageInfo != null) {
            diskImage.setQcowCompat(qemuImageInfo.getQcowCompat());
        }
    }
    imageDao.update(diskImage.getImage());
}
Also used : QemuImageInfo(org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo)

Aggregations

QemuImageInfo (org.ovirt.engine.core.common.businessentities.storage.QemuImageInfo)4 IOException (java.io.IOException)1 DecoderException (org.apache.commons.codec.DecoderException)1 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)1 QemuVolumeFormat (org.ovirt.engine.core.common.businessentities.storage.QemuVolumeFormat)1