Juan Hernandez has uploaded a new change for review.

Change subject: packaging: Use engine.conf for local configuration
......................................................................

packaging: Use engine.conf for local configuration

This change moves the content of the /etc/sysconfig/ovirt-engine file to
the /etc/ovirt-engine/engine.conf file. The reason for this is that this
file is not only used by the service, but also by other tools, and in
other Linux distributions the sysconfig directory is not common.

Change-Id: I9b48f1fd78ebd891e93949f19fafefcffd377254
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M Makefile
M backend/manager/conf/engine.conf
M backend/manager/conf/engine.conf.defaults
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacadeLocator.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
M 
backend/manager/tools/engine-tools-common/src/main/java/org/ovirt/engine/core/tools/common/db/StandaloneDataSource.java
M packaging/fedora/engine-service.py
D packaging/fedora/engine-service.sysconfig
M packaging/fedora/setup/basedefs.py
M packaging/fedora/setup/common_utils.py
M packaging/fedora/spec/ovirt-engine.spec.in
11 files changed, 38 insertions(+), 79 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/7591/1

diff --git a/Makefile b/Makefile
index 678cb9c..647656e 100644
--- a/Makefile
+++ b/Makefile
@@ -206,7 +206,6 @@
        @install -dm 755 $(DESTDIR)$(PYTHON_DIR)/sos/plugins
        @install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-config
        @install -dm 755 $(DESTDIR)$(PKG_SYSCONF_DIR)/engine-manage-domains
-       @install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/sysconfig
        @install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/cron.daily
        @install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/security/limits.d
        @install -dm 755 $(DESTDIR)$(SYSCONF_DIR)/rc.d/init.d
@@ -376,7 +375,6 @@
        install -m 644 packaging/fedora/engine-service.xml.in 
$(DESTDIR)$(DATA_DIR)/service
        install -m 644 packaging/fedora/engine-service-logging.properties 
$(DESTDIR)$(DATA_DIR)/service
        install -m 755 packaging/fedora/engine-service.py 
$(DESTDIR)$(DATA_DIR)/service
-       install -m 644 packaging/fedora/engine-service.sysconfig 
$(DESTDIR)$(SYSCONF_DIR)/sysconfig/ovirt-engine
        install -m 644 packaging/fedora/engine-service.limits 
$(DESTDIR)$(SYSCONF_DIR)/security/limits.d/10-$(ENGINE_NAME).conf
        install -m 644 packaging/fedora/engine-service.systemd 
$(DESTDIR)/usr/lib/systemd/system/ovirt-engine.service
 
diff --git a/backend/manager/conf/engine.conf b/backend/manager/conf/engine.conf
index b6c11e7..d5034f0 100644
--- a/backend/manager/conf/engine.conf
+++ b/backend/manager/conf/engine.conf
@@ -1,6 +1,8 @@
-
-#Timeout value in miliseconds for stop checking if DB connectivity is available
-#OnStartConnectionTimeout=300000
-
-#Interval value in miliseconds for sleep between two subsequent db 
connectivity checks
-#ConnectionCheckInterval=1000
+#
+# For descriptions of the parameters and their default values look
+# at the /usr/share/ovirt-engine/service/ovirt-engine.defaults
+# file.
+#
+# Please note that the engine installation tool engine-setup will
+# append the modified parameters to the end of this file.
+#
diff --git a/backend/manager/conf/engine.conf.defaults 
b/backend/manager/conf/engine.conf.defaults
index 6e75dca..ecc976e 100644
--- a/backend/manager/conf/engine.conf.defaults
+++ b/backend/manager/conf/engine.conf.defaults
@@ -3,7 +3,7 @@
 #
 # Please don't edit this file as it won't be preserverd when updating the
 # package that contains it. If you need to do updates use
-# /etc/sysconfig/ovirt-engine instead.
+# /etc/ovirt-engine/engine.conf instead.
 #
 
 #
@@ -139,3 +139,15 @@
 ENGINE_DB_SSL=false
 ENGINE_DB_USER=engine
 ENGINE_DB_PASSWORD=
+
+#
+# Timeout value in milliseconds for stop checking if database
+# connectivity is available (5 minutes at the moment):
+#
+ENGINE_DB_CONNECTION_TIMEOUT=300000
+
+#
+# Interval value in milliseconds for sleep between two subsequent
+# database connectivity checks:
+#
+ENGINE_DB_CHECK_INTERNVAL=1000
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacadeLocator.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacadeLocator.java
index 92ce864..07cec01 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacadeLocator.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacadeLocator.java
@@ -1,16 +1,12 @@
 package org.ovirt.engine.core.dal.dbbroker;
 
-import java.io.FileInputStream;
-import java.io.InputStream;
 import java.util.Properties;
 
 import javax.sql.DataSource;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.commons.lang.math.NumberUtils;
 import org.ovirt.engine.core.utils.log.Log;
 import org.ovirt.engine.core.utils.log.LogFactory;
-import org.ovirt.engine.core.utils.FileUtil;
+import org.ovirt.engine.core.utils.LocalConfig;
 import org.ovirt.engine.core.utils.ResourceUtils;
 import org.ovirt.engine.core.utils.ejb.ContainerManagedResourceType;
 import org.ovirt.engine.core.utils.ejb.EjbUtils;
@@ -68,56 +64,17 @@
     }
 
     public static void loadDbFacadeConfig() throws Exception {
-        boolean configSucceeded = false;
-        final String ENGINE_CONF_FILE = "/etc/ovirt-engine/engine.conf";
-        final String ON_START_CONNECTION_TIMEOUT = "OnStartConnectionTimeout";
-        final String CONNECTION_CHECK_INTERVAL = "ConnectionCheckInterval";
-        final String DEFAULT_TIMEOUT_VALUE = "300000";
-        final String DEFAULT_INTERVAL_VALUE = "1000";
-        InputStream inputStream = null;
+        int connectionTimeout = 300000;
+        int checkInterval = 1000;
+        LocalConfig config = LocalConfig.getInstance();
         try {
-            String onStartConnectionTimeout = null;
-            String connectionCheckInterval = null;
-            Properties props = new Properties();
-            if (FileUtil.fileExists(ENGINE_CONF_FILE)) {
-                // File exists, load /etc/ovirt-engine/engine.conf and set 
values in DbFacade
-                inputStream = new FileInputStream(ENGINE_CONF_FILE);
-                props.load(inputStream);
-                onStartConnectionTimeout = 
props.getProperty(ON_START_CONNECTION_TIMEOUT);
-                connectionCheckInterval = 
props.getProperty(CONNECTION_CHECK_INTERVAL);
-                if (!validNumber(onStartConnectionTimeout)) {
-                    onStartConnectionTimeout = DEFAULT_TIMEOUT_VALUE;
-                }
-                if (!validNumber(connectionCheckInterval)) {
-                    connectionCheckInterval = DEFAULT_INTERVAL_VALUE;
-                }
-            } else {
-                // File does not exist - use defaults
-                log.warn(String.format("%1$s file is not found. Please check 
your engine installation. " +
-                        "Default values will be used"
-                        , ENGINE_CONF_FILE));
-                onStartConnectionTimeout = DEFAULT_TIMEOUT_VALUE;
-                connectionCheckInterval = DEFAULT_INTERVAL_VALUE;
-            }
-            
dbFacade.setOnStartConnectionTimeout(Integer.parseInt(onStartConnectionTimeout));
-            
dbFacade.setConnectionCheckInterval(Integer.parseInt(connectionCheckInterval));
-            configSucceeded = true;
-        } catch (Exception ex) {
-            log.error("Error in configuration of db facade " + 
ExceptionUtils.getMessage(ex));
-        } finally {
-            if (!configSucceeded) {
-                dbFacade.setOnStartConnectionTimeout(300000);
-                dbFacade.setConnectionCheckInterval(1000);
-            }
-            if (inputStream != null) {
-                inputStream.close();
-            }
+            connectionTimeout = 
config.getInteger("ENGINE_DB_CONNECTION_TIMEOUT");
+            checkInterval = config.getInteger("ENGINE_DB_CHECK_INTERVAL");
         }
-
+        catch (Exception exception) {
+            log.error("Can't load connection checking parameters of DB 
facade.", exception);
+        }
+        dbFacade.setOnStartConnectionTimeout(connectionTimeout);
+        dbFacade.setConnectionCheckInterval(checkInterval);
     }
-
-    private static boolean validNumber(String numberStr) {
-        return numberStr != null && NumberUtils.isNumber(numberStr);
-    }
-
 }
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
index 710a517..d864c51 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/LocalConfig.java
@@ -24,7 +24,7 @@
 
     // Default files for defaults and overriden values:
     private static final File DEFAULTS_FILE = new 
File("/usr/share/ovirt-engine/conf/engine.conf.defaults");
-    private static final File VARS_FILE = new 
File("/etc/sysconfig/ovirt-engine");
+    private static final File VARS_FILE = new 
File("/etc/ovirt-engine/engine.conf");
 
     // This is a singleton and this is the instance:
     private static final LocalConfig instance = new LocalConfig();
diff --git 
a/backend/manager/tools/engine-tools-common/src/main/java/org/ovirt/engine/core/tools/common/db/StandaloneDataSource.java
 
b/backend/manager/tools/engine-tools-common/src/main/java/org/ovirt/engine/core/tools/common/db/StandaloneDataSource.java
index f9edb71..ca7288c 100644
--- 
a/backend/manager/tools/engine-tools-common/src/main/java/org/ovirt/engine/core/tools/common/db/StandaloneDataSource.java
+++ 
b/backend/manager/tools/engine-tools-common/src/main/java/org/ovirt/engine/core/tools/common/db/StandaloneDataSource.java
@@ -44,7 +44,7 @@
         // Load the service configuration file:
         String configPath = System.getenv("ENGINE_VARS");
         if (configPath == null) {
-            configPath = "/etc/sysconfig/ovirt-engine";
+            configPath = "/etc/ovirt-engine/engine.conf";
         }
         File configFile = new File(configPath);
         if (!configFile.exists()) {
diff --git a/packaging/fedora/engine-service.py 
b/packaging/fedora/engine-service.py
index ef56b9b..402d2de 100644
--- a/packaging/fedora/engine-service.py
+++ b/packaging/fedora/engine-service.py
@@ -125,7 +125,7 @@
         raise Exception("The engine configuration defaults file \"%s\" doesn't 
exist." % engineDefaultsFile)
 
     # Locate the configuration file:
-    engineConfigFile = os.getenv("ENGINE_VARS", "/etc/sysconfig/ovirt-engine")
+    engineConfigFile = os.getenv("ENGINE_VARS", 
"/etc/ovirt-engine/engine.conf")
     if not os.path.exists(engineConfigFile):
         raise Exception("The engine configuration file \"%s\" doesn't exist." 
% engineConfigFile)
 
diff --git a/packaging/fedora/engine-service.sysconfig 
b/packaging/fedora/engine-service.sysconfig
deleted file mode 100644
index d5034f0..0000000
--- a/packaging/fedora/engine-service.sysconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# For descriptions of the parameters and their default values look
-# at the /usr/share/ovirt-engine/service/ovirt-engine.defaults
-# file.
-#
-# Please note that the engine installation tool engine-setup will
-# append the modified parameters to the end of this file.
-#
diff --git a/packaging/fedora/setup/basedefs.py 
b/packaging/fedora/setup/basedefs.py
index dcc341d..796ec1b 100644
--- a/packaging/fedora/setup/basedefs.py
+++ b/packaging/fedora/setup/basedefs.py
@@ -66,8 +66,7 @@
 FILE_CA_CRT_TEMPLATE="%s/cacert.template"%(DIR_OVIRT_PKI)
 FILE_CERT_TEMPLATE="%s/cert.template"%(DIR_OVIRT_PKI)
 FILE_ENGINE_CERT="%s/certs/engine.cer"%(DIR_OVIRT_PKI)
-FILE_JBOSSAS_CONF="/etc/%s/%s.conf" % (ENGINE_SERVICE_NAME, 
ENGINE_SERVICE_NAME)
-FILE_ENGINE_SYSCONFIG="/etc/sysconfig/ovirt-engine"
+FILE_ENGINE_CONF="/etc/ovirt-engine/engine.conf"
 FILE_DB_INSTALL_SCRIPT="engine-db-install.sh"
 FILE_DB_UPGRADE_SCRIPT="upgrade.sh"
 FILE_RHEVM_CONFIG_BIN=os.path.join(DIR_ENGINE_CONFIG, "engine-config")
diff --git a/packaging/fedora/setup/common_utils.py 
b/packaging/fedora/setup/common_utils.py
index 318c253..a6140c4 100755
--- a/packaging/fedora/setup/common_utils.py
+++ b/packaging/fedora/setup/common_utils.py
@@ -951,7 +951,7 @@
 def editEngineSysconfig(proxyEnabled, dbUrl, dbUser, fqdn, http, https):
     # Load the file:
     logging.debug("Loading text file handler")
-    handler = TextConfigFileHandler(basedefs.FILE_ENGINE_SYSCONFIG)
+    handler = TextConfigFileHandler(basedefs.FILE_ENGINE_CONF)
     handler.open()
 
     handler.editParam("ENGINE_DB_DRIVER", "org.postgresql.Driver")
@@ -1008,7 +1008,7 @@
     Push the encrypted password into the local configuration file.
     """
     logging.debug("Encrypting database password.")
-    handler = TextConfigFileHandler(basedefs.FILE_ENGINE_SYSCONFIG)
+    handler = TextConfigFileHandler(basedefs.FILE_ENGINE_CONF)
     handler.open()
     handler.editParam("ENGINE_DB_USER", getDbUser())
     handler.editParam("ENGINE_DB_PASSWORD", password)
diff --git a/packaging/fedora/spec/ovirt-engine.spec.in 
b/packaging/fedora/spec/ovirt-engine.spec.in
index 967559d..9cfc3d6 100644
--- a/packaging/fedora/spec/ovirt-engine.spec.in
+++ b/packaging/fedora/spec/ovirt-engine.spec.in
@@ -625,7 +625,6 @@
 %config(noreplace) %attr(-, %{engine_user}, %{engine_group}) 
%{engine_etc}/engine.conf
 
 # Files needed by the service:
-%config(noreplace) %{_sysconfdir}/sysconfig/%{engine_name}
 %config(noreplace) %{_sysconfdir}/security/limits.d/10-ovirt-engine.conf
 %{engine_data}/service
 %{_bindir}/engine-service


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b48f1fd78ebd891e93949f19fafefcffd377254
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to