Search in sources :

Example 66 with AuditLogable

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

the class VdsManager method handleSecureSetup.

public void handleSecureSetup() {
    // if ssl is on and no certificate file
    if (Config.<Boolean>getValue(ConfigValues.EncryptHostCommunication) && !EngineEncryptionUtils.haveKey()) {
        if (cachedVds.getStatus() != VDSStatus.Maintenance && cachedVds.getStatus() != VDSStatus.InstallFailed) {
            setStatus(VDSStatus.NonResponsive, cachedVds);
            updateDynamicData(cachedVds.getDynamicData());
        }
        log.error("Could not find VDC Certificate file.");
        AuditLogable logable = createAuditLogableForHost(cachedVds);
        auditLogDirector.log(logable, AuditLogType.CERTIFICATE_FILE_NOT_FOUND);
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)

Example 67 with AuditLogable

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

the class HostUpdatesChecker method checkForUpdates.

public HostUpgradeManagerResult checkForUpdates(VDS host) {
    AuditLogable auditLog = new AuditLogableImpl();
    auditLog.setVdsName(host.getName());
    auditLog.setVdsId(host.getId());
    if (!vdsDynamicDao.get(host.getId()).getStatus().isEligibleForOnDemandCheckUpdates()) {
        log.warn("Check for available updates is skipped for host '{}' due to unsupported host status '{}' ", host.getName(), host.getStatus());
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_SKIPPED_UNSUPPORTED_STATUS);
        return null;
    }
    HostUpgradeManagerResult updatesResult = null;
    try {
        updatesResult = availableUpdatesFinder.checkForUpdates(host);
        if (updatesResult.isUpdatesAvailable()) {
            List<String> availablePackages = updatesResult.getAvailablePackages();
            String message;
            if (availablePackages.size() > HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES) {
                message = String.format("%1$s and %2$s others. To see all packages check engine.log.", StringUtils.join(availablePackages.subList(0, HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES), ", "), availablePackages.size() - HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES);
            } else {
                message = String.format("found updates for packages %s", StringUtils.join(updatesResult.getAvailablePackages(), ", "));
            }
            auditLog.addCustomValue("Message", message);
        } else {
            auditLog.addCustomValue("Message", "no updates found.");
        }
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FINISHED);
    } catch (IllegalStateException e) {
        log.warn(e.getMessage());
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_PROCESS_IS_ALREADY_RUNNING);
    } catch (Exception e) {
        log.error("Failed to check if updates are available for host '{}' with error message '{}'", host.getName(), e.getMessage());
        log.debug("Exception", e);
        auditLog.addCustomValue("Message", StringUtils.defaultString(e.getMessage(), e.getCause() == null ? null : e.getCause().toString()));
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FAILED);
    }
    if (updatesResult != null && updatesResult.isUpdatesAvailable() != host.isUpdateAvailable()) {
        VdsManager hostManager = resourceManager.getVdsManager(host.getId());
        synchronized (hostManager) {
            hostManager.updateUpdateAvailable(updatesResult.isUpdatesAvailable());
        }
    }
    return updatesResult;
}
Also used : HostUpgradeManagerResult(org.ovirt.engine.core.common.HostUpgradeManagerResult) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) VdsManager(org.ovirt.engine.core.vdsbroker.VdsManager) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 68 with AuditLogable

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

the class InstallVdsInternalCommand method runAnsibleHostDeployPlaybook.

private void runAnsibleHostDeployPlaybook(Cluster hostCluster) throws IOException, InterruptedException {
    // TODO: Remove when we remove support for legacy oVirt node:
    if (getVds().getVdsType().equals(VDSType.oVirtVintageNode)) {
        log.warn("Skipping Ansible runner, because it isn't supported for legacy oVirt node.");
        return;
    }
    AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("host_deploy_cluster_version", hostCluster.getCompatibilityVersion()), new Pair<>("host_deploy_cluster_name", hostCluster.getName()), new Pair<>("host_deploy_gluster_enabled", hostCluster.supportsGlusterService()), new Pair<>("host_deploy_virt_enabled", hostCluster.supportsVirtService()), new Pair<>("host_deploy_vdsm_port", getVds().getPort()), new Pair<>("host_deploy_override_firewall", getParameters().getOverrideFirewall()), new Pair<>("host_deploy_firewall_type", hostCluster.getFirewallType().name()), new Pair<>("ansible_port", getVds().getSshPort()), new Pair<>("host_deploy_post_tasks", AnsibleConstants.HOST_DEPLOY_POST_TASKS_FILE_PATH), new Pair<>("host_deploy_ovn_tunneling_interface", NetworkUtils.getHostIp(getVds())), new Pair<>("host_deploy_ovn_central", getOvnCentral())).logFileDirectory(VdsDeployBase.HOST_DEPLOY_LOG_DIRECTORY).logFilePrefix("ovirt-host-deploy-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.HOST_DEPLOY_PLAYBOOK);
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsName(getVds().getName());
    logable.setVdsId(getVds().getId());
    logable.setCorrelationId(getCorrelationId());
    auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_STARTED);
    AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
    if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
        throw new VdsInstallException(VDSStatus.InstallFailed, String.format("Failed to execute Ansible host-deploy role. Please check logs for more details: %1$s", command.logFile()));
    }
    auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_FINISHED);
}
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) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 69 with AuditLogable

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

the class StorageHelperBase method addToAuditLogErrorMessage.

protected String addToAuditLogErrorMessage(String connection, String errorCode, List<StorageServerConnections> connections, LUNs lun) {
    AuditLogable logable = new AuditLogableImpl();
    String connectionField = getConnectionDescription(connections, connection) + (lun == null ? "" : " (LUN " + lun.getLUNId() + ")");
    logable.addCustomValue("Connection", connectionField);
    // Get translated error by error code ,if no translation found (should not happened) ,
    // will set the error code instead.
    String translatedError = getTranslatedStorageError(errorCode);
    logable.addCustomValue("ErrorMessage", translatedError);
    auditLogDirector.log(logable, AuditLogType.STORAGE_DOMAIN_ERROR);
    return connectionField;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 70 with AuditLogable

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

the class StorageHelperBase method addMessageToAuditLog.

public void addMessageToAuditLog(AuditLogType auditLogType, StorageDomain storageDomain, VDS vds) {
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsId(vds.getId());
    logable.setVdsName(vds.getName());
    if (storageDomain != null) {
        logable.setStorageDomainId(storageDomain.getId());
        logable.setStorageDomainName(storageDomain.getName());
    }
    auditLogDirector.log(logable, auditLogType);
}
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