Search in sources :

Example 61 with VmStatic

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

the class VmStaticDaoTest method testGetAllByCluster.

/**
 * Ensures that all static VMs for the specified VDS group are returned.
 */
@Test
public void testGetAllByCluster() {
    List<VmStatic> result = dao.getAllByCluster(FixturesTool.CLUSTER);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (VmStatic vm : result) {
        assertEquals(FixturesTool.CLUSTER, vm.getClusterId());
    }
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 62 with VmStatic

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

the class VmStaticDaoTest method testGetAllStaticByName.

/**
 * Ensures that all VMs are returned.
 */
@Test
public void testGetAllStaticByName() {
    List<VmStatic> result = dao.getAllByName(FixturesTool.VM_RHEL5_POOL_50_NAME);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (VmStatic vm : result) {
        assertEquals(FixturesTool.VM_RHEL5_POOL_50_NAME, vm.getName());
    }
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 63 with VmStatic

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

the class VmStaticDaoTest method testRemoveWithoutPermissions.

@Test
public void testRemoveWithoutPermissions() {
    for (Snapshot s : dbFacade.getSnapshotDao().getAll()) {
        dbFacade.getSnapshotDao().remove(s.getId());
    }
    PermissionDao permissionsDao = dbFacade.getPermissionDao();
    int numberOfPermissionsBeforeRemove = permissionsDao.getAllForEntity(getExistingEntityId()).size();
    dao.remove(getExistingEntityId(), false);
    VmStatic result = dao.get(getExistingEntityId());
    assertNull(result);
    assertEquals("vm permissions changed during remove although shouldnt have.", numberOfPermissionsBeforeRemove, permissionsDao.getAllForEntity(getExistingEntityId()).size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 64 with VmStatic

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

the class VmStaticDaoTest method initVmStaticsOrderedByPriority.

/**
 * Creates an array of VM static which was initiated for MigrationSupport order, and modified the priority to
 * reflect the precedence of the priority column on top the MigrationSupport.
 *
 * @return an array of VmStatics, in descending order according to: auto_startup, priority, MigrationSupport. The
 *         priority is the one being checked.
 */
private VmStatic[] initVmStaticsOrderedByPriority(List<VmStatic> vmStatics) {
    VmStatic[] vmStaticArray = initVmStaticsOrderedByMigrationSupport(vmStatics);
    // Swapping the first two VmStatics
    VmStatic tempVmStatic = vmStaticArray[0];
    vmStaticArray[0] = vmStaticArray[1];
    vmStaticArray[1] = tempVmStatic;
    int arrayLength = vmStaticArray.length;
    // Setting the array in descending order due to their priorities to maintain its correctness
    for (int i = 0; i < arrayLength; i++) {
        vmStaticArray[i].setPriority(arrayLength - i + 1);
    }
    updateArrayOfVmStaticsInDb(vmStaticArray);
    return vmStaticArray;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 65 with VmStatic

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

the class VmStaticDaoTest method testRemove.

@Test
@Override
public void testRemove() {
    for (Snapshot s : dbFacade.getSnapshotDao().getAll()) {
        dbFacade.getSnapshotDao().remove(s.getId());
    }
    dao.remove(getExistingEntityId());
    VmStatic result = dao.get(getExistingEntityId());
    assertNull(result);
    PermissionDao permissionsDao = dbFacade.getPermissionDao();
    assertEquals("vm permissions wasn't removed", 0, permissionsDao.getAllForEntity(getExistingEntityId()).size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Aggregations

VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)87 Test (org.junit.Test)26 Guid (org.ovirt.engine.core.compat.Guid)15 VM (org.ovirt.engine.core.common.businessentities.VM)11 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)8 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)8 Label (org.ovirt.engine.core.common.businessentities.Label)7 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Response (javax.ws.rs.core.Response)4 AddVmTemplateParameters (org.ovirt.engine.core.common.action.AddVmTemplateParameters)4 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)4 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)4 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 PostConstruct (javax.annotation.PostConstruct)3 Before (org.junit.Before)3