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