Search in sources :

Example 16 with AuditLogableImpl

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

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

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

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

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

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