Search in sources :

Example 26 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable 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 27 with AuditLogable

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

the class HostUpgradeManager method checkForUpdates.

@Override
public HostUpgradeManagerResult checkForUpdates(final VDS host) {
    AnsibleReturnValue ansibleReturnValue = null;
    try {
        AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(host.getHostName()).checkMode(true).enableLogging(false).verboseLevel(AnsibleVerbosity.LEVEL0).stdoutCallback(AnsibleConstants.HOST_UPGRADE_CALLBACK_PLUGIN).playbook(AnsibleConstants.HOST_UPGRADE_PLAYBOOK);
        ansibleReturnValue = ansibleExecutor.runCommand(command);
        if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
            String error = String.format("Failed to run check-update of host '%1$s'.", host.getHostName());
            log.error(error);
            throw new RuntimeException(error);
        }
        List<String> availablePackages = JsonHelper.jsonToList(ansibleReturnValue.getStdout());
        boolean updatesAvailable = !availablePackages.isEmpty();
        HostUpgradeManagerResult hostUpgradeManagerResult = new HostUpgradeManagerResult();
        hostUpgradeManagerResult.setUpdatesAvailable(updatesAvailable);
        if (updatesAvailable) {
            hostUpgradeManagerResult.setAvailablePackages(availablePackages);
            log.info("There are available package updates ({}) for host '{}'", StringUtils.join(availablePackages, ", "), host.getHostName());
            AuditLogable auditLog = new AuditLogableImpl();
            auditLog.setVdsId(host.getId());
            auditLog.setVdsName(host.getName());
            if (availablePackages.isEmpty()) {
                auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE);
            } else {
                if (availablePackages.size() > MAX_NUM_OF_DISPLAYED_UPDATES) {
                    auditLog.addCustomValue("Packages", String.format("%1$s and %2$s others. To see all packages check engine.log.", StringUtils.join(availablePackages.subList(0, MAX_NUM_OF_DISPLAYED_UPDATES), ", "), availablePackages.size() - MAX_NUM_OF_DISPLAYED_UPDATES));
                } else {
                    auditLog.addCustomValue("Packages", StringUtils.join(availablePackages, ", "));
                }
                auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE_WITH_PACKAGES);
            }
        }
        return hostUpgradeManagerResult;
    } catch (final IOException e) {
        log.error("Failed to read host packages: {}", e.getMessage());
        if (ansibleReturnValue != null) {
            log.debug("Ansible packages output: {}", ansibleReturnValue.getStdout());
        }
        throw new RuntimeException(e.getMessage(), e);
    } catch (final Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : HostUpgradeManagerResult(org.ovirt.engine.core.common.HostUpgradeManagerResult) AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) IOException(java.io.IOException) IOException(java.io.IOException)

Example 28 with AuditLogable

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

the class OvirtNodeUpgradeManager method checkForUpdates.

@Override
public HostUpgradeManagerResult checkForUpdates(VDS host) {
    QueryReturnValue returnValue = backendInternal.runInternalQuery(QueryType.GetoVirtISOs, new IdQueryParameters(host.getId()));
    List<RpmVersion> isos = returnValue.getReturnValue();
    boolean updateAvailable = RpmVersionUtils.isUpdateAvailable(isos, host.getHostOs());
    HostUpgradeManagerResult hostUpgradeManagerResult = new HostUpgradeManagerResult();
    hostUpgradeManagerResult.setUpdatesAvailable(updateAvailable);
    if (updateAvailable) {
        AuditLogable auditLog = new AuditLogableImpl();
        auditLog.setVdsName(host.getName());
        auditLog.setVdsId(host.getId());
        auditLog.setClusterName(host.getClusterName());
        auditLog.setClusterId(host.getClusterId());
        auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE);
    }
    return hostUpgradeManagerResult;
}
Also used : HostUpgradeManagerResult(org.ovirt.engine.core.common.HostUpgradeManagerResult) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) RpmVersion(org.ovirt.engine.core.compat.RpmVersion)

Example 29 with AuditLogable

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

the class MetadataDiskDescriptionHandler method createDiskEvent.

private AuditLogable createDiskEvent(String diskAlias) {
    AuditLogable logable = new AuditLogableImpl();
    logable.addCustomValue("DiskAlias", diskAlias);
    return logable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 30 with AuditLogable

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

the class BlockStorageDomainHelper method checkDomainMetadataDevices.

public boolean checkDomainMetadataDevices(StorageDomain domain) {
    if (domain.getVgMetadataDevice() == null || domain.getFirstMetadataDevice() == null) {
        AuditLogable logable = new AuditLogableImpl();
        logable.setStorageDomainName(domain.getName());
        logable.setStorageDomainId(domain.getId());
        auditLogDirector.log(logable, AuditLogType.FAILED_DETERMINE_STORAGE_DOMAIN_METADATA_DEVICES);
        return false;
    }
    return true;
}
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