Juan Hernandez has uploaded a new change for review.

Change subject: packaging: Move defaults out of service script
......................................................................

packaging: Move defaults out of service script

We used to have the defaults values for local engine configuration
files hardcoded in the service start/stop script. This means that
other tools need to duplicate these values. This change moves the
default values to a separate plain file that can be easily
consumed by all kinds of programs.

The file will be stored in /usr/share/ovirt-engine because it is
*not* a configuration file.

Change-Id: I062bb033bf20db9a0d68b8286151345a3653cb03
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M Makefile
A backend/manager/conf/engine.conf.defaults
M packaging/fedora/engine-service.py
M packaging/fedora/engine-service.sysconfig
M packaging/fedora/engine-service.xml.in
5 files changed, 197 insertions(+), 137 deletions(-)


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

diff --git a/Makefile b/Makefile
index 572e5b2..9e2f770 100644
--- a/Makefile
+++ b/Makefile
@@ -346,6 +346,7 @@
        @echo "*** Copying additional files"
        install -m 644 backend/manager/conf/jaas.conf $(DESTDIR)$(DATA_DIR)/conf
        install -m 640 backend/manager/conf/engine.conf 
$(DESTDIR)$(PKG_SYSCONF_DIR)/
+       install -m 644 backend/manager/conf/engine.conf.defaults 
$(DESTDIR)$(DATA_DIR)/conf
        install -m 755 packaging/resources/ovirtlogrot.sh 
${DESTDIR}$(DATA_DIR)/scripts/
        install -m 755 packaging/resources/ovirt-cron 
${DESTDIR}$(SYSCONF_DIR)/cron.daily/
        install -m 644 packaging/resources/ovirt-tmpfilesd 
${DESTDIR}$(SYSCONF_DIR)/tmpfiles.d/$(ENGINE_NAME).conf
diff --git a/backend/manager/conf/engine.conf.defaults 
b/backend/manager/conf/engine.conf.defaults
new file mode 100644
index 0000000..298525e
--- /dev/null
+++ b/backend/manager/conf/engine.conf.defaults
@@ -0,0 +1,141 @@
+#
+# These are the default values for the local configuration.
+#
+# 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.
+#
+
+#
+# The location of the Java virtual machine used by the engine:
+#
+JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
+
+#
+# The location of the application server used by the engine:
+#
+JBOSS_HOME=/usr/share/jboss-as
+
+#
+# Important directories used by the engine:
+#
+ENGINE_ETC=/etc/ovirt-engine
+ENGINE_LOG=/var/log/ovirt-engine
+ENGINE_TMP=/var/tmp/ovirt-engine
+ENGINE_USR=/usr/share/ovirt-engine
+ENGINE_VAR=/var/lib/ovirt-engine
+ENGINE_LOCK=/var/lock/ovirt-engine
+ENGINE_CACHE=/var/cache/ovirt-engine
+
+#
+# Resource limits:
+#
+ENGINE_NOFILE=65535
+
+#
+# Intervals for stoping the engine:
+#
+ENGINE_STOP_TIME=10
+ENGINE_STOP_INTERVAL=1
+
+#
+# Location of the PID file used by the engine:
+#
+ENGINE_PID=/var/run/ovirt-engine.pid
+
+#
+# The names of the user and group that will execute the java
+# virtual machine of the engine:
+#
+ENGINE_USER=ovirt
+ENGINE_GROUP=ovirt
+
+#
+# These variables control the amount of memory used by the java
+# virtual machine where the engine runs:
+#
+ENGINE_HEAP_MIN=1g
+ENGINE_HEAP_MAX=1g
+ENGINE_PERM_MIN=256m
+ENGINE_PERM_MAX=256m
+
+#
+# Use this if you want to enable remote debugging of the engine java virtual
+# machine (useful mainly for developers):
+#
+#   ENGINE_DEBUG_ADDRESS=ovirt.example.com:8787
+#
+# The address and port should be reachable from your debugger, so using
+# localhost is not good unless you are running the engine and the debugger in
+# the same machine.
+#
+ENGINE_DEBUG_ADDRESS=
+
+#
+# Change following to true if you want to enable garbage collection debug
+# information (will be sent to the console.log file):
+#
+ENGINE_VERBOSE_GC=false
+
+#
+# Extra system properties to be added to the java virtual machine
+# of the engine. Properties can be specified using the typical
+# java syntax:
+#
+#   -Dmy.param=my.value
+#   -Dmy.flag
+#
+# If the -D prefix is not used it will be automatically added, so
+# the following is also valid:
+#
+#   my.param=my.value
+#   my.flag
+#
+# If several properties need to be specified they should all go in
+# the same line and separated by spaces:
+#
+#   -Dmy.param=my.value -Dmy.flag -Dyour.param=your.value
+#
+ENGINE_PROPERTIES=
+
+#
+# Additional applications to be deployed in the instance of the
+# application server started by the engine. This is a list space
+# separated of files or directories that should exist under
+# /usr/share/ovirt-engine:
+#
+ENGINE_APPS=engine.ear
+
+#
+# Flags to enable or disable the web server (the proxy) and the
+# connectors of the application server:
+#
+ENGINE_PROXY_ENABLED=true
+ENGINE_HTTP_ENABLED=false
+ENGINE_HTTPS_ENABLED=true
+ENGINE_AJP_ENABLED=true
+
+#
+# Engine host fully qualified domain name:
+#
+ENGINE_FQDN=localhost.localdomain
+
+#
+# Ports used by the web server (the proxy) and by the connectors
+# of the application server:
+#
+ENGINE_PROXY_HTTP_PORT=80
+ENGINE_PROXY_HTTPS_PORT=443
+ENGINE_HTTP_PORT=8080
+ENGINE_HTTPS_PORT=8443
+ENGINE_AJP_PORT=8009
+
+#
+# Database connection details (note that the password is
+# encrypted):
+#
+ENGINE_DB_DRIVER=org.postgresql.Driver
+ENGINE_DB_URL=jdbc:postgresql://localhost/engine
+ENGINE_DB_SSL=false
+ENGINE_DB_USER=engine
+ENGINE_DB_PASSWORD=
diff --git a/packaging/fedora/engine-service.py 
b/packaging/fedora/engine-service.py
index 21eea31..52e71bf 100644
--- a/packaging/fedora/engine-service.py
+++ b/packaging/fedora/engine-service.py
@@ -92,19 +92,18 @@
     def __init__(self, name):
         configobj.ConfigObj.__init__(self, name)
 
-    def getString(self, name, default=None):
-        return self.get(name, default)
-
-    def getBoolean(self, name, default=False):
+    def getString(self, name):
         text = self.get(name)
         if text is None:
-            return default
+            raise Exception("The parameter \"%s\" doesn't have a value." % 
name)
+        return text
+
+    def getBoolean(self, name):
+        text = self.getString(name)
         return text.lower() in ["t", "true", "y", "yes", "1"]
 
-    def getInteger(self, name, default=0):
-        text = self.get(name)
-        if text is None:
-            return default
+    def getInteger(self, name):
+        text = self.getString(name)
         try:
             return int(text)
         except:
@@ -112,17 +111,24 @@
 
 
 def loadConfig():
-    # Load the configuration file:
+    # Load the defaults:
+    engineDefaultsFile = "/usr/share/ovirt-engine/conf/engine.conf.defaults"
+    if not os.path.exists(engineDefaultsFile):
+        raise Exception("The engine configuration defaults file \"%s\" doesn't 
exist." % engineDefaultsFile)
+    global engineConfig
+    engineConfig = Config(engineDefaultsFile)
+
+    # Load the configuration file and merge it with the defaults:
     engineConfigFile = os.getenv("ENGINE_VARS", "/etc/sysconfig/ovirt-engine")
     if not os.path.exists(engineConfigFile):
         raise Exception("The engine configuration file \"%s\" doesn't exist." 
% engineConfigFile)
-    global engineConfig
-    engineConfig = Config(engineConfigFile)
+    engineConfigOverrides = Config(engineConfigFile)
+    engineConfig.merge(engineConfigOverrides)
 
     # Get the id of the engine user:
     global engineUser
     global engineUid
-    engineUser = engineConfig.getString("ENGINE_USER", "ovirt")
+    engineUser = engineConfig.getString("ENGINE_USER")
     try:
         engineUid = pwd.getpwnam(engineUser).pw_uid
     except:
@@ -131,7 +137,7 @@
     # Get id of the engine group:
     global engineGroup
     global engineGid
-    engineGroup = engineConfig.getString("ENGINE_GROUP", "ovirt")
+    engineGroup = engineConfig.getString("ENGINE_GROUP")
     try:
         engineGid = grp.getgrnam(engineGroup).gr_gid
     except:
@@ -139,7 +145,7 @@
 
     # Java home directory:
     global javaHomeDir
-    javaHomeDir = engineConfig.getString("JAVA_HOME", 
"/usr/lib/jvm/jre-1.7.0-openjdk.x86_64")
+    javaHomeDir = engineConfig.getString("JAVA_HOME")
 
     # Java launcher:
     global javaLauncher
@@ -147,7 +153,7 @@
 
     # JBoss directories:
     global jbossHomeDir
-    jbossHomeDir = engineConfig.getString("JBOSS_HOME", "/usr/share/jboss-as")
+    jbossHomeDir = engineConfig.getString("JBOSS_HOME")
 
     # JBoss files:
     global jbossModulesJar
@@ -164,13 +170,13 @@
     global engineServiceDir
     global engineContentDir
     global engineDeploymentsDir
-    engineEtcDir = engineConfig.getString("ENGINE_ETC", "/etc/ovirt-engine")
-    engineLogDir = engineConfig.getString("ENGINE_LOG", 
"/var/log/ovirt-engine")
-    engineTmpDir = engineConfig.getString("ENGINE_TMP", 
"/var/tmp/ovirt-engine")
-    engineUsrDir = engineConfig.getString("ENGINE_USR", 
"/usr/share/ovirt-engine")
-    engineVarDir = engineConfig.getString("ENGINE_VAR", 
"/var/lib/ovirt-engine")
-    engineLockDir = engineConfig.getString("ENGINE_LOCK", 
"/var/lock/ovirt-engine")
-    engineCacheDir = engineConfig.getString("ENGINE_CACHE", 
"/var/cache/ovirt-engine")
+    engineEtcDir = engineConfig.getString("ENGINE_ETC")
+    engineLogDir = engineConfig.getString("ENGINE_LOG")
+    engineTmpDir = engineConfig.getString("ENGINE_TMP")
+    engineUsrDir = engineConfig.getString("ENGINE_USR")
+    engineVarDir = engineConfig.getString("ENGINE_VAR")
+    engineLockDir = engineConfig.getString("ENGINE_LOCK")
+    engineCacheDir = engineConfig.getString("ENGINE_CACHE")
     engineServiceDir = os.path.join(engineUsrDir, "service")
     engineContentDir = os.path.join(engineVarDir, "content")
     engineDeploymentsDir = os.path.join(engineVarDir, "deployments")
@@ -184,7 +190,7 @@
     global engineBootLogFile
     global engineConsoleLogFile
     global engineServerLogFile
-    enginePidFile = engineConfig.getString("ENGINE_PID", 
"/var/run/ovirt-engine.pid")
+    enginePidFile = engineConfig.getString("ENGINE_PID")
     engineLoggingFile = os.path.join(engineServiceDir, 
"engine-service-logging.properties")
     engineLogFile = os.path.join(engineLogDir, "engine.log")
     jbossConfigTemplateFile = os.path.join(engineServiceDir, 
"engine-service.xml.in")
@@ -313,7 +319,7 @@
             return
 
     # The list of applications to be deployed:
-    engineApps = engineConfig.getString("ENGINE_APPS", "engine.ear").split()
+    engineApps = engineConfig.getString("ENGINE_APPS").split()
 
     for engineApp in engineApps:
         # Do nothing if the application is not available:
@@ -369,10 +375,10 @@
 
     # Get heap configuration parameters from the environment or use defaults if
     # they are not provided:
-    engineHeapMin = engineConfig.getString("ENGINE_HEAP_MIN", "1g")
-    engineHeapMax = engineConfig.getString("ENGINE_HEAP_MAX", "1g")
-    enginePermMin = engineConfig.getString("ENGINE_PERM_MIN", "256m")
-    enginePermMax = engineConfig.getString("ENGINE_PERM_MAX", "256m")
+    engineHeapMin = engineConfig.getString("ENGINE_HEAP_MIN")
+    engineHeapMax = engineConfig.getString("ENGINE_HEAP_MAX")
+    enginePermMin = engineConfig.getString("ENGINE_PERM_MIN")
+    enginePermMax = engineConfig.getString("ENGINE_PERM_MAX")
 
     # Module path should include first the engine modules so that they can 
override
     # those provided by the application server if needed:
@@ -416,7 +422,7 @@
         
engineArgs.append("-Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=n" 
% engineDebugAddress)
 
     # Enable verbose garbage collection if required:
-    engineVerboseGC = engineConfig.getBoolean("ENGINE_VERBOSE_GC", False)
+    engineVerboseGC = engineConfig.getBoolean("ENGINE_VERBOSE_GC")
     if engineVerboseGC:
         engineArgs.extend([
             "-verbose:gc",
@@ -456,7 +462,7 @@
 
     # Change the resource limits while we are root as we won't be
     # able to change them once we assume the engine identity:
-    engineNofile = engineConfig.getInteger("ENGINE_NOFILE", 65535)
+    engineNofile = engineConfig.getInteger("ENGINE_NOFILE")
     resource.setrlimit(resource.RLIMIT_NOFILE, (engineNofile, engineNofile))
 
     # This is the child process, first thing we do is assume the engine
@@ -506,8 +512,8 @@
         return
 
     # Get the time to wait for the engine to stop from the configuration:
-    stopTime = engineConfig.getInteger("ENGINE_STOP_TIME", 10)
-    stopInterval = engineConfig.getInteger("ENGINE_STOP_INTERVAL", 1)
+    stopTime = engineConfig.getInteger("ENGINE_STOP_TIME")
+    stopInterval = engineConfig.getInteger("ENGINE_STOP_INTERVAL")
 
     # Kill the process softly and wait for it to dissapear or for the timeout
     # to expire:
diff --git a/packaging/fedora/engine-service.sysconfig 
b/packaging/fedora/engine-service.sysconfig
index 0ca695c..d5034f0 100644
--- a/packaging/fedora/engine-service.sysconfig
+++ b/packaging/fedora/engine-service.sysconfig
@@ -1,96 +1,8 @@
 #
+# 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. If you
-# decide to modify anything manually remember to update those
-# lines accordingly.
-#
-
-#
-# The names of the user and group that will execute the java
-# virtual machine of the engine:
-#
-#ENGINE_USER=ovirt
-#ENGINE_GROUP=ovirt
-
-#
-# These variables control the amount of memory used by the java
-# virtual machine where the engine runs:
-#
-#ENGINE_MIN_HEAP=1g
-#ENGINE_MAX_HEAP=1g
-
-#
-# Uncomment this if you want to enable remote debugging of the
-# engine java virtual machine (useful mainly for developers):
-#
-#ENGINE_DEBUG_ADDRESS=localhost:8787
-
-#
-# Uncomment the following if you want to enable garbage collection
-# debug information (will be sent to the console.log file):
-#
-#ENGINE_VERBOSE_GC=true
-
-#
-# Extra system properties to be added to the java virtual machine
-# of the engine. Properties can be specified using the typical
-# java syntax:
-#
-#   -Dmy.param=my.value
-#   -Dmy.flag
-#
-# If the -D prefix is not used it will be automatically added, so
-# the following is also valid:
-#
-#   my.param=my.value
-#   my.flag
-#
-# If several properties need to be specified they should all go in
-# the same line and separated by spaces:
-#
-#   -Dmy.param=my.value -Dmy.flag -Dyour.param=your.value
-#
-#ENGINE_PROPERTIES=
-
-#
-# Additional applications to be deployed in the instance of the
-# application server started by the engine. This is a list space
-# separated of files or directories that should exist under
-# /usr/share/ovirt-engine:
-#
-#ENGINE_APPS="engine.ear whatever.war"
-
-
-#
-# Flags to enable or disable the web server (the proxy) and the
-# connectors of the application server:
-#
-#ENGINE_PROXY_ENABLED=true
-#ENGINE_HTTP_ENABLED=true
-#ENGINE_HTTPS_ENABLED=true
-#ENGINE_AJP_ENABLED=false
-
-#
-# Ports used by the web server (the proxy) and by the connectors
-# of the application server:
-#
-#ENGINE_PROXY_HTTP_PORT=80
-#ENGINE_PROXY_HTTPS_PORT=443
-#ENGINE_HTTP_PORT=8080
-#ENGINE_HTTPS_PORT=8443
-#ENGINE_AJP_PORT=8009
-
-#
-# Database connection details (note that the password is
-# encrypted):
-#
-#ENGINE_DB_DRIVER=org.postgresql.Driver
-#ENGINE_DB_URL=jdbc:postgresql://localhost/engine
-#ENGINE_DB_SSL=false
-#ENGINE_DB_USER=engine
-#ENGINE_DB_PASSWORD=-2361e09b066a8cd65e09a31f95885cc4
-
-#
-# Parameters modified by engine-setup will be appended after this
-# line:
+# append the modified parameters to the end of this file.
 #
diff --git a/packaging/fedora/engine-service.xml.in 
b/packaging/fedora/engine-service.xml.in
index 6d70348..8417a37 100644
--- a/packaging/fedora/engine-service.xml.in
+++ b/packaging/fedora/engine-service.xml.in
@@ -239,16 +239,16 @@
     <subsystem xmlns="urn:jboss:domain:threads:1.1"/>
 
     <subsystem xmlns="urn:jboss:domain:web:1.1" native="false" 
default-virtual-server="default-host">
-      #if $getBoolean('ENGINE_HTTP_ENABLED', True)
-        <connector name="http" protocol="HTTP/1.1" scheme="http" 
socket-binding="http" redirect-port="$getInteger('ENGINE_HTTPS_PORT', 8443)"/>
+      #if $getBoolean('ENGINE_HTTP_ENABLED')
+        <connector name="http" protocol="HTTP/1.1" scheme="http" 
socket-binding="http" redirect-port="$getInteger('ENGINE_HTTPS_PORT')"/>
       #end if
-      #if $getBoolean('ENGINE_HTTPS_ENABLED', True)
+      #if $getBoolean('ENGINE_HTTPS_ENABLED')
         <connector name="https" protocol="HTTP/1.1" scheme="https" 
socket-binding="https" secure="true">
           <ssl name="ssl" password="mypass" 
certificate-key-file="/etc/pki/ovirt-engine/.keystore" key-alias="engine" 
protocol="TLSv1" verify-client="false"/>
         </connector>
       #end if
-      #if $getBoolean('ENGINE_AJP_ENABLED', False)
-        <connector name="ajp" protocol="AJP/1.3" scheme="http" 
socket-binding="ajp" redirect-port="$getInteger('ENGINE_PROXY_HTTPS_PORT', 
443)"/>
+      #if $getBoolean('ENGINE_AJP_ENABLED')
+        <connector name="ajp" protocol="AJP/1.3" scheme="http" 
socket-binding="ajp" redirect-port="$getInteger('ENGINE_PROXY_HTTPS_PORT')"/>
       #end if
       <virtual-server name="default-host" enable-welcome-root="false">
         <alias name="localhost"/>
@@ -268,14 +268,14 @@
   </interfaces>
 
   <socket-binding-group name="standard-sockets" default-interface="loopback">
-    #if $getBoolean('ENGINE_HTTP_ENABLED', True)
-      <socket-binding name="http" port="$getInteger('ENGINE_HTTP_PORT', 8080)" 
interface="public"/>
+    #if $getBoolean('ENGINE_HTTP_ENABLED')
+      <socket-binding name="http" port="$getInteger('ENGINE_HTTP_PORT')" 
interface="public"/>
     #end if
-    #if $getBoolean('ENGINE_HTTPS_ENABLED', True)
-      <socket-binding name="https" port="$getInteger('ENGINE_HTTPS_PORT', 
8443)" interface="public"/>
+    #if $getBoolean('ENGINE_HTTPS_ENABLED')
+      <socket-binding name="https" port="$getInteger('ENGINE_HTTPS_PORT')" 
interface="public"/>
     #end if
-    #if $getBoolean('ENGINE_AJP_ENABLED', False)
-      <socket-binding name="ajp" port="$getInteger('ENGINE_AJP_PORT', 8009)"/>
+    #if $getBoolean('ENGINE_AJP_ENABLED')
+      <socket-binding name="ajp" port="$getInteger('ENGINE_AJP_PORT')"/>
     #end if
     <socket-binding name="remoting" port="4447"/>
     <socket-binding name="txn-recovery-environment" port="4712"/>


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I062bb033bf20db9a0d68b8286151345a3653cb03
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