Search in sources :

Example 71 with VmStatic

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

the class VmHandlerTest method testValidUpdateOfHostedEngineEditableFieldOnRunningVm.

@Test
public void testValidUpdateOfHostedEngineEditableFieldOnRunningVm() {
    // Given
    VmStatic src = new VmStatic();
    src.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    src.setDescription(RandomUtils.instance().nextString(10));
    VmStatic dest = new VmStatic();
    dest.setOrigin(OriginType.MANAGED_HOSTED_ENGINE);
    dest.setDescription(RandomUtils.instance().nextString(10));
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Up, false);
    // Then
    assertTrue("Update should be valid for different descriptions on a running, hosted engine VM", updateIsValid);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 72 with VmStatic

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

the class VmHandlerTest method testInValidUpdateOfStatusRestrictedEditableFieldOnRunningVm.

@Test
public void testInValidUpdateOfStatusRestrictedEditableFieldOnRunningVm() {
    // Given
    VmStatic src = new VmStatic();
    src.setSingleQxlPci(true);
    VmStatic dest = new VmStatic();
    dest.setSingleQxlPci(false);
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Up, false);
    // Then
    assertFalse("Update should be invalid for different single QXL PCI statuses on a running VM", updateIsValid);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 73 with VmStatic

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

the class ImportVmCommandBase method logImportEvents.

private void logImportEvents() {
    // Some values at the OVF file are used for creating events at the GUI
    // for the sake of providing information on the content of the VM that
    // was exported,
    // but not setting it in the imported VM
    VmStatic vmStaticFromOvf = getVm().getStaticData();
    OvfLogEventHandler<VmStatic> handler = new VMStaticOvfLogHandler(vmStaticFromOvf);
    Map<String, String> aliasesValuesMap = handler.getAliasesValuesMap();
    if (aliasesValuesMap != null) {
        for (Map.Entry<String, String> entry : aliasesValuesMap.entrySet()) {
            String fieldName = entry.getKey();
            String fieldValue = entry.getValue();
            logField(vmStaticFromOvf, fieldName, fieldValue);
        }
    }
    handler.resetDefaults(vmStaticForDefaultValues);
}
Also used : VMStaticOvfLogHandler(org.ovirt.engine.core.utils.ovf.VMStaticOvfLogHandler) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Map(java.util.Map) HashMap(java.util.HashMap)

Example 74 with VmStatic

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

the class UpdateConvertedVmCommand method addImportedDevices.

private void addImportedDevices(VM vm) {
    VmStatic vmStatic = vm.getStaticData();
    // Disk devices were already added
    vmStatic.setImages(new ArrayList<>());
    importUtils.updateGraphicsDevices(vmStatic, getStoragePool().getCompatibilityVersion());
    getVmDeviceUtils().addImportedDevices(vmStatic, false, false);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 75 with VmStatic

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

the class VmManagementCommandBase method updateParametersVmFromInstanceType.

protected void updateParametersVmFromInstanceType() {
    InstanceType instanceType = getInstanceType();
    VmStatic vmStatic = getParameters().getVmStaticData();
    if (instanceType != null) {
        vmStatic.setMemSizeMb(instanceType.getMemSizeMb());
        vmStatic.setNumOfSockets(instanceType.getNumOfSockets());
        vmStatic.setCpuPerSocket(instanceType.getCpuPerSocket());
        vmStatic.setThreadsPerCpu(instanceType.getThreadsPerCpu());
        vmStatic.setAutoStartup(instanceType.isAutoStartup());
        if (FeatureSupported.isMigrationSupported(getCluster().getArchitecture(), getEffectiveCompatibilityVersion())) {
            vmStatic.setMigrationSupport(instanceType.getMigrationSupport());
        }
        vmStatic.setNumOfIoThreads(instanceType.getNumOfIoThreads());
        vmStatic.setMigrationDowntime(instanceType.getMigrationDowntime());
        vmStatic.setPriority(instanceType.getPriority());
        vmStatic.setTunnelMigration(instanceType.getTunnelMigration());
        List<VmDevice> vmDevices = getVmDeviceUtils().getMemoryBalloons(instanceType.getId());
        vmStatic.setMinAllocatedMem(instanceType.getMinAllocatedMem());
        if (vmDevices.isEmpty()) {
            getParameters().setBalloonEnabled(false);
        } else if (osRepository.isBalloonEnabled(getParameters().getVmStaticData().getOsId(), getEffectiveCompatibilityVersion())) {
            getParameters().setBalloonEnabled(true);
        }
        vmStatic.setMigrationPolicyId(instanceType.getMigrationPolicyId());
    }
}
Also used : VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) InstanceType(org.ovirt.engine.core.common.businessentities.InstanceType)

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