Search in sources :

Example 21 with VmDynamic

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

the class VmHandler method checkStatusAndLockVm.

/**
 * Lock VM with compensation, after checking its status, If VM status is locked, we throw an exception.
 *
 * @param vmId
 *            - The ID of the VM, which we want to lock.
 * @param compensationContext
 *            - Used to save the old VM status for compensation purposes.
 */
public void checkStatusAndLockVm(Guid vmId, CompensationContext compensationContext) {
    VmDynamic vmDynamic = vmDynamicDao.get(vmId);
    checkStatusBeforeLock(vmDynamic.getStatus());
    lockVm(vmDynamic, compensationContext);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 22 with VmDynamic

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

the class VmDynamicDaoImpl method getAllRunningForVds.

@Override
public List<VmDynamic> getAllRunningForVds(Guid id) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vds_id", id);
    RowMapper<VmDynamic> mapper = createEntityRowMapper();
    return getCallsHandler().executeReadList("GetVmsDynamicRunningOnVds", mapper, parameterSource);
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 23 with VmDynamic

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

the class BackendVmPoolsResource method mapToVM.

protected VM mapToVM(VmPool model, VmTemplate template, Cluster cluster) {
    // apply template
    VmStatic fromTemplate = getMapper(VmTemplate.class, VmStatic.class).map(template, null);
    VmStatic fromInstanceType = null;
    if (model.isSetInstanceType()) {
        org.ovirt.engine.core.common.businessentities.InstanceType instanceType = loadInstanceType(model);
        fromTemplate.setInstanceTypeId(instanceType.getId());
        fromInstanceType = VmMapper.map(instanceType, fromTemplate, cluster.getCompatibilityVersion());
        fromInstanceType.setInstanceTypeId(instanceType.getId());
    }
    // override with client-provided data
    VM vm = new VM(getMapper(VmPool.class, VmStatic.class).map(model, fromInstanceType != null ? fromInstanceType : fromTemplate), new VmDynamic(), new VmStatistics());
    return vm;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 24 with VmDynamic

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

the class VmMapperTest method getInverse.

@Override
protected org.ovirt.engine.core.common.businessentities.VM getInverse(VmStatic to) {
    VmStatistics statistics = new VmStatistics();
    statistics.setCpuUser(10.0);
    statistics.setCpuSys(20.0);
    VmDynamic dynamic = new VmDynamic();
    dynamic.setStatus(VMStatus.Up);
    dynamic.setBootSequence(to.getDefaultBootSequence());
    dynamic.getGraphicsInfos().put(GraphicsType.SPICE, new GraphicsInfo());
    org.ovirt.engine.core.common.businessentities.VM ret = new org.ovirt.engine.core.common.businessentities.VM(to, dynamic, statistics);
    ret.setUsageMemPercent(50);
    return ret;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

Example 25 with VmDynamic

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

the class VmMapperTest method testGuestOs2.

@Test
public void testGuestOs2() {
    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.setGuestOsType(OsType.Windows);
    vmDynamic.setGuestOsCodename("");
    vmDynamic.setGuestOsDistribution("");
    vmDynamic.setGuestOsVersion("6.2.4800");
    vmDynamic.setGuestOsArch(ArchitectureType.x86_64);
    vmDynamic.setGuestOsKernelVersion("");
    vm.setDynamicData(vmDynamic);
    Vm map = VmMapper.map(vm, (Vm) null);
    assertNotNull(map.getGuestOperatingSystem());
    assertEquals("Windows", map.getGuestOperatingSystem().getFamily());
    assertEquals("", map.getGuestOperatingSystem().getCodename());
    assertEquals("", map.getGuestOperatingSystem().getDistribution());
    assertEquals("6.2.4800", map.getGuestOperatingSystem().getVersion().getFullVersion());
    assertNotNull(map.getGuestOperatingSystem().getVersion().getMajor());
    assertEquals(6, (long) map.getGuestOperatingSystem().getVersion().getMajor());
    assertNotNull(map.getGuestOperatingSystem().getVersion().getMinor());
    assertEquals(2, (long) map.getGuestOperatingSystem().getVersion().getMinor());
    assertNotNull(map.getGuestOperatingSystem().getVersion().getBuild());
    assertEquals(4800, (long) map.getGuestOperatingSystem().getVersion().getBuild());
    assertNull(map.getGuestOperatingSystem().getVersion().getRevision());
    assertEquals("x86_64", map.getGuestOperatingSystem().getArchitecture());
    assertNull(map.getGuestOperatingSystem().getKernel());
}
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