Search in sources :

Example 41 with VmDynamic

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

the class DeactivateStorageDomainCommand method getVmsWithAttachedISO.

protected List<String> getVmsWithAttachedISO() {
    List<VmStatic> vms = vmStaticDao.getAllByStoragePoolId(getStorageDomain().getStoragePoolId());
    List<String> vmNames = new LinkedList<>();
    for (VmStatic vmStatic : vms) {
        VmDynamic vmDynamic = vmDynamicDao.get(vmStatic.getId());
        if (vmDynamic.getStatus() != VMStatus.Down && !StringUtils.isEmpty(vmDynamic.getCurrentCd())) {
            vmNames.add(vmStatic.getName());
        }
    }
    return vmNames;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) LinkedList(java.util.LinkedList)

Example 42 with VmDynamic

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

the class VmDynamicDaoTest method testGuestAgentStatus.

@Test
public void testGuestAgentStatus() throws Exception {
    Guid vmId = FixturesTool.VM_RHEL5_POOL_51;
    VmDynamic vmDynamic = dao.get(vmId);
    vmDynamic.setGuestAgentStatus(GuestAgentStatus.UpdateNeeded);
    dao.update(vmDynamic);
    vmDynamic = dao.get(vmId);
    assertEquals(vmDynamic.getGuestAgentStatus().getValue(), GuestAgentStatus.UpdateNeeded.getValue());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 43 with VmDynamic

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

the class VmDynamicDaoTest method testUpdateToUnknown.

@Test
public void testUpdateToUnknown() {
    VmDynamic existingVm2 = dao.get(FixturesTool.VM_RHEL5_POOL_51);
    VmDynamic existingVm3 = dao.get(FixturesTool.VM_RHEL5_POOL_50);
    dao.updateVmsToUnknown(Arrays.asList(existingEntity.getId(), existingVm2.getId()));
    assertEquals(VMStatus.Unknown, dao.get(existingEntity.getId()).getStatus());
    assertEquals(VMStatus.Unknown, dao.get(existingVm2.getId()).getStatus());
    assertNotEquals(VMStatus.Unknown, dao.get(existingVm3.getId()).getStatus());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Test(org.junit.Test)

Example 44 with VmDynamic

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

the class VmDynamicDaoTest method testGetAllForRunningForVds.

/**
 * Gets all dynamic details for VMs running on a specific VDS.
 */
@Test
public void testGetAllForRunningForVds() {
    List<VmDynamic> result = dao.getAllRunningForVds(FixturesTool.VDS_RHEL6_NFS_SPM);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    assertEquals(DYNAMIC_RUNNING_COUNT, result.size());
    for (VmDynamic vmdynamic : result) {
        assertEquals(FixturesTool.VDS_RHEL6_NFS_SPM, vmdynamic.getRunOnVds());
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Test(org.junit.Test)

Example 45 with VmDynamic

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

the class VmDynamicDaoTest method testUpdateConsoleUserWithOptimisticLockingSuccess.

/**
 * Make sure that saving a new console user id and console user name to a virtual machine
 * without a previous console user succeeds and returns {@code true}.
 */
@Test
public void testUpdateConsoleUserWithOptimisticLockingSuccess() throws Exception {
    VmDynamic vmWithoutConsoleUser = dao.get(FixturesTool.VM_RHEL5_POOL_51);
    vmWithoutConsoleUser.setConsoleUserId(new Guid("9bf7c640-b620-456f-a550-0348f366544b"));
    boolean result = dao.updateConsoleUserWithOptimisticLocking(vmWithoutConsoleUser);
    assertTrue(result);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Aggregations

VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)54 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)12 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)8 VM (org.ovirt.engine.core.common.businessentities.VM)7 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)6 Vm (org.ovirt.engine.api.model.Vm)4 Date (java.util.Date)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 VdsmVm (org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1