Search in sources :

Example 1 with VmStatistics

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

the class VmMigrationProgressMonitoring method onNext.

@Override
public void onNext(Map<String, Object> map) {
    try {
        map.remove(VdsProperties.notify_time);
        map.entrySet().forEach(vmInfo -> {
            Guid vmId = new Guid(vmInfo.getKey());
            Map<?, ?> properties = (Map<?, ?>) vmInfo.getValue();
            int progress = Integer.valueOf(properties.get(VdsProperties.vm_migration_progress).toString());
            VmStatistics vmStatistics = resourceManager.getVmManager(vmId).getStatistics();
            vmStatistics.setMigrationProgressPercent(progress);
            Integer actualDowntime = (Integer) properties.get(VdsProperties.MIGRATION_DOWNTIME);
            if (actualDowntime != null) {
                resourceManager.getEventListener().actualDowntimeReported(vmId, actualDowntime);
            }
        });
    } finally {
        subscription.request(1);
    }
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Guid(org.ovirt.engine.core.compat.Guid) Map(java.util.Map)

Example 2 with VmStatistics

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

the class VdsBrokerObjectsBuilder method buildVMStatisticsData.

public static VmStatistics buildVMStatisticsData(Map<String, Object> struct) {
    VmStatistics vmStatistics = new VmStatistics();
    updateVMStatisticsData(vmStatistics, struct);
    return vmStatistics;
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 3 with VmStatistics

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

the class VmAnalyzerTest method initMocks.

public void initMocks(VmTestPairs vmData, boolean run) {
    stubDaos();
    when(vdsManager.getVdsId()).thenReturn(VmTestPairs.SRC_HOST_ID);
    when(vdsManager.getClusterId()).thenReturn(VmTestPairs.CLUSTER_ID);
    when(vdsManager.getCopyVds()).thenReturn(vdsManagerVds);
    when(vmManager.isColdReboot()).thenReturn(false);
    when(vmManager.isAutoStart()).thenReturn(vmData.dbVm() != null ? vmData.dbVm().isAutoStartup() : false);
    when(vmManager.getStatistics()).thenReturn(new VmStatistics());
    when(resourceManager.getVdsManager(any())).thenReturn(vdsManager);
    // -- default behaviors --
    // dst host is up
    mockDstHostStatus(VDSStatus.Up);
    // -- end of behaviors --
    vmAnalyzer = spy(new VmAnalyzer(vmData.dbVm() != null ? vmData.dbVm().getDynamicData() : null, vmData.vdsmVm(), false, vdsManager, auditLogDirector, resourceManager, vdsDynamicDao, null));
    doNothing().when(vmAnalyzer).resetVmInterfaceStatistics();
    doReturn(vmManager).when(vmAnalyzer).getVmManager();
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setSucceeded(true);
    doReturn(vdsReturnValue).when(vmAnalyzer).runVdsCommand(any(), any());
    if (run) {
        vmAnalyzer.analyze();
    }
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 4 with VmStatistics

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

the class VdsBrokerObjectsBuilderTest method getVmStatistics.

private static VmStatistics getVmStatistics() {
    VmStatistics vmStatistics = new VmStatistics();
    vmStatistics.setId(VM_ID);
    return vmStatistics;
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 5 with VmStatistics

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

the class BackendVmsResourceTest method testListIncludeStatistics.

@Test
public void testListIncludeStatistics() throws Exception {
    try {
        accepts.add("application/xml; detail=statistics");
        UriInfo uriInfo = setUpUriExpectations(null);
        org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM();
        VmStatistics vmStatistics = new VmStatistics();
        vmStatistics.setCpuSys(0D);
        vmStatistics.setCpuUser(0D);
        vmStatistics.setElapsedTime(0D);
        vmStatistics.setUsageCpuPercent(0);
        vmStatistics.setUsageMemPercent(0);
        vmStatistics.setUsageNetworkPercent(0);
        vm.setStatisticsData(vmStatistics);
        vm.setMigrationProgressPercent(50);
        for (int i = 0; i < GUIDS.length - 1; i++) {
            setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[i] }, vm);
        }
        setUpGetGraphicsMultipleExpectations(3);
        setUpQueryExpectations("");
        collection.setUriInfo(uriInfo);
        List<Vm> vms = getCollection();
        assertTrue(vms.get(0).isSetStatistics());
        verifyCollection(vms);
    } finally {
        accepts.clear();
    }
}
Also used : VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics) Vm(org.ovirt.engine.api.model.Vm) UriInfo(javax.ws.rs.core.UriInfo) 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