Search in sources :

Example 51 with VmDynamic

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

the class VmMapperTest method testMapSessions.

@Test
public void testMapSessions() {
    org.ovirt.engine.core.common.businessentities.VM vm = new org.ovirt.engine.core.common.businessentities.VM();
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setConsoleCurrentUserName("admin");
    vmDynamic.setClientIp("1.1.1.1");
    vmDynamic.setGuestCurrentUserName("Ori");
    vm.setDynamicData(vmDynamic);
    Sessions sessions = VmMapper.map(vm, new Sessions());
    assertNotNull(sessions);
    assertEquals(2, sessions.getSessions().size());
    Session consoleSession = sessions.getSessions().get(0).getUser().getUserName().equals("admin") ? sessions.getSessions().get(0) : sessions.getSessions().get(1);
    Session guestSession = sessions.getSessions().get(0).getUser().getUserName().equals("Ori") ? sessions.getSessions().get(0) : sessions.getSessions().get(1);
    assertEquals("admin", consoleSession.getUser().getUserName());
    assertEquals("1.1.1.1", consoleSession.getIp().getAddress());
    assertTrue(consoleSession.isConsoleUser());
    assertEquals("Ori", guestSession.getUser().getUserName());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Sessions(org.ovirt.engine.api.model.Sessions) Session(org.ovirt.engine.api.model.Session) Test(org.junit.Test)

Example 52 with VmDynamic

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

the class VmAnalyzer method processUnmanagedVm.

private void processUnmanagedVm() {
    VmDynamic vmDynamic = vdsmVm.getVmDynamic();
    if (vmDynamic.getStatus() == VMStatus.Down || (vmDynamic.getStatus() == VMStatus.Paused && vmDynamic.getPauseStatus() == VmPauseStatus.EIO)) {
        destroyVm();
        return;
    }
    unmanagedVm = true;
    vmDynamic.setRunOnVds(vdsManager.getVdsId());
    saveDynamic(vmDynamic);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 53 with VmDynamic

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

the class VmAnalyzerFactory method getVmAnalyzer.

protected VmAnalyzer getVmAnalyzer(Pair<VmDynamic, VdsmVm> monitoredVm) {
    // the VM that was reported by vdsm
    VdsmVm vdsmVm = monitoredVm.getSecond();
    // VM from the database running on the monitored host, might be null
    VmDynamic dbVmOnMonitoredHost = monitoredVm.getFirst();
    VmDynamic dbVm = dbVmOnMonitoredHost != null ? dbVmOnMonitoredHost : vmDynamicDao.get(vdsmVm.getVmDynamic().getId());
    return new VmAnalyzer(dbVm, vdsmVm, updateStatistics, vdsManager, auditLogDirector, resourceManager, vdsDynamicDao, vmNetworkInterfaceDao);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 54 with VmDynamic

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

the class VmAnalyzer method proceedWatchdogEvents.

private void proceedWatchdogEvents() {
    VmDynamic vmDynamic = vdsmVm.getVmDynamic();
    if (isNewWatchdogEvent(vmDynamic, dbVm)) {
        AuditLogableBase auditLogable = Injector.injectMembers(new AuditLogableBase());
        auditLogable.setVmId(vmDynamic.getId());
        auditLogable.addCustomValue("wdaction", vmDynamic.getLastWatchdogAction());
        // for the interpretation of vdsm's response see http://docs.python.org/2/library/time.html
        auditLogable.addCustomValue("wdevent", new Date(vmDynamic.getLastWatchdogEvent() * 1000).toString());
        auditLog(auditLogable, AuditLogType.WATCHDOG_EVENT);
    }
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Date(java.util.Date)

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