Search in sources :

Example 36 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsEventListener method createVmEvent.

private AuditLogable createVmEvent(Guid vmId, AuditLogType logType) {
    AuditLogable event = new AuditLogableImpl();
    event.setVmName(vmStaticDao.get(vmId).getName());
    event.setVmId(vmId);
    auditLogDirector.log(event, logType);
    return event;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 37 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VmPoolMonitor method runVmFromPool.

/**
 * Run the given VM as stateless.
 */
private boolean runVmFromPool(VmStatic vmToRun, boolean runAsStateless, String poolName) {
    log.info("Running VM '{}' as {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful");
    RunVmParams runVmParams = new RunVmParams(vmToRun.getId());
    runVmParams.setEntityInfo(new EntityInfo(VdcObjectType.VM, vmToRun.getId()));
    runVmParams.setRunAsStateless(runAsStateless);
    ActionReturnValue actionReturnValueurnValue = Backend.getInstance().runInternalAction(ActionType.RunVm, runVmParams, ExecutionHandler.createInternalJobContext().withLock(vmPoolHandler.createLock(vmToRun.getId())));
    boolean prestartingVmSucceeded = actionReturnValueurnValue.getSucceeded();
    if (!prestartingVmSucceeded) {
        AuditLogable log = new AuditLogableImpl();
        log.addCustomValue("VmPoolName", poolName);
        Injector.get(AuditLogDirector.class).log(log, AuditLogType.VM_FAILED_TO_PRESTART_IN_POOL);
    }
    log.info("Running VM '{}' as {} {}", vmToRun.getName(), runAsStateless ? "stateless" : "stateful", prestartingVmSucceeded ? "succeeded" : "failed");
    return prestartingVmSucceeded;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Example 38 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class AutodefineExternalNetworkCommand method getWarningMessage.

private AuditLogable getWarningMessage(Cluster cluster) {
    AuditLogable event = new AuditLogableImpl();
    event.setClusterName(cluster.getName());
    event.addCustomValue("NetworkName", getNetwork().getName());
    return event;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 39 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class SchedulingManager method performHaResevationCheckImpl.

public void performHaResevationCheckImpl() {
    log.debug("HA Reservation check timer entered.");
    List<Cluster> clusters = clusterDao.getAll();
    if (clusters != null) {
        HaReservationHandling haReservationHandling = new HaReservationHandling(getPendingResourceManager(), slaValidator);
        for (Cluster cluster : clusters) {
            if (cluster.supportsHaReservation()) {
                List<VDS> returnedFailedHosts = new ArrayList<>();
                boolean clusterHaStatus = haReservationHandling.checkHaReservationStatusForCluster(cluster, returnedFailedHosts);
                if (!clusterHaStatus) {
                    // create Alert using returnedFailedHosts
                    AuditLogable logable = createEventForCluster(cluster);
                    String failedHostsStr = returnedFailedHosts.stream().map(VDS::getName).collect(Collectors.joining(", "));
                    logable.addCustomValue("Hosts", failedHostsStr);
                    auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION);
                    log.info("Cluster '{}' fail to pass HA reservation check.", cluster.getName());
                }
                boolean clusterHaStatusFromPreviousCycle = clusterId2isHaReservationSafe.getOrDefault(cluster.getId(), true);
                // Update the status map with the new status
                clusterId2isHaReservationSafe.put(cluster.getId(), clusterHaStatus);
                // Create Alert if the status was changed from false to true
                if (!clusterHaStatusFromPreviousCycle && clusterHaStatus) {
                    AuditLogable logable = createEventForCluster(cluster);
                    auditLogDirector.log(logable, AuditLogType.CLUSTER_ALERT_HA_RESERVATION_DOWN);
                }
            }
        }
    }
    log.debug("HA Reservation check timer finished.");
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 40 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class SchedulingManager method createEventForCluster.

private AuditLogable createEventForCluster(Cluster cluster) {
    AuditLogable logable = new AuditLogableImpl();
    logable.setClusterName(cluster.getName());
    logable.setClusterId(cluster.getId());
    return logable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Aggregations

AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)126 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)86 AuditLogType (org.ovirt.engine.core.common.AuditLogType)10 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)9 Guid (org.ovirt.engine.core.compat.Guid)8 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 HashSet (java.util.HashSet)2 Inject (javax.inject.Inject)2 Singleton (javax.inject.Singleton)2 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2