Search in sources :

Example 56 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class GetVmsByStorageDomainQueryTest method testExecuteQueryCommandNoDisks.

@Test
public void testExecuteQueryCommandNoDisks() {
    List<VM> vmsOfDomain = new ArrayList<>();
    VM vm1 = mock(VM.class);
    VM vm2 = mock(VM.class);
    vmsOfDomain.add(vm1);
    vmsOfDomain.add(vm2);
    when(vmDao.getAllForStorageDomain(domainId)).thenReturn(vmsOfDomain);
    QueryReturnValue returnValue = new QueryReturnValue();
    returnValue.setSucceeded(true);
    List<DiskImage> diskImages = new ArrayList<>();
    returnValue.setReturnValue(diskImages);
    doReturn(returnValue).when(query).getAllDisksByStorageDomain(domainId);
    query.executeQueryCommand();
    List<VM> vms = query.getQueryReturnValue().getReturnValue();
    assertEquals(2, vms.size());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 57 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class GetUserVmsByUserIdAndGroupsQueryTest method mockDisk.

/**
 * @return A disk to add to the VM
 */
private static DiskImage mockDisk() {
    // Prepare the disk
    Guid diskGuid = Guid.newGuid();
    Guid itGuid = Guid.newGuid();
    final DiskImage expectedDisk = new DiskImage();
    expectedDisk.setImageId(diskGuid);
    expectedDisk.setImageTemplateId(itGuid);
    return expectedDisk;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 58 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class ImportValidatorTest method createVM.

protected VM createVM() {
    final VM v = new VM();
    v.setId(Guid.newGuid());
    Guid imageGroupId = Guid.newGuid();
    DiskImage baseImage = new DiskImage();
    baseImage.setId(imageGroupId);
    baseImage.setImageId(Guid.newGuid());
    baseImage.setSizeInGigabytes(1);
    baseImage.setVmSnapshotId(Guid.newGuid());
    baseImage.setActive(false);
    DiskImage activeImage = new DiskImage();
    activeImage.setId(imageGroupId);
    activeImage.setImageId(Guid.newGuid());
    activeImage.setSizeInGigabytes(1);
    activeImage.setVmSnapshotId(Guid.newGuid());
    activeImage.setActive(true);
    activeImage.setParentId(baseImage.getImageId());
    v.setDiskMap(Collections.singletonMap(activeImage.getId(), activeImage));
    v.setImages(new ArrayList<>(Arrays.asList(baseImage, activeImage)));
    v.setClusterId(Guid.Empty);
    return v;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 59 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class BlockStorageDiscardFunctionalityHelperTest method testExistingPassDiscardFunctionalityIsPreservedAllLunsHaveDiscardFunctionality.

@Test
public void testExistingPassDiscardFunctionalityIsPreservedAllLunsHaveDiscardFunctionality() {
    storageDomain.setSupportsDiscard(true);
    storageDomainDisks.add(new DiskImage());
    assertTrue(discardHelper.isExistingPassDiscardFunctionalityPreserved(Arrays.asList(createLunWithDiscardSupport(1024L), createLunWithDiscardSupport(2048L)), storageDomain));
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 60 with DiskImage

use of org.ovirt.engine.core.common.businessentities.storage.DiskImage in project ovirt-engine by oVirt.

the class DiskImagesValidatorTest method createDisk.

private static DiskImage createDisk() {
    DiskImage disk = new DiskImage();
    disk.setId(Guid.newGuid());
    disk.setDiskAlias(RandomUtils.instance().nextString(10));
    disk.setActive(true);
    disk.setImageStatus(ImageStatus.OK);
    ArrayList<Guid> storageDomainIds = new ArrayList<>();
    storageDomainIds.add(Guid.newGuid());
    disk.setStorageIds(storageDomainIds);
    return disk;
}
Also used : ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Aggregations

DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)635 Guid (org.ovirt.engine.core.compat.Guid)212 ArrayList (java.util.ArrayList)167 Test (org.junit.Test)132 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)80 VM (org.ovirt.engine.core.common.businessentities.VM)77 HashMap (java.util.HashMap)64 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)62 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)62 List (java.util.List)56 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)48 Map (java.util.Map)39 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)38 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)35 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)34 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)31 DiskVmElement (org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)31 EngineException (org.ovirt.engine.core.common.errors.EngineException)29 ActionType (org.ovirt.engine.core.common.action.ActionType)22 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)22