Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: setup: Add ovirt-engine-reports service ......................................................................
packaging: setup: Add ovirt-engine-reports service Change-Id: I265f3126bb36e6ecd0c6e36c24b97e894237f5e0 Signed-off-by: Yedidyah Bar David <d...@redhat.com> --- M Makefile M ovirt-engine-reports.spec.in A packaging/services/ovirt-engine-reports/__init__.py A packaging/services/ovirt-engine-reports/config.py.in A packaging/services/ovirt-engine-reports/ovirt-engine-reports-logging.properties.in A packaging/services/ovirt-engine-reports/ovirt-engine-reports.conf.in A packaging/services/ovirt-engine-reports/ovirt-engine-reports.py A packaging/services/ovirt-engine-reports/ovirt-engine-reports.systemd.in A packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv.in A packaging/services/ovirt-engine-reports/ovirt-engine-reports.xml.in 10 files changed, 1,234 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/81/28681/1 diff --git a/Makefile b/Makefile index 08dece2..102db8e 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,8 @@ PKG_LOG_DIR=$(LOCALSTATE_DIR)/log/ovirt-engine-reports PKG_STATE_DIR=$(LOCALSTATE_DIR)/lib/ovirt-engine-reports ENGINE_STATE_DIR=$(LOCALSTATE_DIR)/lib/$(ENGINE_NAME) +PKG_TMP_DIR=$(LOCALSTATE_DIR)/tmp/ovirt-engine-reports +JBOSS_HOME=/usr/share/jboss-as PYTHON_DIR=$(PYTHON_SYS_DIR) DEV_PYTHON_DIR= PKG_USER=ovirt @@ -75,6 +77,8 @@ .in: sed \ + -e "s|@ENGINE_DEFAULTS@|$(DATA_DIR)/services/ovirt-engine/ovirt-engine.conf|g" \ + -e "s|@REPORTS_VARS@|$(PKG_SYSCONF_DIR)/ovirt-engine-reports.conf|g" \ -e "s|@PKG_USER@|$(PKG_USER)|g" \ -e "s|@PKG_GROUP@|$(PKG_GROUP)|g" \ -e "s|@DATAROOT_DIR@|$(DATAROOT_DIR)|g" \ @@ -83,6 +87,7 @@ -e "s|@PKG_JAVA_DIR@|$(PKG_JAVA_DIR)|g" \ -e "s|@PKG_LOG_DIR@|$(PKG_LOG_DIR)|g" \ -e "s|@PKG_STATE_DIR@|$(PKG_STATE_DIR)|g" \ + -e "s|@PKG_TMP_DIR@|$(PKG_TMP_DIR)|g" \ -e "s|@DEV_PYTHON_DIR@|$(DEV_PYTHON_DIR)|g" \ -e "s|@RPM_VERSION@|$(RPM_VERSION)|g" \ -e "s|@RPM_RELEASE@|$(RPM_RELEASE)|g" \ @@ -90,6 +95,7 @@ -e "s|@PACKAGE_VERSION@|$(PACKAGE_VERSION)|g" \ -e "s|@DISPLAY_VERSION@|$(DISPLAY_VERSION)|g" \ -e "s|@ENGINE_VAR@|$(ENGINE_STATE_DIR)|g" \ + -e "s|@JBOSS_HOME@|$(JBOSS_HOME)|g" \ -e "s|@PEP8@|$(PEP8)|g" \ -e "s|@PYFLAKES@|$(PYFLAKES)|g" \ $< > $@ @@ -103,6 +109,11 @@ packaging/setup/ovirt_engine_setup/reports/config.py \ packaging/sys-etc/logrotate.d/ovirt-engine-reports \ packaging/sys-etc/ovirt-engine/engine.conf.d/20-ovirt-engine-reports.conf \ + packaging/sys-etc/ovirt-engine/engine.conf.d/20-ovirt-engine-reports.conf \ + packaging/services/ovirt-engine-reports/config.py \ + packaging/services/ovirt-engine-reports/ovirt-engine-reports.conf \ + packaging/services/ovirt-engine-reports/ovirt-engine-reports.systemd \ + packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv \ $(NULL) all: \ @@ -113,6 +124,8 @@ generated-files: $(GENERATED) chmod a+x build/python-check.sh + chmod a+x packaging/services/ovirt-engine-reports/ovirt-engine-reports.py + chmod a+x packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv $(BUILD_FILE): $(ANT) $(BUILD_FLAGS) all @@ -190,7 +203,7 @@ $(NULL) $(MAKE) copy-recursive SOURCEDIR=packaging/sys-etc TARGETDIR="$(DESTDIR)$(SYSCONF_DIR)" EXCLUDE_GEN="$(GENERATED)" $(MAKE) copy-recursive SOURCEDIR=packaging/setup TARGETDIR="$(DESTDIR)$(PKG_DATA_DIR)/../ovirt-engine/setup" EXCLUDE_GEN="$(GENERATED)" - for d in conf etc jasper-customizations jasper-war-patches ovirt-reports; do \ + for d in conf etc jasper-customizations jasper-war-patches ovirt-reports services; do \ $(MAKE) copy-recursive SOURCEDIR="packaging/$${d}" TARGETDIR="$(DESTDIR)$(PKG_DATA_DIR)/$${d}" EXCLUDE_GEN="$(GENERATED)"; \ done diff --git a/ovirt-engine-reports.spec.in b/ovirt-engine-reports.spec.in index bb2d77e..1444e67 100644 --- a/ovirt-engine-reports.spec.in +++ b/ovirt-engine-reports.spec.in @@ -1,9 +1,13 @@ %if 0%{?fedora} %global java_devel java-devel +%global ovirt_install_systemd 1 +%global ovirt_install_systemv 0 %endif %if 0%{?rhel} %global java_devel java7-devel +%global ovirt_install_systemd 0 +%global ovirt_install_systemv 1 %endif %global product_name Reports package for oVirt Virtualization Management @@ -15,6 +19,26 @@ %global reports_java %{_javadir}/%{reports_name} %global engine_group ovirt %global engine_user ovirt +%global engine_gid 108 +%global engine_group ovirt +%global engine_uid 108 +%global engine_user ovirt + +# Macro to create a user: +# +# %1 user name +# %2 user id +# %3 primary group name +# %4 primary group id +# %5 description +# %6 home directory +# +%global _ovirt_create_user() \ +getent group %3 >/dev/null || groupadd -r -g %4 %3; \ +getent passwd %1 >/dev/null || useradd -r -u %2 -g %3 -c %5 -s /sbin/nologin -d %6 %1 + +%global ovirt_create_user_engine \ +%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%{ovirt_user_description}" %{engine_state} %global make_common_opts \\\ -j1 \\\ @@ -44,7 +68,7 @@ Group: Virtualization/Management URL: http://www.ovirt.org BuildArch: noarch -Source0: http://resources.ovirt.org/pub/src/@PACKAGE_NAME@/@PACKAGE_NAME@-@package_vers...@.tar.gz +Source0: http://resources.ovirt.org/pub/ovirt-master-snapshot/src/@PACKAGE_NAME@/@PACKAGE_NAME@-@package_vers...@.tar.gz BuildRequires: jasperreports-server%{reports_jasper_suffix} >= 5.5.0-7 BuildRequires: %{java_devel} @@ -52,6 +76,10 @@ BuildRequires: log4j BuildRequires: make BuildRequires: ant + +%if %{ovirt_install_systemd} +BuildRequires: systemd +%endif Requires: %{name}-setup >= %{version}-%{release} Requires: jasperreports-server%{reports_jasper_suffix} < 5.6.0 @@ -70,6 +98,12 @@ # bug#862355 Requires: liberation-mono-fonts + +%if %{ovirt_install_systemd} +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +%endif %description The %{product_description} package provides a suite of @@ -116,7 +150,50 @@ ln -s "%{reports_name}" "%{buildroot}%{_javadir}/%{name}" %endif +# +# Register services +# +%if %{ovirt_install_systemd} +install -dm 755 "%{buildroot}%{_unitdir}" +for service in ovirt-engine-reports; do + cp "%{buildroot}%{_datadir}/%{reports_name}/services/${service}/${service}.systemd" "%{buildroot}%{_unitdir}/${service}.service" +done +%endif + +%if %{ovirt_install_systemv} +install -dm 755 "%{buildroot}%{_initddir}" +for service in ovirt-engine-reports; do + cp "%{buildroot}%{_datadir}/%{reports_name}/services/${service}/${service}.sysv" "%{buildroot}%{_initddir}/${service}" +done +%endif + +%pre +%ovirt_create_user_engine + +%post +%if %{ovirt_install_systemd} +%systemd_post ovirt-engine-reports.service +%endif +%if %{ovirt_install_systemv} +chkconfig --add ovirt-engine-reports +%endif + +%preun +%if %{ovirt_install_systemd} +%systemd_preun ovirt-engine-reports.service +%endif + +%if %{ovirt_install_systemv} +if [ $1 -eq 0 ]; then + service ovirt-engine-reports stop > /dev/null 2>&1 || true + chkconfig --del ovirt-engine-reports +fi +%endif + %postun +%if %{ovirt_install_systemd} +%systemd_postun ovirt-engine-reports.service +%endif if [ "$1" -eq 0 ]; then rm -rf /var/lib/ovirt-engine-reports/%{reports_name}.war rm -f /var/lib/ovirt-engine/reports.xml @@ -136,6 +213,13 @@ %{_javadir}/%{name} %endif +%if %{ovirt_install_systemd} +%{_unitdir}/ovirt-engine-reports.service +%endif +%if %{ovirt_install_systemv} +%{_initddir}/ovirt-engine-reports +%endif + %files setup %{_datadir}/ovirt-engine/setup/ovirt_engine_setup/reports/ %{_datadir}/ovirt-engine/setup/plugins/*/ovirt-engine-reports/ diff --git a/packaging/services/ovirt-engine-reports/__init__.py b/packaging/services/ovirt-engine-reports/__init__.py new file mode 100644 index 0000000..73adc60 --- /dev/null +++ b/packaging/services/ovirt-engine-reports/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2014 Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +__all__ = [] + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/services/ovirt-engine-reports/config.py.in b/packaging/services/ovirt-engine-reports/config.py.in new file mode 100644 index 0000000..2fccafc --- /dev/null +++ b/packaging/services/ovirt-engine-reports/config.py.in @@ -0,0 +1,24 @@ +# Copyright 2014 Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +DEV_PYTHON_DIR = '@DEV_PYTHON_DIR@' +REPORTS_VARS = '@REPORTS_VARS@' + +import sys +if DEV_PYTHON_DIR: + sys.path.insert(0, DEV_PYTHON_DIR) + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports-logging.properties.in b/packaging/services/ovirt-engine-reports/ovirt-engine-reports-logging.properties.in new file mode 100644 index 0000000..dd7247b --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports-logging.properties.in @@ -0,0 +1,13 @@ +logger.level=INFO +logger.handlers=FILE + +handler.FILE=org.jboss.logmanager.handlers.FileHandler +handler.FILE.level=DEBUG +handler.FILE.properties=autoFlush,fileName +handler.FILE.autoFlush=true +handler.FILE.fileName=$getstring('PKG_LOG_DIR')/boot.log +handler.FILE.formatter=PATTERN + +formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter +formatter.PATTERN.properties=pattern +formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports.conf.in b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.conf.in new file mode 100644 index 0000000..1f6bc2f --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.conf.in @@ -0,0 +1,201 @@ +# +# 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/ovirt-engine-reports/ovirt-engine-reports.conf instead. +# + +# +# Comma separated list of keys +# not to be logged. +# +SENSITIVE_KEYS="" + +# +# The location of the application server: +# +JBOSS_HOME="@JBOSS_HOME@" + +# +# Important directories: +# +REPORTS_ETC="@REPORTS_ETC@" +SYSCONF_DIR="@SYSCONF_DIR@" +PKG_LOG_DIR="@PKG_LOG_DIR@" +PKG_TMP_DIR="@PKG_TMP_DIR@" +PKG_DATA_DIR="@PKG_DATA_DIR@" +PKG_STATE_DIR="@PKG_STATE_DIR@" + +# +# A file created on init and removed on orderly shutdown +# +SERVICE_UP_MARK="${PKG_STATE_DIR}/service.up" + +# +# Intervals for stoping the service: +# +STOP_TIME=10 +STOP_INTERVAL=1 + +# +# The names of the user and group that will execute the java +# virtual machine of the service: +# +PKG_USER=@PKG_USER@ +PKG_GROUP=@PKG_GROUP@ + +# +# These variables control the amount of memory used by the java +# virtual machine where the service runs: +# +HEAP_MIN=1g +HEAP_MAX=1g +PERM_MIN=256m +PERM_MAX=256m + +# +# Use this if you want to enable remote debugging of the service java virtual +# machine (useful mainly for developers): +# +# 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 service and the debugger in +# the same machine. +# +DEBUG_ADDRESS= + +# +# Set this if you wish to write service log to console as well. +# +REPORTS_LOG_TO_CONSOLE=false + +# +# Change following to true if you want to enable garbage collection debug +# information (will be sent to the console.log file): +# +VERBOSE_GC=false + +# +# Extra system properties to be added to the java virtual machine +# of the service. 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 +# +SERVICE_PROPERTIES="" +SERVICE_PROPERTIES="${SERVICE_PROPERTIES} jsse.enableSNIExtension=false" +SERVICE_PROPERTIES="${SERVICE_PROPERTIES} \"java.security.krb5.conf=${REPORTS_ETC}/krb5.conf\"" + +# +# Extra Java arguments to be added to command-line. +# +JVM_ARGS="" +JVM_ARGS="${JVM_ARGS} -XX:+HeapDumpOnOutOfMemoryError" +JVM_ARGS="${JVM_ARGS} -XX:HeapDumpPath=\"${PKG_LOG_DIR}/dump\"" + +# +# Module path +# +# Colon separated list of paths. +# +# JBoss is always appended, cannot be appended here +# as it may be resolved to different value. +# +JAVA_MODULEPATH="${PKG_DATA_DIR}/modules" + +# +# Additional applications to be deployed in the instance of the +# application server started by the service. This is a list of space +# separated files or directories that should exist under +# @PKG_DATA_DIR@ : +# +REPORTS_APPS=ovirt-engine-reports.war + +# +# Flags to enable or disable the web server (the proxy) and the +# connectors of the application server: +# +SERVICE_HTTP_ENABLED=false +SERVICE_HTTPS_ENABLED=false +SERVICE_HTTP_PORT=8700 +SERVICE_HTTPS_PORT=8701 + +SERVICE_AJP_ENABLED=false +SERVICE_AJP_PORT=8702 + +SERVICE_PROXY_ENABLED=false +SERVICE_PROXY_HTTP_PORT=80 +SERVICE_PROXY_HTTPS_PORT=443 + +# +# A comma separated list of the SSL protocols supported by the service +# when the HTTPS connector is enabled. The possible values are the +# following: +# +# SSLv3 +# TLSv1 +# TLSv1.1 +# TLSv1.2 +# +SERVICE_HTTPS_PROTOCOLS=SSLv3,TLSv1,TLSv1.1,TLSv1.2 + +# +# service host fully qualified domain name: +# +SERVICE_FQDN=localhost.localdomain + +# +# Database connection details +# +SENSITIVE_KEYS="${SENSITIVE_KEYS},REPORTS_DB_PASSWORD" +REPORTS_DB_HOST="localhost" +REPORTS_DB_PORT="5432" +REPORTS_DB_USER="ovirt_engine_reports" +REPORTS_DB_PASSWORD= +REPORTS_DB_DATABASE="ovirt_engine_reports" +REPORTS_DB_SECURED="False" +REPORTS_DB_SECURED_VALIDATION="False" +REPORTS_DB_DRIVER=org.postgresql.Driver +REPORTS_DB_URL="jdbc:postgresql://${ENGINE_DB_HOST}:${ENGINE_DB_PORT}/${ENGINE_DB_DATABASE}?sslfactory=org.postgresql.ssl.NonValidatingFactory" + +# +# Size of the database connection pool: +# +ENGINE_DB_MIN_CONNECTIONS=1 +ENGINE_DB_MAX_CONNECTIONS=100 + +# +# 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_INTERVAL=1000 + +# +# PKI artifacts +# + +# +# Reports +# by default serv 404. +# + diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports.py b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.py new file mode 100644 index 0000000..707203d --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.py @@ -0,0 +1,434 @@ +#!/usr/bin/python + +# Copyright 2014 Red Hat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +import sys +import re +import shlex +import gettext +_ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-reports') + + +from Cheetah.Template import Template + + +import config + + +from ovirt_engine import configfile +from ovirt_engine import service +from ovirt_engine import java + + +class Daemon(service.Daemon): + + def __init__(self): + super(Daemon, self).__init__() + self._tempDir = None + self._defaults = os.path.abspath( + os.path.join( + os.path.dirname(sys.argv[0]), + 'ovirt-engine-reports.conf', + ) + ) + + def _processTemplate(self, template, dir, mode=None): + out = os.path.join( + dir, + re.sub('\.in$', '', os.path.basename(template)), + ) + with open(out, 'w') as f: + if mode is not None: + os.chmod(out, mode) + f.write( + '%s' % ( + Template( + file=template, + searchList=[ + self._config, + { + 'tempdir': self._tempDir.directory, + }, + ], + ) + ), + ) + return out + + def _linkModules(self, directory, modulePath): + """ + Link all the JBoss modules into a temporary directory. + This required because jboss tries to automatically update + indexes based on timestamp even if there is no permission to do so. + """ + + modifiedModulePath = [] + for index, element in enumerate(modulePath.split(':')): + modulesTmpDir = os.path.join( + directory, + '%02d-%s' % ( + index, + '-'.join(element.split(os.sep)[-2:]), + ), + ) + modifiedModulePath.append(modulesTmpDir) + + # For each directory in the modules directory create the + # same in the temporary directory and populate with symlinks + # pointing to the original files (excluding indexes): + for parentDir, childrenDirs, childrenFiles in os.walk(element): + parentTmpDir = os.path.join( + modulesTmpDir, + os.path.relpath( + parentDir, + element + ), + ) + if not os.path.exists(parentTmpDir): + os.makedirs(parentTmpDir) + for childFile in childrenFiles: + if childFile.endswith('.index'): + continue + os.symlink( + os.path.join(parentDir, childFile), + os.path.join(parentTmpDir, childFile) + ) + + return ':'.join(modifiedModulePath) + + def _checkInstallation( + self, + pidfile, + jbossModulesJar, + ): + # Check the required JBoss directories and files: + self.check( + name=self._config.get('JBOSS_HOME'), + directory=True, + ) + self.check( + name=jbossModulesJar, + ) + + # Check the required directories and files: + self.check( + os.path.join( + self._config.get('PKG_DATA_DIR'), + 'services', + ), + directory=True, + ) + self.check( + self._config.get('PKG_TMP_DIR'), + directory=True, + writable=True, + mustExist=False, + ) + self.check( + self._config.get('PKG_LOG_DIR'), + directory=True, + writable=True, + ) + for log in ('reports.log', 'console.log', 'server.log'): + self.check( + name=os.path.join(self._config.get("PKG_LOG_DIR"), log), + mustExist=False, + writable=True, + ) + if pidfile is not None: + self.check( + name=pidfile, + writable=True, + mustExist=False, + ) + + def _setupApps(self): + + deploymentsDir = os.path.join( + self._tempDir.directory, + 'deployments', + ) + os.mkdir(deploymentsDir) + + # The list of applications to be deployed: + for AppDir in shlex.split(self._config.get('REPORTS_APPS')): + self.logger.debug('Deploying: %s', AppDir) + if not os.path.isabs(AppDir): + AppDir = os.path.join( + self._config.get('PKG_DATA_DIR'), + AppDir, + ) + if not os.path.exists(AppDir): + self.logger.warning( + _( + "Application directory '{directory}' " + "does not exist, it will be ignored" + ).format( + directory=AppDir, + ), + ) + continue + + AppLink = os.path.join( + deploymentsDir, + os.path.basename(AppDir), + ) + os.symlink(AppDir, AppLink) + with open('%s.dodeploy' % AppLink, 'w'): + pass + + def daemonSetup(self): + + if os.geteuid() == 0: + raise RuntimeError( + _('This service cannot be executed as root') + ) + + if not os.path.exists(self._defaults): + raise RuntimeError( + _( + "The configuration defaults file '{file}' " + "required but missing" + ).format( + file=self._defaults, + ) + ) + + self._config = configfile.ConfigFile( + ( + self._defaults, + config.REPORTS_VARS, + ), + ) + + # + # the earliest so we can abort early. + # + self._executable = os.path.join( + java.Java().getJavaHome(), + 'bin', + 'java', + ) + + jbossModulesJar = os.path.join( + self._config.get('JBOSS_HOME'), + 'jboss-modules.jar', + ) + + self._checkInstallation( + pidfile=self.pidfile, + jbossModulesJar=jbossModulesJar, + ) + + self._tempDir = service.TempDir(self._config.get('PKG_TMP_DIR')) + self._tempDir.create() + + self._setupApps() + + jbossTempDir = os.path.join( + self._tempDir.directory, + 'tmp', + ) + + jbossConfigDir = os.path.join( + self._tempDir.directory, + 'config', + ) + + javaModulePath = self._linkModules( + os.path.join( + self._tempDir.directory, + 'modules', + ), + '%s:%s' % ( + self._config.get('JAVA_MODULEPATH'), + os.path.join( + self._config.get('JBOSS_HOME'), + 'modules', + ), + ), + ) + + os.mkdir(jbossTempDir) + os.mkdir(jbossConfigDir) + os.chmod(jbossConfigDir, 0o700) + + jbossBootLoggingFile = self._processTemplate( + template=os.path.join( + os.path.dirname(sys.argv[0]), + 'ovirt-engine-reports-logging.properties.in' + ), + dir=jbossConfigDir, + ) + + jbossConfigFile = self._processTemplate( + template=os.path.join( + os.path.dirname(sys.argv[0]), + 'ovirt-engine-reports.xml.in', + ), + dir=jbossConfigDir, + mode=0o600, + ) + + # We start with an empty list of arguments: + self._serviceArgs = [] + + # Add arguments for the java virtual machine: + self._serviceArgs.extend([ + # The name or the process, as displayed by ps: + 'ovirt-engine-reports', + + # Virtual machine options: + '-server', + '-XX:+TieredCompilation', + '-Xms%s' % self._config.get('HEAP_MIN'), + '-Xmx%s' % self._config.get('HEAP_MAX'), + '-XX:PermSize=%s' % self._config.get('PERM_MIN'), + '-XX:MaxPermSize=%s' % self._config.get('PERM_MAX'), + '-Djava.net.preferIPv4Stack=true', + '-Dsun.rmi.dgc.client.gcInterval=3600000', + '-Dsun.rmi.dgc.server.gcInterval=3600000', + '-Djava.awt.headless=true', + ]) + + # Add extra system properties provided in the configuration: + for serviceProperty in shlex.split( + self._config.get('SERVICE_PROPERTIES') + ): + if not serviceProperty.startswith('-D'): + serviceProperty = '-D' + serviceProperty + self._serviceArgs.append(serviceProperty) + + # Add extra jvm arguments provided in the configuration: + for arg in shlex.split(self._config.get('JVM_ARGS')): + self._serviceArgs.append(arg) + + # Add arguments for remote debugging of the java virtual machine: + debugAddress = self._config.get('DEBUG_ADDRESS') + if debugAddress: + self._serviceArgs.append( + ( + '-Xrunjdwp:transport=dt_socket,address=%s,' + 'server=y,suspend=n' + ) % ( + debugAddress + ) + ) + + # Enable verbose garbage collection if required: + if self._config.getboolean('VERBOSE_GC'): + self._serviceArgs.extend([ + '-verbose:gc', + '-XX:+PrintGCTimeStamps', + '-XX:+PrintGCDetails', + ]) + + # Add arguments for JBoss: + self._serviceArgs.extend([ + '-Djava.util.logging.manager=org.jboss.logmanager', + '-Dlogging.configuration=file://%s' % jbossBootLoggingFile, + '-Dorg.jboss.resolver.warning=true', + '-Djboss.modules.system.pkgs=org.jboss.byteman', + '-Djboss.modules.write-indexes=false', + '-Djboss.server.default.config=ovirt-engine-reports', + '-Djboss.home.dir=%s' % self._config.get( + 'JBOSS_HOME' + ), + '-Djboss.server.base.dir=%s' % self._config.get( + 'PKG_DATA_DIR' + ), + '-Djboss.server.data.dir=%s' % self._config.get( + 'PKG_STATE_DIR' + ), + '-Djboss.server.log.dir=%s' % self._config.get( + 'PKG_LOG_DIR' + ), + '-Djboss.server.config.dir=%s' % jbossConfigDir, + '-Djboss.server.temp.dir=%s' % jbossTempDir, + '-Djboss.controller.temp.dir=%s' % jbossTempDir, + '-jar', jbossModulesJar, + '-mp', javaModulePath, + '-jaxpmodule', 'javax.xml.jaxp-provider', + 'org.jboss.as.standalone', + '-c', os.path.basename(jbossConfigFile), + ]) + + self._serviceEnv = os.environ.copy() + self._serviceEnv.update({ + 'PATH': ( + '/usr/local/sbin:/usr/local/bin:' + '/usr/sbin:/usr/bin:/sbin:/bin' + ), + 'LANG': 'en_US.UTF-8', + 'LC_ALL': 'en_US.UTF-8', + 'REPORTS_DEFAULTS': self._defaults, + 'REPORTS_VARS': config.REPORTS_VARS, + 'REPORTS_ETC': self._config.get('REPORTS_ETC'), + 'PKG_LOG_DIR': self._config.get('PKG_LOG_DIR'), + 'PKG_TMP_DIR': self._tempDir.directory, + 'PKG_DATA_DIR': self._config.get('PKG_DATA_DIR'), + 'PKG_STATE_DIR': self._config.get('PKG_STATE_DIR'), + }) + + def daemonStdHandles(self): + consoleLog = open( + os.path.join( + self._config.get('PKG_LOG_DIR'), + 'console.log' + ), + 'w+', + ) + return (consoleLog, consoleLog) + + def daemonContext(self): + try: + # + # create mark file to be used by notifier service + # + with open(self._config.get('SERVICE_UP_MARK'), 'w') as f: + f.write('%s\n' % os.getpid()) + + self.daemonAsExternalProcess( + executable=self._executable, + args=self._serviceArgs, + env=self._serviceEnv, + stopTime=self._config.getinteger( + 'STOP_TIME' + ), + stopInterval=self._config.getinteger( + 'STOP_INTERVAL' + ), + ) + + raise self.TerminateException() + + except self.TerminateException: + if os.path.exists(self._config.get('SERVICE_UP_MARK')): + os.remove(self._config.get('SERVICE_UP_MARK')) + + def daemonCleanup(self): + if self._tempDir: + self._tempDir.destroy() + + +if __name__ == '__main__': + service.setupLogger() + d = Daemon() + d.run() + + +# vim: expandtab tabstop=4 shiftwidth=4 diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports.systemd.in b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.systemd.in new file mode 100644 index 0000000..867de41 --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.systemd.in @@ -0,0 +1,14 @@ +[Unit] +Description=oVirt Engine Reports +After=network.service postgresql.service + +[Service] +Type=notify +User=@PKG_USER@ +Group=@PKG_GROUP@ +LimitNOFILE=65535 +ExecStart=@PKG_DATA_DIR@/services/ovirt-engine-reports/ovirt-engine-reports.py --redirect-output --systemd=notify $EXTRA_ARGS start +EnvironmentFile=-/etc/sysconfig/ovirt-engine-reports + +[Install] +WantedBy=multi-user.target diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv.in b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv.in new file mode 100644 index 0000000..6571728 --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.sysv.in @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Start/stop oVirt Engine Reports +# +# chkconfig: - 65 34 +# description: oVirt Engine Reports +# pidfile: /var/run/ovirt-engine-reports.pid + +### BEGIN INIT INFO +# Provides: ovirt-engine-reports +# Short-Description: oVirt Engine Reports +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +NAME="ovirt-engine-reports" +PROG="oVirt Engine Reports" + +[ -f "/etc/sysconfig/${NAME}" ] && . "/etc/sysconfig/${NAME}" + +RETVAL=0 +LOCKFILE="/var/lock/subsys/${NAME}" +PIDFILE="${PIDFILE:-/var/run/${NAME}.pid}" +USER="@PKG_USER@" +PKG_DATA_DIR="@PKG_DATA_DIR@" + +# See how we were called. +case "$1" in + start) + if [ `id -u` -ne 0 ]; then + echo $"Insufficient privilege" 1>&2 + exit 4 + fi + echo -n $"Starting $PROG: " + ulimit -n ${FILENO:-65535} + touch "${PIDFILE}" + chown "${USER}" "${PIDFILE}" + daemon --user "${USER}" --pidfile="${PIDFILE}" \ + "${PKG_DATA_DIR}/services/${NAME}/${NAME}.py" \ + --pidfile="${PIDFILE}" \ + --background \ + --redirect-output \ + ${EXTRA_ARGS} \ + start + RETVAL=$? + echo + if [ $RETVAL -eq 0 ]; then + touch "${LOCKFILE}" + else + if [ -f "${LOCKFILE}" ]; then + RETVAL=0 + fi + fi + [ $RETVAL -ne 0 -a ! -s "${PIDFILE}" ] && rm -f "${PIDFILE}" + ;; + stop) + echo -n $"Stopping $PROG: " + killproc -p "${PIDFILE}" -d 60 + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f "${LOCKFILE}" + ;; + status) + status -p "${PIDFILE}" "${NAME}" + RETVAL=$? + ;; + restart) + $0 stop + $0 start + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|status|restart}" + exit 2 + ;; +esac + +exit $RETVAL diff --git a/packaging/services/ovirt-engine-reports/ovirt-engine-reports.xml.in b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.xml.in new file mode 100644 index 0000000..41cdbdf --- /dev/null +++ b/packaging/services/ovirt-engine-reports/ovirt-engine-reports.xml.in @@ -0,0 +1,351 @@ +<?xml version="1.0" ?> + +<server xmlns="urn:jboss:domain:1.1"> + + <extensions> + <extension module="org.jboss.as.clustering.infinispan"/> + <extension module="org.jboss.as.connector"/> + <extension module="org.jboss.as.deployment-scanner"/> + <extension module="org.jboss.as.ee"/> + <extension module="org.jboss.as.ejb3"/> + <extension module="org.jboss.as.jaxrs"/> + <extension module="org.jboss.as.jmx"/> + <extension module="org.jboss.as.jpa"/> + <extension module="org.jboss.as.logging"/> + <extension module="org.jboss.as.naming"/> + <extension module="org.jboss.as.remoting"/> + <extension module="org.jboss.as.security"/> + <extension module="org.jboss.as.threads"/> + <extension module="org.jboss.as.transactions"/> + <extension module="org.jboss.as.web"/> + </extensions> + + <system-properties> + <!-- Don't let quartz call home to check for updates: --> + <property name="org.quartz.scheduler.skipUpdateCheck" value="true"/> + + <!-- Configure quartz thread pool: --> + <property name="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"/> + <property name="org.quartz.threadPool.threadCount" value="100"/> + <property name="org.quartz.jobStore.misfireThreshold" value="60000"/> + <property name="org.quartz.jobStore.class" value="org.quartz.simpl.RAMJobStore"/> + + <!-- Enable compression for html content and REST api --> + <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/> + <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="text/javascript,text/css,text/html,text/xml,text/json,application/x-yaml,application/xml,application/json"/> + + </system-properties> + + <!-- We need to enable the management subsystem because it is an + indirect dependency of the Infinispan subsystem (since version + 7.2 of the application server) but at the same time we don't + want anyone (other than the root and ovirt users) to be able + to connect to the management port, so we just use an empty + users file: --> + <management> + <security-realms> + <security-realm name="management"> + <authentication> + <properties path="/dev/null"/> + </authentication> + </security-realm> + </security-realms> + <management-interfaces> + <native-interface security-realm="management"> + <socket-binding native="management"/> + </native-interface> + </management-interfaces> + </management> + + <profile> + + <subsystem xmlns="urn:jboss:domain:logging:1.1"> + + <!-- All the application server messages go here: --> + <file-handler name="SERVER"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file path="$getstring('PKG_LOG_DIR')/server.log"/> + <append value="true"/> + </file-handler> + + <!-- Only the engine messages go here: --> + <file-handler name="ENGINE" autoflush="true"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/> + </formatter> + <file path="$getstring('PKG_LOG_DIR')/reports.log"/> + <append value="true"/> + </file-handler> + + <!-- Console --> + <console-handler name="CONSOLE" autoflush="true"> + <level name="INFO"/> + <formatter> + <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/> + </formatter> + </console-handler> + + <!-- Loggers for the application server: --> + <logger category="com.arjuna"> + <level name="WARN"/> + </logger> + <logger category="org.apache.tomcat.util"> + <level name="WARN"/> + </logger> + <logger category="sun.rmi"> + <level name="WARN"/> + </logger> + + <!-- Loggers for the engine: --> + <logger category="org.ovirt" use-parent-handlers="false"> + <level name="INFO"/> + <handlers> + <handler name="ENGINE"/> + #if $getboolean('REPORTS_LOG_TO_CONSOLE') + <handler name="CONSOLE"/> + #end if + </handlers> + </logger> + <logger category="org.ovirt.engine.core.bll"> + <level name="INFO"/> + </logger> + <logger category="org.ovirt.engine.core.dal.dbbroker.PostgresDbEngineDialect\$PostgresJdbcTemplate"> + <level name="WARN"/> + </logger> + <logger category="org.springframework.ldap"> + <level name="ERROR"/> + </logger> + + <root-logger> + <level name="INFO"/> + <handlers> + <handler name="SERVER"/> + </handlers> + </root-logger> + + </subsystem> + + <subsystem xmlns="urn:jboss:domain:datasources:1.0"> + + <datasources> + + <datasource jndi-name="java:/ENGINEDataSource" pool-name="ENGINEDataSource" enabled="true" use-ccm="false"> + <connection-url><![CDATA[$getstring('ENGINE_DB_URL')]]></connection-url> + <driver>postgresql</driver> + <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> + <pool> + <min-pool-size>$getinteger('ENGINE_DB_MIN_CONNECTIONS')</min-pool-size> + <max-pool-size>$getinteger('ENGINE_DB_MAX_CONNECTIONS')</max-pool-size> + <prefill>true</prefill> + </pool> + <security> + <user-name><![CDATA[$getstring('ENGINE_DB_USER')]]></user-name> + <password><![CDATA[$getstring('ENGINE_DB_PASSWORD')]]></password> + </security> + <statement> + <prepared-statement-cache-size>100</prepared-statement-cache-size> + <share-prepared-statements/> + </statement> + <validation> + <validate-on-match>true</validate-on-match> + <check-valid-connection-sql>select 1</check-valid-connection-sql> + </validation> + </datasource> + + <drivers> + <driver name="postgresql" module="org.postgresql"> + <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> + </driver> + </drivers> + + </datasources> + + </subsystem> + + <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"> + <deployment-scanner scan-interval="5000" path="$tempdir/deployments" deployment-timeout="1200"/> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:ee:1.0"/> + + <subsystem xmlns="urn:jboss:domain:ejb3:1.2"> + <session-bean> + <stateless> + <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/> + </stateless> + <stateful default-access-timeout="300000" cache-ref="simple"/> + <singleton default-access-timeout="300000"/> + </session-bean> + <mdb> + <resource-adapter-ref resource-adapter-name="hornetq-ra"/> + <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/> + </mdb> + <pools> + <bean-instance-pools> + <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> + <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/> + </bean-instance-pools> + </pools> + <caches> + <cache name="simple" aliases="NoPassivationCache"/> + </caches> + <async thread-pool-name="default"/> + <timer-service thread-pool-name="default"> + <data-store path="$getstring('PKG_STATE_DIR')/timer-service-data"/> + </timer-service> + <remote connector-ref="remoting-connector" thread-pool-name="default"/> + <thread-pools> + <thread-pool name="default"> + <max-threads count="10"/> + <keepalive-time time="100" unit="milliseconds"/> + </thread-pool> + </thread-pools> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:infinispan:1.1" default-cache-container="ovirt-engine"> + <cache-container name="ovirt-engine" default-cache="timeout-base" jndi-name="java:jboss/infinispan/ovirt-engine" start="EAGER"> + <local-cache name="timeout-base"> + <transaction mode="NONE"/> + <eviction max-entries="10000"/> + <expiration interval="60000"/> + </local-cache> + </cache-container> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/> + + <subsystem xmlns="urn:jboss:domain:jca:1.1"> + <archive-validation enabled="false" fail-on-error="false" fail-on-warn="false"/> + <bean-validation enabled="true"/> + <default-workmanager> + <short-running-threads> + <core-threads count="50"/> + <queue-length count="50"/> + <max-threads count="50"/> + <keepalive-time time="10" unit="seconds"/> + </short-running-threads> + <long-running-threads> + <core-threads count="50"/> + <queue-length count="50"/> + <max-threads count="50"/> + <keepalive-time time="10" unit="seconds"/> + </long-running-threads> + </default-workmanager> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:jmx:1.1"> + <show-model value="true"/> + <remoting-connector/> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:jpa:1.0"> + <jpa default-datasource=""/> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:naming:1.1"/> + + <subsystem xmlns="urn:jboss:domain:remoting:1.1"> + <connector name="remoting-connector" socket-binding="remoting"/> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:resource-adapters:1.0"/> + + <subsystem xmlns="urn:jboss:domain:security:1.1"> + <security-domains> + <security-domain name="other" cache-type="default"> + <authentication> + <login-module code="Remoting" flag="optional"> + <module-option name="password-stacking" value="useFirstPass"/> + </login-module> + </authentication> + </security-domain> + <security-domain name="jboss-web-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + <security-domain name="jboss-ejb-policy" cache-type="default"> + <authorization> + <policy-module code="Delegating" flag="required"/> + </authorization> + </security-domain> + + <security-domain name="oVirtKerb"> + <authentication> + <login-module code="com.sun.security.auth.module.Krb5LoginModule" flag="required"/> + </authentication> + </security-domain> + + <security-domain name="oVirtKerbDebug"> + <authentication> + <login-module code="com.sun.security.auth.module.Krb5LoginModule" flag="required"> + <module-option name="debug" value="true"/> + </login-module> + </authentication> + </security-domain> + + </security-domains> + </subsystem> + + <subsystem xmlns="urn:jboss:domain:transactions:1.1"> + <core-environment> + <process-id> + <uuid/> + </process-id> + </core-environment> + <recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/> + <coordinator-environment default-timeout="600"/> + </subsystem> + + <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') + <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') + <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true"> + <ssl name="ssl" password="mypass" certificate-key-file="$getstring('SYSCONF_DIR')/pki/ovirt-engine/keys/jboss.p12" keystore-type="PKCS12" key-alias="1" protocol="$getstring('ENGINE_HTTPS_PROTOCOLS')" verify-client="false"/> + </connector> + #end if + #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"/> + <rewrite pattern="^/RHEVManager(.*)$" substitution="/OvirtEngine$1" flags="last"/> + </virtual-server> + </subsystem> + + </profile> + + <interfaces> + <interface name="loopback"> + <loopback/> + </interface> + <interface name="public"> + <any-address/> + </interface> + </interfaces> + + <socket-binding-group name="standard-sockets" default-interface="loopback"> + #if $getboolean('ENGINE_HTTP_ENABLED') + <socket-binding name="http" port="$getinteger('ENGINE_HTTP_PORT')" interface="public"/> + #end if + #if $getboolean('ENGINE_HTTPS_ENABLED') + <socket-binding name="https" port="$getinteger('ENGINE_HTTPS_PORT')" interface="public"/> + #end if + #if $getboolean('ENGINE_AJP_ENABLED') + <socket-binding name="ajp" port="$getinteger('ENGINE_AJP_PORT')"/> + #end if + <socket-binding name="remoting" port="8703"/> + <socket-binding name="txn-recovery-environment" port="8704"/> + <socket-binding name="txn-status-manager" port="8705"/> + <socket-binding name="management" port="8706"/> + </socket-binding-group> + +</server> -- To view, visit http://gerrit.ovirt.org/28681 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I265f3126bb36e6ecd0c6e36c24b97e894237f5e0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-reports Gerrit-Branch: master Gerrit-Owner: Yedidyah Bar David <d...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches