Search in sources :

Example 1 with AddDiskParameters

use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.

the class ImportVmFromOvaCommand method buildAddDiskParameters.

@Override
protected AddDiskParameters buildAddDiskParameters(DiskImage image) {
    if (getParameters().getVm().getOrigin() != OriginType.OVIRT) {
        // set default value since VirtIO interface doesn't require having an appropriate controller
        // so validation will pass. This will anyway be overridden later by OVF.
        image.getDiskVmElementForVm(getVm().getId()).setDiskInterface(DiskInterface.VirtIO);
        return super.buildAddDiskParameters(image);
    }
    // The volume format and type is fixed for disks within oVirt's OVA files:
    image.setVolumeFormat(VolumeFormat.COW);
    image.setVolumeType(VolumeType.Sparse);
    AddDiskParameters parameters = super.buildAddDiskParameters(image);
    parameters.setUsePassedDiskId(true);
    parameters.setUsePassedImageId(true);
    return parameters;
}
Also used : AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 2 with AddDiskParameters

use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.

the class UploadImageModel method createInitParams.

private TransferDiskImageParameters createInitParams() {
    Disk newDisk = diskModel.getDisk();
    AddDiskParameters diskParameters = new AddDiskParameters(newDisk);
    if (diskModel.getDiskStorageType().getEntity() == DiskStorageType.IMAGE || diskModel.getDiskStorageType().getEntity() == DiskStorageType.CINDER) {
        diskParameters.setStorageDomainId(getDiskModel().getStorageDomain().getSelectedItem().getId());
    }
    TransferDiskImageParameters parameters = new TransferDiskImageParameters(diskParameters.getStorageDomainId(), diskParameters);
    parameters.setTransferSize(getImageSize());
    parameters.setVdsId(getDiskModel().getHost().getSelectedItem().getId());
    return parameters;
}
Also used : TransferDiskImageParameters(org.ovirt.engine.core.common.action.TransferDiskImageParameters) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 3 with AddDiskParameters

use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.

the class NewDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    startProgress();
    AddDiskParameters parameters = new AddDiskParameters(getDiskVmElement(), getDisk());
    parameters.setPlugDiskToVm(getIsPlugged().getEntity());
    if (getDiskStorageType().getEntity() == DiskStorageType.IMAGE || getDiskStorageType().getEntity() == DiskStorageType.CINDER) {
        StorageDomain storageDomain = getStorageDomain().getSelectedItem();
        parameters.setStorageDomainId(storageDomain.getId());
    }
    IFrontendActionAsyncCallback onFinished = callback != null ? callback : result -> {
        NewDiskModel diskModel = (NewDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
        postSave();
    };
    Frontend.getInstance().runAction(ActionType.AddDisk, parameters, onFinished, this);
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 4 with AddDiskParameters

use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.

the class AddDiskCommandTest method createParameters.

/**
 * @return Valid parameters for the command.
 */
private static AddDiskParameters createParameters() {
    DiskImage image = new DiskImage();
    DiskVmElement dve = new DiskVmElement(null, vmId);
    dve.setDiskInterface(DiskInterface.IDE);
    return new AddDiskParameters(dve, image);
}
Also used : DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Example 5 with AddDiskParameters

use of org.ovirt.engine.core.common.action.AddDiskParameters in project ovirt-engine by oVirt.

the class BackendDisksResource method add.

@Override
public Response add(Disk disk) {
    validateDiskForCreation(disk);
    AddDiskParameters params = new AddDiskParameters();
    Guid storageDomainId = getStorageDomainId(disk);
    params.setStorageDomainId(storageDomainId);
    if (storageDomainId != null) {
        updateStorageTypeForDisk(disk, storageDomainId);
    }
    params.setDiskInfo(getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class).map(disk, null));
    if (disk.isSetLunStorage() && disk.getLunStorage().isSetHost()) {
        params.setVdsId(getHostId(disk.getLunStorage().getHost()));
    }
    if (disk.isSetId()) {
        params.setUsePassedDiskId(true);
    }
    if (disk.isSetImageId()) {
        params.setUsePassedImageId(true);
    }
    return performCreate(ActionType.AddDisk, params, new QueryIdResolver<Guid>(QueryType.GetDiskByDiskId, IdQueryParameters.class));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Guid(org.ovirt.engine.core.compat.Guid) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Aggregations

AddDiskParameters (org.ovirt.engine.core.common.action.AddDiskParameters)17 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 Guid (org.ovirt.engine.core.compat.Guid)6 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)3 ArrayList (java.util.ArrayList)2 Disk (org.ovirt.engine.api.model.Disk)1 QuotaConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter)1 QuotaStorageConsumptionParameter (org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 RegisterDiskParameters (org.ovirt.engine.core.common.action.RegisterDiskParameters)1 TransferDiskImageParameters (org.ovirt.engine.core.common.action.TransferDiskImageParameters)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)1 ImageStatus (org.ovirt.engine.core.common.businessentities.storage.ImageStatus)1 GetUnregisteredDiskQueryParameters (org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)1