Search in sources :

Example 26 with VmStatic

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

the class HotUnplugMemoryCommand method updateCurrentConfiguration.

private void updateCurrentConfiguration(int memoryAfterHotUnplugMb, int minMemoryAfterHotUnplugMb) {
    final VmStatic updatedVmStatic = new VmStatic(getVm().getStaticData());
    updatedVmStatic.setMemSizeMb(memoryAfterHotUnplugMb);
    updatedVmStatic.setMinAllocatedMem(minMemoryAfterHotUnplugMb);
    getVmManager().update(updatedVmStatic);
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 27 with VmStatic

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

the class IconLoader method updateVmStaticTable.

private void updateVmStaticTable() {
    for (VmStatic vmStatic : vmStaticDao.getAllWithoutIcon()) {
        setIconsByOs(vmStatic);
        vmStaticDao.update(vmStatic);
    }
    for (VmTemplate vmTemplate : vmTemplateDao.getAllWithoutIcon()) {
        setIconsByOs(vmTemplate);
        vmTemplateDao.update(vmTemplate);
    }
}
Also used : VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 28 with VmStatic

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

the class HostedEngineHelper method init.

@PostConstruct
private void init() {
    List<VmStatic> byName = vmStaticDao.getAllByName(Config.getValue(ConfigValues.HostedEngineVmName));
    if (byName != null && !byName.isEmpty()) {
        VmStatic vmStatic = byName.get(0);
        hostedEngineVm = vmDao.get(vmStatic.getId());
        vmHandler.updateDisksFromDb(hostedEngineVm);
    }
    initHostedEngineStorageDomain();
}
Also used : VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) PostConstruct(javax.annotation.PostConstruct)

Example 29 with VmStatic

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

the class SnapshotsManager method updateVmFromConfiguration.

/**
 * Update the given VM with the (static) data that is contained in the configuration. The {@link VM#getImages()}
 * will contain the images that were read from the configuration.
 *
 * @param vm
 *            The VM to update.
 * @param configuration
 *            The configuration to update from.
 * @return In case of a problem reading the configuration, <code>false</code>. Otherwise, <code>true</code>.
 */
public boolean updateVmFromConfiguration(VM vm, String configuration) {
    try {
        VmStatic oldVmStatic = vm.getStaticData();
        VM tempVM = new VM();
        if (vm.getDynamicData() != null) {
            tempVM.setDynamicData(vm.getDynamicData());
        }
        FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(tempVM);
        ovfManager.importVm(configuration, tempVM, fullEntityOvfData);
        for (DiskImage diskImage : fullEntityOvfData.getDiskImages()) {
            DiskImage dbImage = diskImageDao.getSnapshotById(diskImage.getImageId());
            if (dbImage != null) {
                diskImage.setStorageIds(dbImage.getStorageIds());
            }
        }
        new VMStaticOvfLogHandler(tempVM.getStaticData()).resetDefaults(oldVmStatic);
        vm.setStaticData(tempVM.getStaticData());
        IconUtils.preserveIcons(vm.getStaticData(), oldVmStatic);
        vm.setImages((ArrayList<DiskImage>) fullEntityOvfData.getDiskImages());
        vm.setInterfaces(fullEntityOvfData.getInterfaces());
        // These fields are not saved in the OVF, so get them from the current VM.
        vm.setIsoPath(oldVmStatic.getIsoPath());
        vm.setCpuProfileId(oldVmStatic.getCpuProfileId());
        vm.setClusterId(oldVmStatic.getClusterId());
        // The VM configuration does not hold the vds group Id.
        // It is necessary to fetch the vm static from the Db, in order to get this information
        VmStatic vmStaticFromDb = vmStaticDao.get(vm.getId());
        if (vmStaticFromDb != null) {
            Cluster cluster = clusterDao.get(vmStaticFromDb.getClusterId());
            if (cluster != null) {
                vm.setStoragePoolId(cluster.getStoragePoolId());
                vm.setClusterCompatibilityVersion(cluster.getCompatibilityVersion());
                vm.setClusterName(cluster.getName());
                vm.setClusterCpuName(cluster.getCpuName());
            }
        }
        // if the required dedicated host is invalid -> use current VM dedicated host
        if (!vmHandler.validateDedicatedVdsExistOnSameCluster(vm.getStaticData()).isValid()) {
            vm.setDedicatedVmForVdsList(oldVmStatic.getDedicatedVmForVdsList());
        }
        vmHandler.updateMaxMemorySize(vm.getStaticData(), vm.getCompatibilityVersion());
        vmHandler.autoSelectResumeBehavior(vm.getStaticData(), vm.getCompatibilityVersion());
        validateQuota(vm);
        return true;
    } catch (OvfReaderException e) {
        log.error("Failed to update VM from the configuration '{}': {}", configuration, e.getMessage());
        log.debug("Exception", e);
        return false;
    }
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) VMStaticOvfLogHandler(org.ovirt.engine.core.utils.ovf.VMStaticOvfLogHandler) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Example 30 with VmStatic

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

the class VmHandlerTest method testValidUpdateOfEditableFieldOnDownVm.

@Test
public void testValidUpdateOfEditableFieldOnDownVm() {
    // Given
    VmStatic src = new VmStatic();
    src.setClusterId(Guid.newGuid());
    VmStatic dest = new VmStatic();
    dest.setClusterId(Guid.newGuid());
    // When
    boolean updateIsValid = vmHandler.isUpdateValid(src, dest, VMStatus.Down, false);
    // Then
    assertTrue("Update should be valid for different cluster IDs in the down state", updateIsValid);
}
Also used : 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