Search in sources :

Example 11 with VmStatistics

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

the class SetVmStatusVDSCommand method executeVDSCommand.

@Override
protected void executeVDSCommand() {
    VmDynamic vmDynamic = vmDynamicDao.get(getParameters().getVmId());
    resourceManager.removeAsyncRunningVm(getParameters().getVmId());
    resourceManager.internalSetVmStatus(vmDynamic, getParameters().getStatus(), getParameters().getExitStatus());
    resourceManager.getVmManager(getParameters().getVmId()).update(new VmStatistics(getParameters().getVmId()));
    // TODO: update network statistics
    resourceManager.getVmManager(getParameters().getVmId()).update(vmDynamic);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 12 with VmStatistics

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

the class VmManager method estimateOverhead.

private int estimateOverhead(VmStatic vmStatic) {
    // Prepare VM object using the available bits and pieces
    VM compose = new VM(vmStatic, new VmDynamic(), new VmStatistics(), clusterArchitecture, clusterCompatibilityVersion);
    // Load device list, TODO ignores unmanaged devices for now
    Map<Guid, VmDevice> devices = vmDeviceDao.getVmDeviceByVmId(vmId).stream().filter(VmDevice::isManaged).collect(Collectors.toMap(d -> d.getId().getDeviceId(), Function.identity()));
    vmStatic.setManagedDeviceMap(devices);
    return vmOverheadCalculator.getTotalRequiredMemoryInMb(compose);
}
Also used : VmStatisticsDao(org.ovirt.engine.core.dao.VmStatisticsDao) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Guid(org.ovirt.engine.core.compat.Guid) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) VmNetworkStatistics(org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics) Function(java.util.function.Function) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) Inject(javax.inject.Inject) OriginType(org.ovirt.engine.core.common.businessentities.OriginType) VmNetworkStatisticsDao(org.ovirt.engine.core.dao.network.VmNetworkStatisticsDao) Map(java.util.Map) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Version(org.ovirt.engine.core.compat.Version) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) ReentrantLock(java.util.concurrent.locks.ReentrantLock) VmOverheadCalculator(org.ovirt.engine.core.common.scheduling.VmOverheadCalculator) Collectors(java.util.stream.Collectors) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdsmVm(org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm) PostConstruct(javax.annotation.PostConstruct) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid)

Example 13 with VmStatistics

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

the class VdsBrokerObjectsBuilder method buildVmsDataFromExternalProvider.

public static VM buildVmsDataFromExternalProvider(Map<String, Object> struct) {
    VmStatic vmStatic = buildVmStaticDataFromExternalProvider(struct);
    if (vmStatic == null) {
        return null;
    }
    VmDynamic vmDynamic = buildVMDynamicDataFromList(struct);
    VM vm = new VM(vmStatic, vmDynamic, new VmStatistics());
    for (DiskImage image : vm.getImages()) {
        vm.getDiskMap().put(Guid.newGuid(), image);
    }
    try {
        vm.setClusterArch(parseArchitecture(struct));
    } catch (IllegalArgumentException ex) {
        log.warn("Illegal architecture type: {}, replacing with x86_64", struct.get(VdsProperties.vm_arch));
        vm.setClusterArch(ArchitectureType.x86_64);
    } catch (NullPointerException ex) {
        log.warn("null architecture type, replacing with x86_64, {}", vm);
        vm.setClusterArch(ArchitectureType.x86_64);
    }
    return vm;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 14 with VmStatistics

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

the class VmStatisticsDaoTest method generateNewEntity.

@Override
protected VmStatistics generateNewEntity() {
    VmStatistics newVmStatistics = new VmStatistics();
    newVmStatistics.setId(FixturesTool.VM_RHEL5_POOL_50_ID);
    newVmStatistics.setCpuSys(22.0D);
    newVmStatistics.setCpuUser(35.0D);
    newVmStatistics.setUsageCpuPercent(44);
    newVmStatistics.setUsageMemPercent(67);
    newVmStatistics.setDisksUsage("disk_usage");
    newVmStatistics.setGuestMemoryBuffered(32L);
    newVmStatistics.setGuestMemoryCached(34L);
    return newVmStatistics;
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 15 with VmStatistics

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

the class VdsBrokerObjectsBuilderTest method testNullDisksUsages.

@Test
public void testNullDisksUsages() {
    VmStatistics vmStatistics = getVmStatistics();
    Map<String, Object> xml = setDisksUsage(null);
    VdsBrokerObjectsBuilder.updateVMStatisticsData(vmStatistics, xml);
    assertNull(vmStatistics.getDisksUsage());
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Test(org.junit.Test)

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