use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method map.
private DiskAttachment map(DiskImage entity, DiskAttachment template) {
Disk disk = getMapper(org.ovirt.engine.core.common.businessentities.storage.Disk.class, Disk.class).map(entity, null);
DiskAttachment diskAttachment = new DiskAttachment();
diskAttachment.setDisk(disk);
return diskAttachment;
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmsResource method prepareImagesForCloneFromSnapshotParams.
private void prepareImagesForCloneFromSnapshotParams(DiskAttachments disksAttachments, Map<Guid, DiskImage> imagesFromConfiguration) {
if (disksAttachments.getDiskAttachments() != null) {
for (DiskAttachment diskAttachment : disksAttachments.getDiskAttachments()) {
Disk disk = diskAttachment.getDisk();
if (disk != null && disk.isSetImageId()) {
DiskImage diskImageFromConfig = imagesFromConfiguration.get(asGuid(disk.getImageId()));
DiskImage diskImage = (DiskImage) getMapper(Disk.class, org.ovirt.engine.core.common.businessentities.storage.Disk.class).map(disk, diskImageFromConfig);
imagesFromConfiguration.put(diskImage.getId(), diskImage);
}
}
}
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmsResource method mapDisks.
public ArrayList<DiskImage> mapDisks(Disks disks) {
ArrayList<DiskImage> diskImages = null;
if (disks != null && disks.isSetDisks()) {
diskImages = new ArrayList<>();
for (Disk disk : disks.getDisks()) {
DiskImage diskImage = (DiskImage) DiskMapper.map(disk, null);
diskImages.add(diskImage);
}
}
return diskImages;
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendVmDiskResource method move.
@Override
public Response move(Action action) {
validateParameters(action, "storageDomain.id|name");
Guid storageDomainId = getStorageDomainId(action);
Disk disk = getDisk();
Guid sourceStorageDomainId = getSourceStorageDomainId(disk);
Guid imageId = getDiskImageId(disk.getImageId());
MoveDiskParameters innerParams = new MoveDiskParameters(imageId, sourceStorageDomainId, storageDomainId);
innerParams.setImageGroupID(asGuid(disk.getId()));
MoveDisksParameters params = new MoveDisksParameters(Collections.singletonList(innerParams));
return doAction(ActionType.MoveDisk, params, action);
}
use of org.ovirt.engine.api.model.Disk in project ovirt-engine by oVirt.
the class BackendTemplatesResource method getDestinationTemplateDiskMap.
protected HashMap<Guid, DiskImage> getDestinationTemplateDiskMap(Vm vm, Guid vmId, Guid storageDomainId, boolean isTemplateGeneralStorageDomainSet) {
HashMap<Guid, DiskImage> destinationTemplateDiskMap = null;
if (vm.isSetDiskAttachments() && vm.getDiskAttachments().isSetDiskAttachments()) {
destinationTemplateDiskMap = new HashMap<>();
Map<Guid, org.ovirt.engine.core.common.businessentities.storage.Disk> vmSourceDisks = queryVmDisksMap(vmId);
for (DiskAttachment diskAttachment : vm.getDiskAttachments().getDiskAttachments()) {
Disk disk = diskAttachment.getDisk();
if (disk == null || !disk.isSetId()) {
continue;
}
Guid currDiskID = asGuid(disk.getId());
org.ovirt.engine.core.common.businessentities.storage.Disk sourceDisk = vmSourceDisks.get(currDiskID);
// VM template can only have disk images
if (sourceDisk == null || !isDiskImage(sourceDisk)) {
continue;
}
DiskImage destinationDisk = (DiskImage) DiskMapper.map(disk, sourceDisk);
if (isTemplateGeneralStorageDomainSet) {
destinationDisk.setStorageIds(new ArrayList<>(Arrays.asList(storageDomainId)));
}
// Since domain can be changed, do not set profile and quota for this disk.
destinationDisk.setDiskProfileId(null);
destinationDisk.setQuotaId(null);
destinationTemplateDiskMap.put(destinationDisk.getId(), destinationDisk);
}
}
return destinationTemplateDiskMap;
}
Aggregations