Search in sources :

Example 66 with VmStatic

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

the class VmStaticDaoTest method testGetAllByGroupAndNetwork.

/**
 * Ensures that all static vm details for the specified group and network are returned.
 */
@Test
public void testGetAllByGroupAndNetwork() {
    List<VmStatic> result = dao.getAllByGroupAndNetworkName(FixturesTool.CLUSTER, "engine");
    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 67 with VmStatic

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

the class VmStaticDaoTest method testAllCpuProfileValuesEqualTo.

private void testAllCpuProfileValuesEqualTo(Guid clusterId, Guid cpuProfileId, boolean isAllNull) {
    List<VmStatic> allByCluster = dao.getAllByCluster(clusterId);
    assertNotNull(allByCluster);
    assertFalse(allByCluster.isEmpty());
    boolean allValues = true;
    for (VmStatic vmStatic : allByCluster) {
        allValues &= Objects.equals(vmStatic.getCpuProfileId(), cpuProfileId);
    }
    assertEquals(isAllNull, allValues);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 68 with VmStatic

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

the class VmDaoTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getVmDao();
    existingVm = dao.get(FixturesTool.VM_RHEL5_POOL_57);
    existingVm.setStatus(VMStatus.Up);
    VmTemplate vmtemplate = dbFacade.getVmTemplateDao().get(FixturesTool.VM_TEMPLATE_RHEL5);
    existingTemplate = dbFacade.getVmTemplateDao().get(FixturesTool.VM_TEMPLATE_RHEL5);
    VM newVm = new VM();
    newVm.setId(Guid.newGuid());
    newVm.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI);
    newVm.setVmtGuid(vmtemplate.getId());
    VmStatic newVmStatic = new VmStatic();
    newVmStatic.setName("New Virtual Machine");
    newVmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI);
    newVmStatic.setVmtGuid(vmtemplate.getId());
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 69 with VmStatic

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

the class StorageDomainDaoTest method testIsHostedEngineStorage.

@Test
public void testIsHostedEngineStorage() {
    // create hosted engine vm
    VmStatic vm = new VmStatic();
    vm.setId(Guid.newGuid());
    vm.setOrigin(OriginType.HOSTED_ENGINE);
    dbFacade.getVmStaticDao().save(vm);
    // create disk for HE
    DiskImage disk = new DiskImage();
    disk.setId(Guid.newGuid());
    disk.setImageId(Guid.newGuid());
    disk.setActive(true);
    disk.setVolumeType(VolumeType.Preallocated);
    disk.setVolumeFormat(VolumeFormat.RAW);
    dbFacade.getImageDao().save(disk.getImage());
    dbFacade.getBaseDiskDao().save(disk);
    ImageStorageDomainMap map = new ImageStorageDomainMap(disk.getImageId(), existingDomain.getId(), null, null);
    dbFacade.getImageStorageDomainMapDao().save(map);
    // attach disk
    VmDevice device = new VmDevice(new VmDeviceId(disk.getId(), vm.getId()), VmDeviceGeneralType.DISK, VmDeviceType.DISK.getName(), "", null, true, false, false, "", null, null, null);
    dbFacade.getVmDeviceDao().save(device);
    DiskVmElement diskVmElement = new DiskVmElement(device.getId());
    diskVmElement.setDiskInterface(DiskInterface.IDE);
    dbFacade.getDiskVmElementDao().save(diskVmElement);
    // run test
    StorageDomain domain = dao.get(existingDomain.getId());
    assertTrue(domain.isHostedEngineStorage());
    // change origin
    vm.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    dbFacade.getVmStaticDao().update(vm);
    // run test again
    domain = dao.get(existingDomain.getId());
    assertTrue(domain.isHostedEngineStorage());
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ImageStorageDomainMap(org.ovirt.engine.core.common.businessentities.storage.ImageStorageDomainMap) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) Test(org.junit.Test)

Example 70 with VmStatic

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

the class BackendVmPoolsResourceTest method getVmEntity.

protected org.ovirt.engine.core.common.businessentities.VM getVmEntity() {
    org.ovirt.engine.core.common.businessentities.VM entity = mock(org.ovirt.engine.core.common.businessentities.VM.class);
    when(entity.getId()).thenReturn(GUIDS[0]);
    when(entity.getStaticData()).thenReturn(new VmStatic());
    return entity;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

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