Search in sources :

Example 21 with Disk

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;
}
Also used : DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Disk(org.ovirt.engine.api.model.Disk)

Example 22 with Disk

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);
            }
        }
    }
}
Also used : DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 23 with Disk

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;
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.api.model.Disk)

Example 24 with Disk

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);
}
Also used : MoveDiskParameters(org.ovirt.engine.core.common.action.MoveDiskParameters) MoveDisksParameters(org.ovirt.engine.core.common.action.MoveDisksParameters) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk)

Example 25 with Disk

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;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DiskAttachment(org.ovirt.engine.api.model.DiskAttachment) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Disk(org.ovirt.engine.api.model.Disk)

Aggregations

Disk (org.ovirt.engine.api.model.Disk)68 Test (org.junit.Test)33 Response (javax.ws.rs.core.Response)13 Guid (org.ovirt.engine.core.compat.Guid)13 WebApplicationException (javax.ws.rs.WebApplicationException)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)10 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 StorageDomain (org.ovirt.engine.api.model.StorageDomain)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 Vm (org.ovirt.engine.api.model.Vm)6 StorageDomains (org.ovirt.engine.api.model.StorageDomains)4 V3Disk (org.ovirt.engine.api.v3.types.V3Disk)4 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 UriInfo (javax.ws.rs.core.UriInfo)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 V3CdRoms (org.ovirt.engine.api.v3.types.V3CdRoms)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3Floppies (org.ovirt.engine.api.v3.types.V3Floppies)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2