Search in sources :

Example 6 with AuditLogType

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

the class GlusterTasksSyncJob method logTaskStoppedFromCLI.

private void logTaskStoppedFromCLI(Step step, GlusterVolumeEntity vol) {
    AuditLogType logType;
    switch(step.getStepType()) {
        case REBALANCING_VOLUME:
            logType = AuditLogType.GLUSTER_VOLUME_REBALANCE_NOT_FOUND_FROM_CLI;
            break;
        case REMOVING_BRICKS:
            logType = AuditLogType.REMOVE_GLUSTER_VOLUME_BRICKS_NOT_FOUND_FROM_CLI;
            break;
        default:
            logType = AuditLogType.UNASSIGNED;
            break;
    }
    logUtil.logAuditMessage(vol.getClusterId(), vol.getClusterName(), vol, null, logType, null);
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 7 with AuditLogType

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

the class InstallVdsInternalCommand method getAuditLogTypeValue.

@Override
public AuditLogType getAuditLogTypeValue() {
    AuditLogType result = null;
    if (getSucceeded()) {
        result = AuditLogType.VDS_INSTALL;
    } else {
        // In case of failure - add to audit log the error as achieved from
        // the host
        addCustomValue("FailedInstallMessage", getErrorMessage(_failureMessage));
        result = AuditLogType.VDS_INSTALL_FAILED;
    }
    return result;
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType)

Example 8 with AuditLogType

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

the class InstallerMessages method post.

public void post(Severity severity, String text) {
    AuditLogType logType;
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsId(_vds.getId());
    logable.setVdsName(_vds.getName());
    logable.setCorrelationId(_correlationId);
    logable.addCustomValue("Message", text);
    switch(severity) {
        case INFO:
            logType = AuditLogType.VDS_INSTALL_IN_PROGRESS;
            log.info("Installation '{}': {}", _vds.getHostName(), text);
            break;
        default:
        case WARNING:
            logType = AuditLogType.VDS_INSTALL_IN_PROGRESS_WARNING;
            log.warn("Installation '{}': {}", _vds.getHostName(), text);
            break;
        case ERROR:
            logType = AuditLogType.VDS_INSTALL_IN_PROGRESS_ERROR;
            log.error("Installation '{}': {}", _vds.getHostName(), text);
            break;
    }
    Injector.get(AuditLogDirector.class).log(logable, logType);
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Example 9 with AuditLogType

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

the class QuotaManager method consume.

/**
 * Consume from quota according to the parameters.
 *
 * @param parameters
 *            - Quota consumption parameters
 * @return - true if the request was validated and set
 */
public boolean consume(QuotaConsumptionParametersWrapper parameters) throws InvalidQuotaParametersException {
    Pair<AuditLogType, AuditLogableBase> auditLogPair = new Pair<>();
    auditLogPair.setSecond(parameters.getAuditLogable());
    StoragePool storagePool = parameters.getAuditLogable().getStoragePool();
    if (storagePool == null) {
        throw new InvalidQuotaParametersException("Null storage pool passed to QuotaManager");
    }
    addStoragePoolToCacheWithLock(storagePool.getId());
    lock.readLock().lock();
    try {
        if (parameters.getStoragePool().getQuotaEnforcementType() != QuotaEnforcementTypeEnum.DISABLED) {
            synchronized (storagePoolQuotaMap.get(storagePool.getId())) {
                return validateAndCompleteParameters(parameters, auditLogPair) && internalConsumeAndReleaseHandler(parameters, auditLogPair);
            }
        }
    } finally {
        lock.readLock().unlock();
        getQuotaManagerAuditLogger().auditLog(auditLogPair.getFirst(), auditLogPair.getSecond());
    }
    return true;
}
Also used : AuditLogableBase(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase) AuditLogType(org.ovirt.engine.core.common.AuditLogType) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 10 with AuditLogType

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

the class VdsCommandsHelper method updateStepMessage.

private void updateStepMessage(CommandBase<?> cmd, Guid vdsForExecution) {
    // As an HSM job can run on any host, we want to display the host running the job when it is
    // chosen. To do so, we look for a corresponding command step with an "_ON_HOST" suffix that
    // is supposed to contain a "vds" placeholder.
    StepEnum stepEnum = null;
    try {
        stepEnum = StepEnum.valueOf(getStepWithHostname(cmd));
    } catch (IllegalArgumentException e) {
        // Ignore this exception and do nothing as no corresponding step_ON_HOST found.
        log.debug("No StepEnum found for " + getStepWithHostname(cmd));
        return;
    }
    Step step = cmd.getExecutionContext().getStep();
    Map<String, String> jobProperties = cmd.getJobMessageProperties();
    jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), vdsDao.get(vdsForExecution).getName());
    step.setDescription(ExecutionMessageDirector.resolveStepMessage(stepEnum, jobProperties));
    stepDao.update(step);
    // Add an audit log entry if a corresponding AuditLogType exists. Note that we expect an AuditLogType
    // with name equals to Step_Enum to exist. If an AuditLogType exists, the arguments in the audit
    // message must match these in the StepEnum message.
    AuditLogType logType = null;
    try {
        logType = AuditLogType.valueOf(getAuditLogType(cmd));
    } catch (IllegalArgumentException e) {
        // Ignore this exception and do nothing as no corresponding AuditLogType found.
        log.debug("No AuditLogType found for " + getAuditLogType(cmd));
        return;
    }
    jobProperties.entrySet().stream().forEach(entry -> cmd.addCustomValue(entry.getKey(), entry.getValue()));
    Injector.get(AuditLogDirector.class).log(cmd, logType);
}
Also used : AuditLogType(org.ovirt.engine.core.common.AuditLogType) StepEnum(org.ovirt.engine.core.common.job.StepEnum) Step(org.ovirt.engine.core.common.job.Step) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)

Aggregations

AuditLogType (org.ovirt.engine.core.common.AuditLogType)23 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)8 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)5 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)4 AuditLogableBase (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 StandardCharsets (java.nio.charset.StandardCharsets)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1