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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations