Search in sources :

Example 46 with VmDynamic

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

the class VmDynamicDaoTest method testUpdateStatus.

/**
 * Ensures updating the dynamic status aspect of the VM works.
 */
@Test
public void testUpdateStatus() {
    existingEntity.setStatus(VMStatus.Down);
    dao.updateStatus(existingEntity.getId(), existingEntity.getStatus());
    VmDynamic after = dao.get(existingEntity.getId());
    assertEquals(existingEntity, after);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Test(org.junit.Test)

Example 47 with VmDynamic

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

the class MaintenanceNumberOfVdssCommand method cancelIncommingMigrations.

private void cancelIncommingMigrations() {
    for (Guid hostId : vdssToMaintenance.keySet()) {
        for (VmDynamic vm : vmDynamicDao.getAllMigratingToHost(hostId)) {
            if (vm.getStatus() == VMStatus.MigratingFrom) {
                log.info("Cancelling incoming migration of '{}' id '{}'", vm, vm.getId());
                runVdsCommand(VDSCommandType.CancelMigrate, new CancelMigrationVDSParameters(vm.getRunOnVds(), vm.getId(), true));
            }
        }
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) CancelMigrationVDSParameters(org.ovirt.engine.core.vdsbroker.vdsbroker.CancelMigrationVDSParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 48 with VmDynamic

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

the class AddVmTemplateCommand method init.

@Override
protected void init() {
    if (Guid.isNullOrEmpty(getParameters().getVmTemplateId())) {
        getParameters().setVmTemplateId(Guid.newGuid());
    }
    setVmTemplateId(getParameters().getVmTemplateId());
    getParameters().setEntityInfo(new EntityInfo(VdcObjectType.VmTemplate, getVmTemplateId()));
    setVmTemplateName(getParameters().getName());
    VmStatic masterVm = getParameters().getMasterVm();
    if (masterVm != null) {
        setVmId(masterVm.getId());
        setClusterId(masterVm.getClusterId());
        // API backward compatibility
        if (getVmDeviceUtils().shouldOverrideSoundDevice(masterVm, getMasterVmCompatibilityVersion(), getParameters().isSoundDeviceEnabled())) {
            getParameters().setSoundDeviceEnabled(true);
        }
        if (getParameters().isSoundDeviceEnabled() == null) {
            getParameters().setSoundDeviceEnabled(false);
        }
        if (getParameters().isConsoleEnabled() == null) {
            getParameters().setConsoleEnabled(false);
        }
        vmHandler.updateDefaultTimeZone(masterVm);
        vmHandler.autoSelectUsbPolicy(masterVm);
        vmHandler.autoSelectDefaultDisplayType(getVmId(), masterVm, getCluster(), getParameters().getGraphicsDevices());
        vmHandler.autoSelectGraphicsDevice(getVmId(), masterVm, getCluster(), getParameters().getGraphicsDevices(), getMasterVmCompatibilityVersion());
        vmHandler.autoSelectResumeBehavior(masterVm, getCluster());
        separateCustomProperties(masterVm);
    }
    if (getVm() != null) {
        updateVmDevices();
        images.addAll(getVmDisksFromDB());
        setStoragePoolId(getVm().getStoragePoolId());
        isVmInDb = true;
    } else if (getCluster() != null && masterVm != null) {
        VM vm = new VM(masterVm, new VmDynamic(), null);
        vm.setClusterCompatibilityVersion(getCluster().getCompatibilityVersion());
        setVm(vm);
        setStoragePoolId(getCluster().getStoragePoolId());
    }
    updateDiskInfoDestinationMap();
    generateTargetDiskIds();
    getParameters().setUseCinderCommandCallback(!getCinderDisks().isEmpty());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 49 with VmDynamic

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

the class RestoreAllSnapshotsCommandTest method getVmDynamic.

/**
 * Mock a VM.
 */
private VmDynamic getVmDynamic() {
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setId(vmId);
    vmDynamic.setStatus(VMStatus.Down);
    return vmDynamic;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 50 with VmDynamic

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

the class VmMapperTest method testGuestTimezone.

@Test
public void testGuestTimezone() {
    org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM();
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setStatus(VMStatus.Up);
    vmDynamic.setGuestOsTimezoneName("This is not a timezone");
    vmDynamic.setGuestOsTimezoneOffset(-60);
    vm.setDynamicData(vmDynamic);
    Vm map = VmMapper.map(vm, (Vm) null);
    assertNotNull(map.getGuestTimeZone());
    assertEquals("-01:00", map.getGuestTimeZone().getUtcOffset());
    assertEquals("This is not a timezone", map.getGuestTimeZone().getName());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Aggregations

VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)54 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)12 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)8 VM (org.ovirt.engine.core.common.businessentities.VM)7 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)6 Vm (org.ovirt.engine.api.model.Vm)4 Date (java.util.Date)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 VdsmVm (org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1