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;
}
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;
}
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);
}
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);
}
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));
}
Aggregations