Search in sources :

Example 11 with BaseDisk

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

the class StepDaoTest method diskNullStepProgress.

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

Example 12 with BaseDisk

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

the class StepDaoTest method diskNullFinishedStepProgress.

@Test
public void diskNullFinishedStepProgress() {
    Guid entityId = FixturesTool.FLOATING_DISK_ID;
    prepareProgressTest(entityId);
    List<Guid> stepIds = Arrays.asList(FixturesTool.STEP_ID, FixturesTool.STEP_ID_2);
    stepIds.forEach(x -> {
        Step s = dao.get(x);
        s.setProgress(null);
        s.setStatus(JobExecutionStatus.FINISHED);
        dao.update(s);
    });
    BaseDisk diskImage = getDiskDao().get(entityId);
    assertProgress(80, diskImage);
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step) Test(org.junit.Test)

Example 13 with BaseDisk

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

the class StepDaoTest method prepareProgressTest.

private void prepareProgressTest(Guid entityId) {
    VdcObjectType type = VdcObjectType.Disk;
    BaseDisk diskImage = getDiskDao().get(entityId);
    assertProgress(null, diskImage);
    getStepSubjectEntityDao().saveAll(Arrays.asList(new StepSubjectEntity(FixturesTool.STEP_ID, type, entityId, 30), new StepSubjectEntity(FixturesTool.STEP_ID_2, type, entityId, 50)));
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity)

Example 14 with BaseDisk

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

the class StorageDomainDaoTest method testRemoveEntitesFromStorageDomain.

/**
 * 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 testRemoveEntitesFromStorageDomain() {
    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.removeEntitesFromStorageDomain(existingDomain.getId());
    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 15 with BaseDisk

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

the class SnapshotModel method onSave.

public void onSave() {
    if (getProgress() != null || !validate()) {
        return;
    }
    startProgress();
    VM vm = getVm();
    ArrayList<ActionParametersBase> params = new ArrayList<>();
    Set<Guid> snapshotDisksIds = null;
    if (getSnapshotDisks().getSelectedItems() != null) {
        snapshotDisksIds = getSnapshotDisks().getSelectedItems().stream().map(BaseDisk::getId).collect(Collectors.toSet());
    }
    CreateSnapshotForVmParameters param = new CreateSnapshotForVmParameters(vm.getId(), getDescription().getEntity(), getMemory().getEntity(), snapshotDisksIds);
    param.setQuotaId(vm.getQuotaId());
    params.add(param);
    Frontend.getInstance().runMultipleAction(ActionType.CreateSnapshotForVm, params, result -> {
        SnapshotModel localModel = (SnapshotModel) result.getState();
        localModel.stopProgress();
        getCancelCommand().execute();
    }, this);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) Guid(org.ovirt.engine.core.compat.Guid) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

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