use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class VmHandler method warnMemorySizeLegal.
/**
* Checks the validity of the given memory size according to OS type.
*
* @param vm
* a vm|template.
* @param clusterVersion
* the vm's cluster version.
*/
public void warnMemorySizeLegal(VmBase vm, Version clusterVersion) {
if (!vmValidationUtils.isMemorySizeLegal(vm.getOsId(), vm.getMemSizeMb(), clusterVersion)) {
AuditLogable logable = new AuditLogableImpl();
logable.setVmId(vm.getId());
logable.setVmName(vm.getName());
logable.addCustomValue("VmMemInMb", String.valueOf(vm.getMemSizeMb()));
logable.addCustomValue("VmMinMemInMb", String.valueOf(vmValidationUtils.getMinMemorySizeInMb(vm.getOsId(), clusterVersion)));
logable.addCustomValue("VmMaxMemInMb", String.valueOf(vmValidationUtils.getMaxMemorySizeInMb(vm.getOsId(), clusterVersion)));
auditLogDirector.log(logable, AuditLogType.VM_MEMORY_NOT_IN_RECOMMENDED_RANGE);
}
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class VdsCommand method alert.
/**
* Alerts the specified log type.
*
* @param logType
* Type of the log.
*/
private void alert(AuditLogType logType) {
AuditLogable alert = new AuditLogableImpl();
alert.setVdsName(getVds().getName());
alert.setVdsId(getVds().getId());
auditLogDirector.log(alert, logType);
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class RemoveVdsCommand method runAnsibleRemovePlaybook.
@SuppressWarnings("unchecked")
private void runAnsibleRemovePlaybook() {
AuditLogable logable = new AuditLogableImpl();
logable.setVdsName(getVds().getName());
logable.setVdsId(getVds().getId());
logable.setCorrelationId(getCorrelationId());
try {
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).playbook(AnsibleConstants.HOST_REMOVE_PLAYBOOK);
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_HOST_REMOVE_STARTED);
AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
logable.addCustomValue("LogFile", command.logFile().getAbsolutePath());
if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_HOST_REMOVE_FAILED);
} else {
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_HOST_REMOVE_FINISHED);
}
} catch (Exception e) {
logable.addCustomValue("Message", e.getMessage());
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_HOST_REMOVE_EXECUTION_FAILED);
}
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class RemoveAuditLogByIdCommand method createAuditLogableImpl.
private AuditLogable createAuditLogableImpl(AuditLog event) {
AuditLogable logable = new AuditLogableImpl();
logable.setStorageDomainId(event.getStorageDomainId());
logable.setStoragePoolId(event.getStoragePoolId());
logable.setUserId(event.getUserId());
logable.setClusterId(event.getClusterId());
logable.setVdsId(event.getVdsId());
logable.setVmId(event.getVmId());
logable.setVmTemplateId(event.getVmTemplateId());
logable.setCustomId(event.getCustomId());
return logable;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class CommandBase method logRenamedEntity.
void logRenamedEntity() {
if (this instanceof RenamedEntityInfoProvider) {
RenamedEntityInfoProvider renameable = (RenamedEntityInfoProvider) this;
String oldEntityName = renameable.getEntityOldName();
String newEntityName = renameable.getEntityNewName();
if (!StringUtils.equals(oldEntityName, newEntityName)) {
// log entity rename details
AuditLogable logable = new AuditLogableImpl();
String entityType = renameable.getEntityType();
logable.addCustomValue("EntityType", entityType);
logable.addCustomValue("OldEntityName", oldEntityName);
logable.addCustomValue("NewEntityName", newEntityName);
if (getCurrentUser() != null) {
logable.addCustomValue("UserName", getCurrentUser().getLoginName());
}
renameable.setEntityId(logable);
auditLog(logable, getCurrentUser() != null ? AuditLogType.ENTITY_RENAMED : AuditLogType.ENTITY_RENAMED_INTERNALLY);
}
}
}
Aggregations