Search in sources :

Example 6 with EngineLocalConfig

use of org.ovirt.engine.core.utils.EngineLocalConfig in project ovirt-engine by oVirt.

the class ContextSensitiveHelpMappingServlet method getManualDir.

/**
 * Get the configured manual directory from the servlet config.
 */
protected String getManualDir(ServletConfig config) {
    EngineLocalConfig engineLocalConfig = EngineLocalConfig.getInstance();
    String manualDir = ServletUtils.getAsAbsoluteContext(getServletContext().getContextPath(), engineLocalConfig.expandString(// $NON-NLS-1$ //$NON-NLS-2$
    config.getInitParameter(MANUAL_DIR_KEY).replaceAll("%\\{", "\\${")));
    return manualDir;
}
Also used : EngineLocalConfig(org.ovirt.engine.core.utils.EngineLocalConfig)

Example 7 with EngineLocalConfig

use of org.ovirt.engine.core.utils.EngineLocalConfig in project ovirt-engine by oVirt.

the class EngineMonitorService method reportServerStatus.

/**
 * Analyzes server status and reports upon its status by configuration as needed:<br>
 * If compares the current server status to the latest one. <br>
 * if status was changed, adds an events to audit_log to represent the concrete event, else, <br>
 * if is a repetition of previous status, checks the {@link #repeatNonResponsiveNotification} flag to<br>
 * determine whether a user configured getting repeatable notifications or not.
 * @param isResponsive
 *            current server status
 */
private void reportServerStatus(boolean isResponsive) {
    boolean statusChanged;
    boolean lastServerStatus = isServerUp;
    isServerUp = isResponsive;
    statusChanged = lastServerStatus ^ isResponsive;
    // reports for any server status change or in case of configure for repeatable notification
    if (statusChanged || repeatNonResponsiveNotification) {
        if (isResponsive) {
            // if server is up, report only if its status was changed from non responsive.
            if (statusChanged) {
                insertEventIntoAuditLogSafe(AuditLogType.VDC_START, AuditLogSeverity.NORMAL, ENGINE_RESPONDING_MESSAGE, "Failed auditing event down (for responsive server).");
            }
        } else {
            // reports an error for non responsive server
            EngineLocalConfig config = EngineLocalConfig.getInstance();
            if (config.getEngineUpMark().exists()) {
                // assumed crash, since engine up file is still there
                insertEventIntoAuditLogSafe(AuditLogType.VDC_STOP, AuditLogSeverity.ERROR, ENGINE_NOT_RESPONDING_ERROR, "Failed auditing event up (for crashed non responsive server).");
            } else {
                insertEventIntoAuditLogSafe(AuditLogType.VDC_STOP, AuditLogSeverity.WARNING, ENGINE_NOT_RESPONDING_ERROR, "Failed auditing event up (for stopped non responsive server).");
            }
        }
    }
}
Also used : EngineLocalConfig(org.ovirt.engine.core.utils.EngineLocalConfig)

Example 8 with EngineLocalConfig

use of org.ovirt.engine.core.utils.EngineLocalConfig in project ovirt-engine by oVirt.

the class AddGlusterWebhookInternalCommand method getWebhookUrl.

private String getWebhookUrl() {
    EngineLocalConfig config = EngineLocalConfig.getInstance();
    URL servletUrl;
    try {
        if (config.isHttpsEnabled()) {
            servletUrl = config.getExternalHttpsUrl(WEBHOOK_SERVLET_PATH);
        } else {
            servletUrl = config.getExternalHttpUrl(WEBHOOK_SERVLET_PATH);
        }
        return servletUrl.toExternalForm();
    } catch (MalformedURLException exception) {
        log.debug("Failed to get engine webhook url", exception);
        return null;
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) EngineLocalConfig(org.ovirt.engine.core.utils.EngineLocalConfig)

Example 9 with EngineLocalConfig

use of org.ovirt.engine.core.utils.EngineLocalConfig in project ovirt-engine by oVirt.

the class SsoOAuthServiceUtils method setClientIdSecretBasicAuthHeader.

private static void setClientIdSecretBasicAuthHeader(HttpUriRequest request) {
    EngineLocalConfig config = EngineLocalConfig.getInstance();
    byte[] encodedBytes = Base64.encodeBase64(String.format("%s:%s", config.getProperty("ENGINE_SSO_CLIENT_ID"), config.getProperty("ENGINE_SSO_CLIENT_SECRET")).getBytes());
    request.setHeader(FiltersHelper.Constants.HEADER_AUTHORIZATION, String.format("Basic %s", new String(encodedBytes)));
}
Also used : EngineLocalConfig(org.ovirt.engine.core.utils.EngineLocalConfig)

Aggregations

EngineLocalConfig (org.ovirt.engine.core.utils.EngineLocalConfig)9 URI (java.net.URI)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 PostConstruct (javax.annotation.PostConstruct)1 ServletException (javax.servlet.ServletException)1 HttpGet (org.apache.http.client.methods.HttpGet)1 HttpPost (org.apache.http.client.methods.HttpPost)1 Logger (org.slf4j.Logger)1