Search in sources :

Example 76 with AuditLogableImpl

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);
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 77 with AuditLogableImpl

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);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 78 with AuditLogableImpl

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);
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 79 with AuditLogableImpl

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;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 80 with AuditLogableImpl

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);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Aggregations

AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)88 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)85 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)8 AuditLogType (org.ovirt.engine.core.common.AuditLogType)6 Guid (org.ovirt.engine.core.compat.Guid)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 AnsibleCommandBuilder (org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder)3 AnsibleReturnValue (org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)2 Event (org.ovirt.engine.core.common.eventqueue.Event)2