Search in sources :

Example 6 with VmStatistics

use of org.ovirt.engine.core.common.businessentities.VmStatistics 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 7 with VmStatistics

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

the class VmStatisticalQuery method getStatistics.

public List<Statistic> getStatistics(org.ovirt.engine.core.common.businessentities.VM entity) {
    VmStatistics s = entity.getStatisticsData();
    long mem = entity.getMemSizeMb() * Mb;
    long memUsedByCent = s.getUsageMemPercent() == null ? 0 : mem * s.getUsageMemPercent();
    long memFree = entity.getGuestMemoryFree() == null ? 0 : entity.getGuestMemoryFree() * Kb;
    long memBuffered = entity.getGuestMemoryBuffered() == null ? 0 : entity.getGuestMemoryBuffered() * Kb;
    long memCached = entity.getGuestMemoryCached() == null ? 0 : entity.getGuestMemoryCached() * Kb;
    long migrationProgress = entity.getMigrationProgressPercent() != null ? entity.getMigrationProgressPercent() : 0;
    Double zero = 0.0;
    Double cpuUser = s.getCpuUser() == null ? zero : s.getCpuUser();
    Double cpuSys = s.getCpuSys() == null ? zero : s.getCpuSys();
    return asList(setDatum(clone(MEM_CONFIG), mem), setDatum(clone(MEM_USED), memUsedByCent / 100), setDatum(clone(CPU_GUEST), cpuUser), setDatum(clone(CPU_OVERHEAD), cpuSys), setDatum(clone(CPU_TOTAL), cpuUser + cpuSys), setDatum(clone(MIGRATION_PROGRESS), migrationProgress), setDatum(clone(MEM_BUFFERED), memBuffered), setDatum(clone(MEM_CACHED), memCached), setDatum(clone(MEM_FREE), memFree));
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 8 with VmStatistics

use of org.ovirt.engine.core.common.businessentities.VmStatistics 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 9 with VmStatistics

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

the class VmStatisticsDaoTest method testUpdateAll.

@Test
public void testUpdateAll() throws Exception {
    VmStatistics existingVm = dao.get(FixturesTool.VM_RHEL5_POOL_57);
    VmStatistics existingVm2 = dao.get(FixturesTool.VM_RHEL5_POOL_51);
    existingVm.setCpuSys(50.0);
    existingVm2.setCpuUser(50.0);
    dao.updateAll(Arrays.asList(existingVm, existingVm2));
    assertEquals(existingVm, dao.get(existingVm.getId()));
    assertEquals(existingVm2, dao.get(existingVm2.getId()));
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Test(org.junit.Test)

Example 10 with VmStatistics

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

the class VmDaoTest method createHostedEngineVm.

private void createHostedEngineVm(Guid id) {
    VmStatic vmStatic = new VmStatic();
    vmStatic.setId(id);
    vmStatic.setClusterId(FixturesTool.CLUSTER_RHEL6_ISCSI);
    vmStatic.setName("HostedEngine");
    vmStatic.setOrigin(OriginType.HOSTED_ENGINE);
    vmStatic.setCpuProfileId(FixturesTool.CPU_PROFILE_1);
    getDbFacade().getVmStaticDao().save(vmStatic);
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setId(id);
    getDbFacade().getVmDynamicDao().save(vmDynamic);
    VmStatistics vmStatistics = new VmStatistics();
    vmStatistics.setId(id);
    getDbFacade().getVmStatisticsDao().save(vmStatistics);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Aggregations

VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)17 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)6 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)4 Test (org.junit.Test)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 Map (java.util.Map)2 Guid (org.ovirt.engine.core.compat.Guid)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 PostConstruct (javax.annotation.PostConstruct)1 Inject (javax.inject.Inject)1 UriInfo (javax.ws.rs.core.UriInfo)1 Vm (org.ovirt.engine.api.model.Vm)1 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 GraphicsInfo (org.ovirt.engine.core.common.businessentities.GraphicsInfo)1 OriginType (org.ovirt.engine.core.common.businessentities.OriginType)1 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1