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;
}
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));
}
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;
}
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()));
}
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);
}
Aggregations