Search in sources :

Example 36 with VmStatic

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

the class UpdateRngDeviceTest method mockCommand.

private UpdateRngDeviceCommand mockCommand() {
    final VmStatic vmMock = mock(VmStatic.class);
    when(vmMock.getClusterId()).thenReturn(clusterId);
    when(vmDaoMock.get(vmId)).thenReturn(vmMock);
    when(vmDeviceDaoMock.getVmDeviceByVmIdAndType(vmId, VmDeviceGeneralType.RNG)).thenReturn(Collections.singletonList(new VmDevice()));
    final Cluster cluster = mock(Cluster.class);
    when(cluster.getRequiredRngSources()).thenReturn(Collections.singleton(VmRngDevice.Source.RANDOM));
    when(clusterMock.get(clusterId)).thenReturn(cluster);
    cmd.init();
    return cmd;
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 37 with VmStatic

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

the class UpdateVmCommandTest method initParams.

private static VmManagementParametersBase initParams() {
    VmStatic vmStatic = new VmStatic();
    vmStatic.setClusterId(clusterId);
    vmStatic.setName("my_vm");
    vmStatic.setMaxMemorySizeMb(MAX_MEMORY_SIZE);
    vmStatic.setMemSizeMb(MEMORY_SIZE);
    VmManagementParametersBase params = new VmManagementParametersBase();
    params.setCommandType(ActionType.UpdateVm);
    params.setVmStaticData(vmStatic);
    params.setUpdateNuma(true);
    return params;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase)

Example 38 with VmStatic

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

the class VmStaticDaoTest method initVmStaticsOrderedByAutoStartup.

/**
 * Creates an array of VM static which was initiated for Priority and MigrationSupport order, and modified the
 * auto-startup to reflect the precedence of the auto-startup column on top the Priority.
 *
 * @return an array of VmStatics, in descending order according to: auto_startup, priority, MigrationSupport. The
 *         auto_startup is the one being checked
 */
private VmStatic[] initVmStaticsOrderedByAutoStartup(List<VmStatic> vmStatics) {
    VmStatic[] vmStaticArray = initVmStaticsOrderedByPriority(vmStatics);
    // Swapping the first two VmStatics
    VmStatic tempVmStatic = vmStaticArray[0];
    vmStaticArray[0] = vmStaticArray[1];
    vmStaticArray[1] = tempVmStatic;
    // Maintaining the order correctness of the elements by incrementing the auto_startup of the first element
    vmStaticArray[0].setAutoStartup(true);
    updateArrayOfVmStaticsInDb(vmStaticArray);
    return vmStaticArray;
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 39 with VmStatic

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

the class VmStaticDaoTest method testGetAllWithFailbackByVds.

/**
 * Ensures that the right set of VMs are returned.
 */
@Test
public void testGetAllWithFailbackByVds() {
    List<VmStatic> result = dao.getAllWithFailbackByVds(FixturesTool.VDS_RHEL6_NFS_SPM);
    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 40 with VmStatic

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

the class VmStaticDaoTest method generateNewEntity.

@Override
protected VmStatic generateNewEntity() {
    VmStatic newVmStatic = new VmStatic();
    newVmStatic.setId(Guid.newGuid());
    newVmStatic.setName("New Virtual Machine");
    newVmStatic.setClusterId(FixturesTool.CLUSTER);
    newVmStatic.setVmtGuid(FixturesTool.VM_TEMPLATE_RHEL5);
    newVmStatic.setOrigin(OriginType.OVIRT);
    newVmStatic.setQuotaId(FixturesTool.QUOTA_GENERAL);
    newVmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1);
    newVmStatic.setSmallIconId(FixturesTool.SMALL_ICON_ID);
    newVmStatic.setLargeIconId(FixturesTool.LARGE_ICON_ID);
    newVmStatic.setConsoleDisconnectAction(ConsoleDisconnectAction.REBOOT);
    return newVmStatic;
}
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