Juan Hernandez has uploaded a new change for review.

Change subject: core: Fix notifier parameters
......................................................................

core: Fix notifier parameters

The default parameters of the notifier service are not adjusted
when the engine is configured. This patch changes the notifier so
that it will get the parameters directly from the engine
configuration file /etc/sysconfig/ovirt-engine.

Change-Id: Ic4adb0c079b5d008e83dcf5449582916d8bd9ef3
Signed-off-by: Juan Hernandez <[email protected]>
---
M 
backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf
M 
backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
M backend/manager/tools/engine-notifier/engine-notifier-service/pom.xml
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/EngineMonitorService.java
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/connection-test-notifier.conf
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/error-notifier.conf
D 
backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/login-config.xml
M 
backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/notifier.conf
D 
backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/postgres-ds.xml
10 files changed, 26 insertions(+), 224 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/7187/1

diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf
 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf
index 4155dda..075cf83 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.conf
@@ -56,11 +56,7 @@
 # Time (in seconds) to wait between retries. Default is 30 seconds.
 #ENGINE_TIMEOUT_IN_SECONDS=30
 
-# The address of the engine server, in format of address:port. Default is 
localhost:80
-#ENGINE_ADDRESS=localhost:80
-
-# If running Jboss in secure mode, should be set to true. Default is false. If 
set to true, ENGINE_ADDRESS should
-# be filled with the actual engine server name and port (do not use 
localhost), e.g. engineserver:443
+# If running Jboss in secure mode, should be set to true. Default is false.
 #IS_HTTPS_PROTOCOL=true
 
 # Specifies the protocol used by Jboss Configuration Connector when SSL is 
enabled. Default is 'TLS'.
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
index b2c1126..30590d9 100755
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-resources/src/main/resources/notifier.sh
@@ -160,13 +160,6 @@
     fi
 fi
 
-# ENGINE_ADDRESS if defined can not be empty
-if [ "${ENGINE_ADDRESS+x}" ]; then
-    if [ -z "$ENGINE_ADDRESS" ]; then
-        die_no_propset \$ENGINE_ADDRESS
-    fi
-fi
-
 # IS_HTTPS_PROTOCOL if defined can not be empty
 if [ "${IS_HTTPS_PROTOCOL+x}" ]; then
     if [ -z "$IS_HTTPS_PROTOCOL" ]; then
@@ -207,6 +200,7 @@
     ovirt-engine/engineencryptutils
     ovirt-engine/engine-notifier-service
     ovirt-engine/engine-tools-common
+    ovirt-engine/utils
     postgresql-jdbc
     slf4j/api
     glassfish-jaxb/jaxb-impl
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/pom.xml 
b/backend/manager/tools/engine-notifier/engine-notifier-service/pom.xml
index 4ff065a..0eb8bc7 100644
--- a/backend/manager/tools/engine-notifier/engine-notifier-service/pom.xml
+++ b/backend/manager/tools/engine-notifier/engine-notifier-service/pom.xml
@@ -26,6 +26,12 @@
 
     <dependency>
       <groupId>${engine.groupId}</groupId>
+      <artifactId>utils</artifactId>
+      <version>${engine.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>${engine.groupId}</groupId>
       <artifactId>engine-tools-common</artifactId>
       <version>${engine.version}</version>
     </dependency>
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/EngineMonitorService.java
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/EngineMonitorService.java
index e5409c8..3c6893b 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/EngineMonitorService.java
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/EngineMonitorService.java
@@ -40,6 +40,7 @@
 import org.ovirt.engine.core.notifier.utils.NotificationConfigurator;
 import org.ovirt.engine.core.notifier.utils.NotificationProperties;
 import org.ovirt.engine.core.tools.common.db.StandaloneDataSource;
+import org.ovirt.engine.core.utils.LocalConfig;
 
 /**
  * Class uses to monitor the oVirt Engineanager service by sampling its health 
servlet. Upon response other than code 200,
@@ -53,8 +54,7 @@
     private static final Log log = 
LogFactory.getLog(EngineMonitorService.class);
     private static final String ENGINE_NOT_RESPONDING_ERROR = "Engine server 
is not responding.";
     private static final String ENGINE_RESPONDING_MESSAGE = "Engine server is 
up and running.";
-    private static final String DEFAULT_SERVER_ADDRESS = "localhost:80";
-    private static final String HEALTH_SERVLET_URL = 
"%s://%s/OvirtEngineWeb/HealthStatus";
+    private static final String HEALTH_SERVLET_PATH = 
"/OvirtEngineWeb/HealthStatus";
     private static final String CERTIFICATION_TYPE = "JKS";
     private static final String DEFAULT_SSL_PROTOCOL = "TLS";
     private static final long DEFAULT_SERVER_MONITOR_TIMEOUT_IN_SECONDS = 30;
@@ -62,7 +62,7 @@
     private DataSource ds;
     private Map<String, String> prop = null;
     private long serverMonitorTimeout;
-    private String serverUrl;
+    private URL serverUrl;
     private boolean isServerUp = true;
     private boolean repeatNonResponsiveNotification;
     private int serverMonitorRetries;
@@ -249,21 +249,18 @@
     }
 
     private void initServerUrl() throws NotificationServiceException {
-        String serverAddressProp = 
prop.get(NotificationProperties.ENGINE_ADDRESS);
-        String protocol = isHttpsProtocol ? "https" : "http";
-        serverUrl =
-                String.format(HEALTH_SERVLET_URL,
-                        protocol,
-                        StringUtils.isEmpty(serverAddressProp) ? 
DEFAULT_SERVER_ADDRESS : serverAddressProp);
+        LocalConfig config = LocalConfig.getInstance();
         try {
-            new URL(serverUrl);
-        } catch (MalformedURLException e) {
-            throw new NotificationServiceException(String.format("Invalid 
engine server address format: [%s]. " +
-                    "Please verify the format of [%s]. Should be ip:port or 
hostname:port whereas [%s])",
-                    serverUrl,
-                    NotificationProperties.ENGINE_ADDRESS,
-                    serverAddressProp),
-                    e);
+            if (isHttpsProtocol) {
+                serverUrl = config.getExternalHttpsUrl(HEALTH_SERVLET_PATH);
+            }
+            else {
+                config.getExternalHttpUrl(HEALTH_SERVLET_PATH);
+            }
+            log.info("Engine health servlet URL is \"" + serverUrl + "\".");
+        }
+        catch (MalformedURLException exception) {
+            throw new NotificationServiceException("Can't get engine health 
servlet URL.", exception);
         }
     }
 
@@ -305,7 +302,7 @@
         while (retries > 0) {
             retries--;
             try {
-                isResponsive = checkServerStatus(serverUrl, errors);
+                isResponsive = checkServerStatus(errors);
                 if (!isResponsive) {
                     if (retries > 0) {
                         Thread.sleep(serverMonitorTimeout);
@@ -385,22 +382,17 @@
      *            collection which aggregates any error
      * @return true is engine server is responsive (response with code 200 - 
HTTP_OK), else false
      */
-    private boolean checkServerStatus(String serverUrl, Set<String> errors) {
+    private boolean checkServerStatus(Set<String> errors) {
         boolean isResponsive = true;
         HttpURLConnection engineConn = null;
-        URL engine;
 
         try {
-            engine = new URL(serverUrl);
-
+            engineConn = (HttpsURLConnection) serverUrl.openConnection();
             if (isHttpsProtocol) {
-                engineConn = (HttpsURLConnection) engine.openConnection();
                 ((HttpsURLConnection) 
engineConn).setSSLSocketFactory(sslFactory);
                 if (sslIgnoreHostVerification) {
                     ((HttpsURLConnection) 
engineConn).setHostnameVerifier(IgnoredHostnameVerifier);
                 }
-            } else {
-                engineConn = (HttpURLConnection) engine.openConnection();
             }
         } catch (IOException e) {
             errors.add(e.getMessage());
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
index 1a2babc..6301206 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java
@@ -17,16 +17,6 @@
  */
 public class NotificationProperties {
     /**
-     * Database parameters
-     */
-    public static final String AS_DATA_SOURCE = "AS_DATA_SOURCE";
-    public static final String AS_LOGIN_CONFIG = "AS_LOGIN_CONFIG";
-    public static final String DB_CONNECTION_URL = "DB_CONNECTION_URL";
-    public static final String DB_USER_NAME = "DB_USER_NAME";
-    public static final String DB_PASSWORD = "DB_PASSWORD";
-    public static final String DB_JDBC_DRIVER_CLASS = "DB_JDBC_DRIVER_CLASS";
-
-    /**
      * Email parameters
      */
     public static final String MAIL_SERVER = "MAIL_SERVER";
@@ -45,7 +35,6 @@
     public static final String INTERVAL_IN_SECONDS = "INTERVAL_IN_SECONDS";
     public static final String ENGINE_INTERVAL_IN_SECONDS = 
"ENGINE_INTERVAL_IN_SECONDS";
     public static final String ENGINE_TIMEOUT_IN_SECONDS = 
"ENGINE_TIMEOUT_IN_SECONDS";
-    public static final String ENGINE_ADDRESS = "ENGINE_ADDRESS"; // ip:port 
or hostname:port
     public static final String IS_HTTPS_PROTOCOL = "IS_HTTPS_PROTOCOL";
     public static final String SSL_PROTOCOL = "SSL_PROTOCOL";
     public static final String REPEAT_NON_RESPONSIVE_NOTIFICATION = 
"REPEAT_NON_RESPONSIVE_NOTIFICATION";
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/connection-test-notifier.conf
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/connection-test-notifier.conf
index 894374c..eb440c4 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/connection-test-notifier.conf
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/connection-test-notifier.conf
@@ -3,15 +3,6 @@
 #
 # Sample configuration:
 
-# Data source files location
-#AS_DATA_SOURCE=
-#AS_LOGIN_CONFIG=
-
-DB_CONNECTION_URL=jdbc:postgresql://engine-db-test:5432/engine
-DB_USER_NAME=postgres
-DB_PASSWORD=
-DB_JDBC_DRIVER_CLASS=org.postgresql.Driver
-
 # Notification settings
 INTERVAL_IN_SECONDS=60
 MAIL_SERVER=smtp.redhat.com
@@ -26,4 +17,4 @@
 #DAYS_TO_KEEP_HISTORY=30
 
 # oVirt lib location
-engineLib=/usr/local/jboss-eap-5.1/jboss-as/server/default/deploy/engine.ear/lib
\ No newline at end of file
+engineLib=/usr/local/jboss-eap-5.1/jboss-as/server/default/deploy/engine.ear/lib
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/error-notifier.conf
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/error-notifier.conf
index 1dce2e0..5ebe562 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/error-notifier.conf
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/error-notifier.conf
@@ -3,15 +3,6 @@
 #
 # Sample configuration:
 
-# Data source files location
-AS_DATA_SOURCE=src/test/resources/conf/postgres-ds.xml
-AS_LOGIN_CONFIG=src/test/resources/conf/login-config.xml
-
-#DB_CONNECTION_URL=jdbc:sqlserver://engine-test-db\SQLEXPRESS;databaseName=engine
-#DB_USER_NAME=sa
-#DB_PASSWORD=ENGINEadmin2009!
-#DB_JDBC_DRIVER_CLASS=com.microsoft.sqlserver.jdbc.SQLServerDriver
-
 # Notification settings
 INTERVAL_IN_SECONDS=-1
 MAIL_SERVER=smtp.redhat.com
@@ -25,8 +16,6 @@
 # Engine server monitor settings
 ENGINE_INTERVAL_IN_SECONDS=300
 ENGINE_TIMEOUT_IN_SECONDS=30
-ENGINE_ADDRESS=localhost:8080
-
 
 # Days to keep history in the event_notification_history table
 DAYS_TO_KEEP_HISTORY=30
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/login-config.xml
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/login-config.xml
deleted file mode 100755
index 205a9f2..0000000
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/login-config.xml
+++ /dev/null
@@ -1,142 +0,0 @@
-<?xml version="1.0"?>
-<!-- The XML based JAAS login configuration read by the
-org.jboss.security.auth.login.XMLLoginConfig mbean. Add
-an application-policy element for each security domain.
-
-The outline of the application-policy is:
-<application-policy name="security-domain-name">
-  <authentication>
-    <login-module code="login.module1.class.name" flag="control_flag">
-      <module-option name = "option1-name">option1-value</module-option>
-      <module-option name = "option2-name">option2-value</module-option>
-      ...
-    </login-module>
-
-    <login-module code="login.module2.class.name" flag="control_flag">
-      ...
-    </login-module>
-    ...
-  </authentication>
-</application-policy>
-
-$Id: login-config.xml 87078 2009-04-09 14:23:47Z [email protected] $
-$Revision: 87078 $
--->
-<policy>
-       <!-- Used by clients within the application server VM such as
-  mbeans and servlets that access EJBs.
-  -->
-       <application-policy name="client-login">
-               <authentication>
-                       <login-module 
code="org.jboss.security.ClientLoginModule" flag="required">
-                               <!-- Any existing security context will be 
restored on logout -->
-                               <module-option 
name="restore-login-identity">true</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!-- Security domains for testing new jca framework -->
-       <application-policy name="HsqlDbRealm">
-               <authentication>
-                       <login-module 
code="org.jboss.resource.security.ConfiguredIdentityLoginModule" 
flag="required">
-                               <module-option 
name="principal">sa</module-option>
-                               <module-option 
name="userName">sa</module-option>
-                               <module-option name="password"></module-option>
-                               <module-option 
name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <application-policy name="JmsXARealm">
-               <authentication>
-                       <login-module 
code="org.jboss.resource.security.ConfiguredIdentityLoginModule" 
flag="required">
-                               <module-option 
name="principal">guest</module-option>
-                               <module-option 
name="userName">guest</module-option>
-                               <module-option 
name="password">guest</module-option>
-                               <module-option 
name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!-- A template configuration for the jmx-console web application. This
-    defaults to the UsersRolesLoginModule the same as other and should be
-    changed to a stronger authentication mechanism as required.
-  -->
-       <application-policy name="jmx-console">
-               <authentication>
-                       <login-module 
code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
-                               <module-option 
name="usersProperties">props/jmx-console-users.properties</module-option>
-                               <module-option 
name="rolesProperties">props/jmx-console-roles.properties</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!-- A template configuration for the web-console web application. This
-    defaults to the UsersRolesLoginModule the same as other and should be
-    changed to a stronger authentication mechanism as required.
-  -->
-       <application-policy name="web-console">
-               <authentication>
-                       <login-module 
code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
-                               <module-option 
name="usersProperties">web-console-users.properties</module-option>
-                               <module-option 
name="rolesProperties">web-console-roles.properties</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!--
-    A template configuration for the JBossWS security domain.
-    This defaults to the UsersRolesLoginModule the same as other and should be
-    changed to a stronger authentication mechanism as required.
-  -->
-       <application-policy name="JBossWS">
-               <authentication>
-                       <login-module 
code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
-                               <module-option 
name="usersProperties">props/jbossws-users.properties</module-option>
-                               <module-option 
name="rolesProperties">props/jbossws-roles.properties</module-option>
-                               <module-option 
name="unauthenticatedIdentity">anonymous</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!-- The default login configuration used by any security domain that
-  does not have a application-policy entry with a matching name
-  -->
-       <!-- A simple server login module, which can be used when the number
-    of users is relatively small. It uses two properties files:
-    users.properties, which holds users (key) and their password (value).
-    roles.properties, which holds users (key) and a comma-separated list of
-    their roles (value).
-    The unauthenticatedIdentity property defines the name of the principal
-    that will be used when a null username and password are presented as is
-    the case for an unuathenticated web client or MDB. If you want to
-    allow such users to be authenticated add the property, e.g.,
-    unauthenticatedIdentity="nobody"
-    -->
-       <!--
-  <application-policy name="other">
-    <authentication>
-      <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
-        flag="required"/>
-    </authentication>
-  </application-policy>
--->
-       <application-policy name="EngineKerberosAuth">
-               <authentication>
-                       <login-module 
code="com.sun.security.auth.module.Krb5LoginModule" flag="required">
-                               <!--
-              <module-option name="debug">true</module-option>
-              <module-option 
name="principal">HTTP/principal@REALM</module-option>
-             <module-option name="storeKey">true</module-option>
-              <module-option name="useKeyTab">true</module-option>
-              <module-option name="doNotPrompt">true</module-option>
-              <module-option 
name="keyTab">/path/to/keytabfile.keytab</module-option>
--->
-                       </login-module>
-               </authentication>
-       </application-policy>
-       <!-- oVirt Engine SecureIdentityLoginModule -->
-       <application-policy name="EncryptDBPassword">
-               <authentication>
-                       <login-module 
code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
-                               <module-option 
name="username">sa</module-option>
-                               <module-option 
name="password">2a10b7b619d2aec1</module-option>
-                               <module-option 
name="managedConnectionFactoryName">jboss.jca:name=ENGINEDataSource,service=LocalTxCM</module-option>
-                       </login-module>
-               </authentication>
-       </application-policy>
-</policy>
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/notifier.conf
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/notifier.conf
index cf73ebb..f5a1765 100644
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/notifier.conf
+++ 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/notifier.conf
@@ -11,7 +11,6 @@
 # Engine server monitor settings
 ENGINE_INTERVAL_IN_SECONDS=300
 ENGINE_TIMEOUT_IN_SECONDS=30
-ENGINE_ADDRESS=localhost:8080
 
 # Days to keep history in the event_notification_history table
 DAYS_TO_KEEP_HISTORY=30
diff --git 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/postgres-ds.xml
 
b/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/postgres-ds.xml
deleted file mode 100644
index 3af7d85..0000000
--- 
a/backend/manager/tools/engine-notifier/engine-notifier-service/src/test/resources/conf/postgres-ds.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<datasources>
-       <local-tx-datasource>
-         <jndi-name>ENGINEDataSource</jndi-name>
-         
<connection-url>jdbc:postgresql://engine-db-test:5432/engine</connection-url>
-         <driver-class>org.postgresql.Driver</driver-class>
-         <user-name>postgres</user-name>
-         <password></password>
-                <check-valid-connection-sql>select 
1</check-valid-connection-sql>
-    </local-tx-datasource>
-</datasources>


--
To view, visit http://gerrit.ovirt.org/7187
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic4adb0c079b5d008e83dcf5449582916d8bd9ef3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to