Search in sources :

Example 76 with DiskImage

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

the class DiskImagesValidatorTest method diskImagesAlreadyExistBothExist.

@Test
public void diskImagesAlreadyExistBothExist() {
    doReturn(new DiskImage()).when(validator).getExistingDisk(any());
    assertThat(validator.diskImagesAlreadyExist(), both(failsWith(EngineMessage.ACTION_TYPE_FAILED_IMPORT_DISKS_ALREADY_EXIST)).and(replacements(hasItem(createAliasReplacements(disk1, disk2)))));
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 77 with DiskImage

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

the class DiskImagesValidatorTest method diskImagesAlreadyDiskInImportWithNullAlias.

/**
 * Test a case when the two validated disks exists and have a null disk alias, in that case the disk aliases in
 * the CDA message should be taken from the disks existing on the setup
 */
@Test
public void diskImagesAlreadyDiskInImportWithNullAlias() {
    disk1.setDiskAlias(null);
    disk2.setDiskAlias(null);
    DiskImage existingImage1 = new DiskImage();
    existingImage1.setDiskAlias("existingDiskAlias1");
    DiskImage existingImage2 = new DiskImage();
    existingImage2.setDiskAlias("existingDiskAlias2");
    doReturn(existingImage1).when(validator).getExistingDisk(disk1.getId());
    doReturn(existingImage2).when(validator).getExistingDisk(disk2.getId());
    assertThat(validator.diskImagesAlreadyExist(), both(failsWith(EngineMessage.ACTION_TYPE_FAILED_IMPORT_DISKS_ALREADY_EXIST)).and(replacements(hasItem(createAliasReplacements(existingImage1, existingImage2)))));
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 78 with DiskImage

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

the class BackendAttachedStorageDomainDiskResource method register.

@Override
public Response register(Action action) {
    // First we need to query the backend to fill in all the information about the disk from the VDSM.
    // We don't just use the information from the Disk object because it's missing a few things like creation
    // date and last modified date.
    Guid dataCenterId = BackendDataCenterHelper.lookupByStorageDomainId(this, storageDomainId);
    GetUnregisteredDiskQueryParameters getDiskParams = new GetUnregisteredDiskQueryParameters(guid, storageDomainId, dataCenterId);
    DiskImage unregisteredDisk = getEntity(DiskImage.class, QueryType.GetUnregisteredDisk, getDiskParams, guid.toString());
    RegisterDiskParameters registerDiskParams = new RegisterDiskParameters(unregisteredDisk, storageDomainId);
    return doAction(ActionType.RegisterDisk, registerDiskParams, action);
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) GetUnregisteredDiskQueryParameters(org.ovirt.engine.core.common.queries.GetUnregisteredDiskQueryParameters) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) RegisterDiskParameters(org.ovirt.engine.core.common.action.RegisterDiskParameters)

Example 79 with DiskImage

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

the class BackendStorageDomainDiskSnapshotResourceTest method getEntity.

@Override
protected Disk getEntity(int index) {
    DiskImage entity = new DiskImage();
    entity.setImageId(GUIDS[index]);
    entity.setId(DISK_ID);
    return entity;
}
Also used : DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 80 with DiskImage

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

the class BackendStorageDomainDiskSnapshotsResourceTest method getEntity.

@Override
protected Disk getEntity(int index) {
    DiskImage entity = new DiskImage();
    entity.setImageId(GUIDS[index]);
    entity.setId(DISK_ID);
    return entity;
}
Also used : 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