Search in sources :

Example 6 with BaseDisk

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

the class VmDeviceUtils method addImportedDiskDevices.

/**
 * Add disk devices to an imported VM or template.
 *
 * @param vmDevicesToUpdate    list of devices to be updated in the DB
 */
private void addImportedDiskDevices(VmBase vmBase, List<VmDevice> vmDevicesToUpdate) {
    final Guid vmId = vmBase.getId();
    for (BaseDisk disk : getDisks(vmBase.getImages())) {
        Guid deviceId = disk.getId();
        VmDevice vmDevice = addDiskDevice(vmId, deviceId, getVmDeviceAddress(vmBase, vmId));
        updateImportedVmDevice(vmBase, vmDevice, deviceId, vmDevicesToUpdate);
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Guid(org.ovirt.engine.core.compat.Guid)

Example 7 with BaseDisk

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

the class StepDaoTest method diskStepProgress.

@Test
public void diskStepProgress() {
    Guid entityId = FixturesTool.FLOATING_DISK_ID;
    prepareProgressTest(entityId);
    updateStepProgress(FixturesTool.STEP_ID, 10);
    updateStepProgress(FixturesTool.STEP_ID_2, 80);
    BaseDisk diskImage = getDiskDao().get(entityId);
    assertProgress(43, diskImage);
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 8 with BaseDisk

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

the class StorageDomainDaoTest method testRemove.

/**
 * Asserts that the existing Storage Domain exists and has VMs and VM Templates, the after remove asserts
 * that the existing domain is removed along with the VM and VM Templates
 */
@Test
public void testRemove() {
    List<VM> vms = getDbFacade().getVmDao().getAllForStorageDomain(FixturesTool.STORAGE_DOMAIN_SCALE_SD5);
    List<VmTemplate> templates = getDbFacade().getVmTemplateDao().getAllForStorageDomain(FixturesTool.STORAGE_DOMAIN_SCALE_SD5);
    BaseDisk diskImage = getDbFacade().getBaseDiskDao().get(FixturesTool.DISK_ID);
    assertNotNull(diskImage);
    assertFalse(vms.isEmpty());
    assertFalse(templates.isEmpty());
    assertNotNull(dao.get(FixturesTool.STORAGE_DOMAIN_SCALE_SD5));
    dao.remove(existingDomain.getId());
    assertNull(dao.get(FixturesTool.STORAGE_DOMAIN_SCALE_SD5));
    for (VM vm : vms) {
        assertNull(getDbFacade().getVmDao().get(vm.getId()));
    }
    for (VmTemplate template : templates) {
        assertNull(getDbFacade().getVmTemplateDao().get(template.getId()));
    }
    assertNull(getDbFacade().getBaseDiskDao().get(FixturesTool.DISK_ID));
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VM(org.ovirt.engine.core.common.businessentities.VM) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Test(org.junit.Test)

Example 9 with BaseDisk

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

the class ImportHostedEngineStorageDomainCommandTest method prepareCommand.

protected void prepareCommand() {
    parameters.setStoragePoolId(HE_SP_ID);
    parameters.setVdsId(HE_VDS_ID);
    parameters.setStorageDomainId(HE_SD_ID);
    // vds
    VDS vds = new VDS();
    vds.setId(Guid.Empty);
    vds.setStoragePoolId(HE_SP_ID);
    when(vdsDao.get(any())).thenReturn(vds);
    List<BaseDisk> baseDisks = Collections.singletonList(new BaseDisk());
    when(baseDiskDao.getDisksByAlias(any())).thenReturn(baseDisks);
    // Data center
    StoragePool pool = new StoragePool();
    pool.setStatus(StoragePoolStatus.Up);
    pool.setId(HE_SP_ID);
    when(storagePoolDao.get(HE_SP_ID)).thenReturn(pool);
    // compensation
    CompensationContext compensationContext = mock(CompensationContext.class);
    when(cmd.getCompensationContext()).thenReturn(compensationContext);
    when(cmd.getContext()).thenReturn(new CommandContext(new EngineContext()));
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) EngineContext(org.ovirt.engine.core.bll.context.EngineContext)

Example 10 with BaseDisk

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

the class EntityDaoImplTest method testGetEntityNameByIdAndTypeForDisk.

@Test
public void testGetEntityNameByIdAndTypeForDisk() {
    BaseDisk disk = baseDiskDao.get(DISK_ID);
    assertNotNull(disk);
    String name = disk.getDiskAlias();
    assertEquals(name, underTest.getEntityNameByIdAndType(DISK_ID, VdcObjectType.Disk));
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Test(org.junit.Test)

Aggregations

BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)15 Guid (org.ovirt.engine.core.compat.Guid)7 Test (org.junit.Test)6 VM (org.ovirt.engine.core.common.businessentities.VM)4 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Instance (javax.enterprise.inject.Instance)1 Typed (javax.enterprise.inject.Typed)1 Inject (javax.inject.Inject)1