Search in sources :

Example 1 with VolumeFormat

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

the class StorageDomainValidatorFreeSpaceTest method createParams.

@Parameterized.Parameters
public static Collection<Object[]> createParams() {
    List<Object[]> params = new ArrayList<>();
    for (StorageType storageType : StorageType.values()) {
        if (storageType.isConcreteStorageType() && !storageType.isCinderDomain()) {
            List<VolumeType> volumeTypes = storageType.isFileDomain() ? Arrays.asList(VolumeType.Preallocated, VolumeType.Sparse) : Collections.singletonList(VolumeType.Preallocated);
            for (VolumeType volumeType : volumeTypes) {
                for (VolumeFormat volumeFormat : new VolumeFormat[] { VolumeFormat.COW, VolumeFormat.RAW }) {
                    DiskImage disk = new DiskImage();
                    disk.setVolumeFormat(volumeFormat);
                    disk.setVolumeType(volumeType);
                    disk.getSnapshots().add(disk);
                    disk.setSizeInGigabytes(200);
                    // GB
                    disk.setActualSize(100);
                    StorageDomain sd = new StorageDomain();
                    sd.setStorageType(storageType);
                    // GB
                    sd.setAvailableDiskSize(107);
                    params.add(new Object[] { disk, sd, volumeFormat == VolumeFormat.RAW && volumeType == VolumeType.Sparse, volumeFormat == VolumeFormat.COW || volumeType == VolumeType.Sparse, volumeFormat == VolumeFormat.RAW && volumeType == VolumeType.Sparse });
                }
            }
        }
    }
    return params;
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 2 with VolumeFormat

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

the class CreateImageTemplateCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid storagePoolId = getDiskImage().getStoragePoolId() != null ? getDiskImage().getStoragePoolId() : Guid.Empty;
    Guid imageGroupId = getDiskImage().getId() != null ? getDiskImage().getId() : Guid.Empty;
    Guid snapshotId = getDiskImage().getImageId();
    // Create new image group id and image id:
    Guid destinationImageGroupID = Guid.newGuid();
    setDestinationImageId(Guid.newGuid());
    DiskImage newImage = cloneDiskImage(getDestinationImageId());
    if (getParameters().getVolumeFormat() == null || getParameters().getVolumeType() == null) {
        // At least one of the volume arguments should be copied from the ancestral image.
        fillVolumeInformation(newImage);
    }
    if (getParameters().getVolumeFormat() != null) {
        newImage.setVolumeFormat(getParameters().getVolumeFormat());
    }
    if (getParameters().getVolumeType() != null) {
        newImage.setVolumeType(getParameters().getVolumeType());
    }
    Guid taskId = persistAsyncTaskPlaceHolder(getParameters().getParentCommand());
    VolumeFormat targetFormat = getTargetVolumeFormat(newImage.getVolumeFormat(), newImage.getVolumeType(), getParameters().getDestinationStorageDomainId());
    newImage.setDiskAlias(getParameters().getDiskAlias() != null ? getParameters().getDiskAlias() : getDiskImage().getDiskAlias());
    VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.CopyImage, postDeleteActionHandler.fixParameters(new CopyImageVDSCommandParameters(storagePoolId, getParameters().getStorageDomainId(), getParameters().getVmId(), imageGroupId, snapshotId, destinationImageGroupID, getDestinationImageId(), getJsonDiskDescription(newImage), getParameters().getDestinationStorageDomainId(), getParameters().getCopyVolumeType(), targetFormat, newImage.getVolumeType(), getDiskImage().isWipeAfterDelete(), storageDomainDao.get(getParameters().getDestinationStorageDomainId()).getDiscardAfterDelete(), false)));
    getReturnValue().getInternalVdsmTaskIdList().add(createTask(taskId, vdsReturnValue.getCreationInfo(), getParameters().getParentCommand(), VdcObjectType.Storage, getParameters().getStorageDomainId(), getParameters().getDestinationStorageDomainId()));
    newImage.setId(destinationImageGroupID);
    newImage.setDiskDescription(getParameters().getDescription() != null ? getParameters().getDescription() : getDiskImage().getDiskDescription());
    newImage.setVmSnapshotId(getParameters().getVmSnapshotId());
    newImage.setQuotaId(getParameters().getQuotaId());
    newImage.setDiskProfileId(getParameters().getDiskProfileId());
    newImage.setParentId(Guid.Empty);
    newImage.setImageTemplateId(Guid.Empty);
    newImage.setStorageIds(new ArrayList<>(Arrays.asList(getParameters().getDestinationStorageDomainId())));
    newImage.setActive(true);
    imagesHandler.saveImage(newImage);
    baseDiskDao.save(newImage);
    DiskImageDynamic diskDynamic = new DiskImageDynamic();
    diskDynamic.setId(newImage.getImageId());
    diskDynamic.setActualSize(getDiskImage().getActualSizeInBytes());
    diskImageDynamicDao.save(diskDynamic);
    setActionReturnValue(newImage);
    // set source image as locked:
    lockImage();
    setSucceeded(true);
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) CopyImageVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskImageDynamic(org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with VolumeFormat

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

the class BackendStorageDomainVmResource method setVolumesTypeFormat.

private void setVolumesTypeFormat(Action action) {
    if (action.isSetVm()) {
        Vm modelVm = action.getVm();
        if (!modelVm.isSetDiskAttachments()) {
            return;
        }
        Map<Guid, org.ovirt.engine.core.common.businessentities.storage.Disk> entityDisks = getDiskMap();
        for (DiskAttachment modelDiskAttachment : modelVm.getDiskAttachments().getDiskAttachments()) {
            Disk modelDisk = modelDiskAttachment.getDisk();
            if (modelDisk != null) {
                validateParameters(modelDisk, "id");
                Guid modelDiskId = Guid.createGuidFromString(modelDisk.getId());
                DiskImage entityDisk = (DiskImage) entityDisks.get(modelDiskId);
                if (entityDisk == null) {
                    continue;
                }
                if (modelDisk.isSetFormat()) {
                    VolumeFormat entityDiskFormat = DiskMapper.map(modelDisk.getFormat(), null);
                    entityDisk.setVolumeFormat(entityDiskFormat);
                }
                if (modelDisk.isSetSparse()) {
                    entityDisk.setVolumeType(modelDisk.isSparse() ? VolumeType.Sparse : VolumeType.Preallocated);
                }
            }
        }
    }
}
Also used : VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Vm(org.ovirt.engine.api.model.Vm) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 4 with VolumeFormat

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

the class DisksAllocationModel method updateImageToDestinationDomainMap.

private void updateImageToDestinationDomainMap() {
    if (disks == null) {
        return;
    }
    for (DiskModel diskModel : disks) {
        StorageDomain storageDomain = diskModel.getStorageDomain().getSelectedItem();
        DiskImage diskImage = (DiskImage) diskModel.getDisk();
        diskImage.setStorageIds(new ArrayList<>(Collections.singletonList(storageDomain.getId())));
        diskImage.setDiskAlias(diskModel.getAlias().getEntity());
        DiskProfile diskProfile = diskModel.getDiskProfile().getSelectedItem();
        diskImage.setDiskProfileId(diskProfile != null ? diskProfile.getId() : null);
        if (diskModel.getQuota().getSelectedItem() != null) {
            diskImage.setQuotaId(diskModel.getQuota().getSelectedItem().getId());
        }
        if (diskModel.getVolumeFormat().getIsAvailable()) {
            VolumeFormat volumeFormat = diskModel.getVolumeFormat().getSelectedItem();
            diskImage.setVolumeFormat(volumeFormat);
            diskImage.setVolumeType(AsyncDataProvider.getInstance().getVolumeType(volumeFormat, storageDomain.getStorageType()));
        } else if (diskModel.getVolumeType().getIsAvailable()) {
            VolumeType volumeType = diskModel.getVolumeType().getSelectedItem();
            diskImage.setVolumeType(volumeType);
            diskImage.setVolumeFormat(AsyncDataProvider.getInstance().getDiskVolumeFormat(volumeType, storageDomain.getStorageType()));
        }
        imageToDestinationDomainMap.put(diskImage.getId(), diskImage);
    }
}
Also used : DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DiskProfile(org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 VolumeFormat (org.ovirt.engine.core.common.businessentities.storage.VolumeFormat)4 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 VolumeType (org.ovirt.engine.core.common.businessentities.storage.VolumeType)2 Guid (org.ovirt.engine.core.compat.Guid)2 ArrayList (java.util.ArrayList)1 Disk (org.ovirt.engine.api.model.Disk)1 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)1 Vm (org.ovirt.engine.api.model.Vm)1 DiskProfile (org.ovirt.engine.core.common.businessentities.profiles.DiskProfile)1 DiskImageDynamic (org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic)1 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)1 CopyImageVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.CopyImageVDSCommandParameters)1 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)1 DiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)1