use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class ImportVmCommand method saveDiskImageDynamic.
/**
* Generates and saves a {@link DiskImageDynamic} for the given <code>disk</code>
*
* @param disk
* The imported disk
*/
protected void saveDiskImageDynamic(DiskImage disk) {
DiskImageDynamic diskDynamic = new DiskImageDynamic();
diskDynamic.setId(disk.getImageId());
diskDynamic.setActualSize(disk.getActualSizeInBytes());
diskImageDynamicDao.save(diskDynamic);
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class LiveMigrateDiskCommand method updateImagesInfo.
private void updateImagesInfo() {
for (DiskImage image : diskImageDao.getAllSnapshotsForImageGroup(getParameters().getImageGroupID())) {
VDSReturnValue ret = runVdsCommand(VDSCommandType.GetImageInfo, new GetImageInfoVDSCommandParameters(getParameters().getStoragePoolId(), getParameters().getTargetStorageDomainId(), getParameters().getImageGroupID(), image.getImageId()));
DiskImage imageFromIRS = (DiskImage) ret.getReturnValue();
setQcowCompatForSnapshot(image, imageFromIRS);
DiskImageDynamic diskImageDynamic = diskImageDynamicDao.get(image.getImageId());
// Update image's actual size in DB
if (imageFromIRS != null && diskImageDynamic != null) {
diskImageDynamic.setActualSize(imageFromIRS.getActualSizeInBytes());
diskImageDynamicDao.update(diskImageDynamic);
}
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method buildVmDiskStatistics.
public static List<DiskImageDynamic> buildVmDiskStatistics(Map<String, Object> vmStruct) {
Map<String, Object> disks = (Map<String, Object>) vmStruct.get(VdsProperties.vm_disks);
if (disks == null) {
return Collections.emptyList();
}
List<DiskImageDynamic> disksData = new ArrayList<>();
for (Object diskAsObj : disks.values()) {
Map<String, Object> disk = (Map<String, Object>) diskAsObj;
DiskImageDynamic diskData = new DiskImageDynamic();
String imageGroupIdString = assignStringValue(disk, VdsProperties.image_group_id);
if (!StringUtils.isEmpty(imageGroupIdString)) {
Guid imageGroupIdGuid = new Guid(imageGroupIdString);
diskData.setId(imageGroupIdGuid);
diskData.setReadRate(assignIntValue(disk, VdsProperties.vm_disk_read_rate));
diskData.setWriteRate(assignIntValue(disk, VdsProperties.vm_disk_write_rate));
if (disk.containsKey(VdsProperties.disk_true_size)) {
Long size = assignLongValue(disk, VdsProperties.disk_true_size);
diskData.setActualSize(size != null ? size : 0);
}
if (disk.containsKey(VdsProperties.vm_disk_read_latency)) {
diskData.setReadLatency(assignDoubleValueWithNullProtection(disk, VdsProperties.vm_disk_read_latency) / NANO_SECONDS);
}
if (disk.containsKey(VdsProperties.vm_disk_write_latency)) {
diskData.setWriteLatency(assignDoubleValueWithNullProtection(disk, VdsProperties.vm_disk_write_latency) / NANO_SECONDS);
}
if (disk.containsKey(VdsProperties.vm_disk_flush_latency)) {
diskData.setFlushLatency(assignDoubleValueWithNullProtection(disk, VdsProperties.vm_disk_flush_latency) / NANO_SECONDS);
}
disksData.add(diskData);
}
}
return disksData;
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic in project ovirt-engine by oVirt.
the class BaseImagesCommand method addDiskImageToDb.
protected void addDiskImageToDb(DiskImage image, CompensationContext compensationContext, boolean active) {
image.setActive(active);
imageDao.save(image.getImage());
DiskImageDynamic diskDynamic = updateDiskImageDynamicIntoDB(image);
ImageStorageDomainMap imageStorageDomainMap = new ImageStorageDomainMap(image.getImageId(), image.getStorageIds().get(0), image.getQuotaId(), image.getDiskProfileId());
imageStorageDomainMapDao.save(imageStorageDomainMap);
boolean isDiskAdded = saveDiskIfNotExists(image);
if (compensationContext != null) {
compensationContext.snapshotNewEntity(image.getImage());
compensationContext.snapshotNewEntity(diskDynamic);
compensationContext.snapshotNewEntity(imageStorageDomainMap);
if (isDiskAdded) {
compensationContext.snapshotNewEntity(image);
}
compensationContext.stateChanged();
}
}
use of org.ovirt.engine.core.common.businessentities.storage.DiskImageDynamic 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);
}
Aggregations