예제 #1
0
    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.ENGINE_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('ENGINE_TMP'))
        self._tempDir.create()

        self._jbossRuntime = service.TempDir(self._config.get('JBOSS_RUNTIME'))
        self._jbossRuntime.create()

        self._setupEngineApps()

        jbossTempDir = os.path.join(
            self._jbossRuntime.directory,
            'tmp',
        )

        jbossConfigDir = os.path.join(
            self._jbossRuntime.directory,
            'config',
        )

        javaModulePath = '%s:%s' % (
            self._config.get('ENGINE_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-logging.properties.in'),
            dir=jbossConfigDir,
        )

        # We start with an empty list of arguments:
        self._engineArgs = []

        # Add arguments for the java virtual machine:
        self._engineArgs.extend([
            # Virtual machine options:
            '-server',
            '-XX:+TieredCompilation',
            '-Xms%s' % self._config.get('ENGINE_HEAP_MIN'),
            '-Xmx%s' % self._config.get('ENGINE_HEAP_MAX'),
        ])

        # Add extra system properties provided in the configuration:
        for engineProperty in shlex.split(
                self._config.get('ENGINE_PROPERTIES')):
            if not engineProperty.startswith('-D'):
                engineProperty = '-D' + engineProperty
            self._engineArgs.append(engineProperty)

        # Add extra jvm arguments provided in the configuration:
        for arg in shlex.split(self._config.get('ENGINE_JVM_ARGS')):
            self._engineArgs.append(arg)

        # Enable verbose garbage collection if required:
        if self._config.getboolean('ENGINE_VERBOSE_GC'):
            self._engineArgs.extend([
                '-verbose:gc',
                '-XX:+PrintGCTimeStamps',
                '-XX:+PrintGCDetails',
            ])

        # Specify special krb5.conf file if required
        if self._config.get('AAA_KRB5_CONF_FILE'):
            self._engineArgs.append('-Djava.security.krb5.conf=%s' %
                                    self._config.get('AAA_KRB5_CONF_FILE'))

        # Add arguments for JBoss:
        self._engineArgs.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.server.default.config=ovirt-engine',
            '-Djboss.home.dir=%s' % self._config.get('JBOSS_HOME'),
            '-Djboss.server.base.dir=%s' % self._config.get('ENGINE_USR'),
            '-Djboss.server.data.dir=%s' % self._config.get('ENGINE_VAR'),
            '-Djboss.server.log.dir=%s' % self._config.get('ENGINE_LOG'),
            '-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',
        ])

        self._engineEnv = os.environ.copy()
        self._engineEnv.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',
            'ENGINE_DEFAULTS':
            self._defaults,
            'ENGINE_VARS':
            config.ENGINE_VARS,
            'ENGINE_ETC':
            self._config.get('ENGINE_ETC'),
            'ENGINE_LOG':
            self._config.get('ENGINE_LOG'),
            'ENGINE_TMP':
            self._tempDir.directory,
            'ENGINE_USR':
            self._config.get('ENGINE_USR'),
            'ENGINE_VAR':
            self._config.get('ENGINE_VAR'),
            'ENGINE_CACHE':
            self._config.get('ENGINE_CACHE'),
        })

        self._detectJBossVersion()

        self._jbossConfigFile = self._processTemplate(
            template=os.path.join(
                os.path.dirname(sys.argv[0]),
                'ovirt-engine.xml.in',
            ),
            dir=jbossConfigDir,
            mode=0o600,
        )
예제 #2
0
    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.DWH_VARS,
            ),
        )

        #
        # the earliest so we can abort early.
        #
        self._executable = os.path.join(
            java.Java().getJavaHome(),
            'bin',
            'java',
        )

        self._checkInstallation(
            pidfile=self.pidfile,
        )

        self._tempDir = service.TempDir()
        self._tempDir.create()

        settings = os.path.join(self._tempDir.directory, 'settings.properties')
        with open(settings, 'w') as f:
            f.write(
                util.processTemplate(
                    os.path.join(
                        self._config.get('PKG_DATA_DIR'),
                        'conf',
                        'settings.properties.in'
                    ),
                    dict(
                        ('@%s@' % k, util.escape(v, ':=\\ ')) for (k, v) in
                        self._config.values.items()
                    ),
                )
            )

        self._serviceArgs = [
            'ovirt-engine-dwhd',
            '-Dorg.ovirt.engine.dwh.settings=%s' % settings,
        ]

        # Add arguments for the java heap size:
        self._serviceArgs.extend([
            '-Xms%s' % self._config.get('DWH_HEAP_MIN'),
            '-Xmx%s' % self._config.get('DWH_HEAP_MAX'),
        ])

        for engineProperty in shlex.split(
            self._config.get('DWH_PROPERTIES')
        ):
            if not engineProperty.startswith('-D'):
                engineProperty = '-D' + engineProperty
            self._serviceArgs.append(engineProperty)

        for arg in shlex.split(self._config.get('DWH_JVM_ARGS')):
            self._serviceArgs.append(arg)

        engineDebugAddress = self._config.get('DWH_DEBUG_ADDRESS')
        if engineDebugAddress:
            self._serviceArgs.append(
                (
                    '-Xrunjdwp:transport=dt_socket,address=%s,'
                    'server=y,suspend=n'
                ) % (
                    engineDebugAddress
                )
            )

        if self._config.getboolean('DWH_VERBOSE_GC'):
            self._serviceArgs.extend([
                '-verbose:gc',
                '-XX:+PrintGCTimeStamps',
                '-XX:+PrintGCDetails',
            ])

        self._serviceArgs.extend([
            '-classpath', '%s:%s' % (
                os.path.join(
                    self._config.get('PKG_JAVA_LIB'),
                    '*',
                ),
                self._getClasspath(),
            ),
            'ovirt_engine_dwh.historyetl_4_3.HistoryETL',
            '--context=Default',
        ])

        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',
        })
예제 #3
0
    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.ENGINE_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('ENGINE_TMP'))
        self._tempDir.create()

        self._setupEngineApps()

        jbossTempDir = os.path.join(
            self._config.get('ENGINE_TMP'),
            'tmp',
        )

        jbossConfigDir = os.path.join(
            self._config.get('ENGINE_TMP'),
            'config',
        )

        javaModulePath = self._linkModules(
            '%s:%s' % (
                self._config.get('ENGINE_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-logging.properties.in'),
            dir=jbossConfigDir,
        )

        jbossConfigFile = self._processTemplate(
            template=os.path.join(
                os.path.dirname(sys.argv[0]),
                'ovirt-engine.xml.in',
            ),
            dir=jbossConfigDir,
            mode=0o600,
        )

        # We start with an empty list of arguments:
        self._engineArgs = []

        # Add arguments for the java virtual machine:
        self._engineArgs.extend([
            # The name or the process, as displayed by ps:
            'ovirt-engine',

            # Virtual machine options:
            '-server',
            '-XX:+TieredCompilation',
            '-Xms%s' % self._config.get('ENGINE_HEAP_MIN'),
            '-Xmx%s' % self._config.get('ENGINE_HEAP_MAX'),
            '-XX:PermSize=%s' % self._config.get('ENGINE_PERM_MIN'),
            '-XX:MaxPermSize=%s' % self._config.get('ENGINE_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 engineProperty in shlex.split(
                self._config.get('ENGINE_PROPERTIES')):
            if not engineProperty.startswith('-D'):
                engineProperty = '-D' + engineProperty
            self._engineArgs.append(engineProperty)

        # Add extra jvm arguments provided in the configuration:
        for arg in shlex.split(self._config.get('ENGINE_JVM_ARGS')):
            self._engineArgs.append(arg)

        # Add arguments for remote debugging of the java virtual machine:
        engineDebugAddress = self._config.get('ENGINE_DEBUG_ADDRESS')
        if engineDebugAddress:
            self._engineArgs.append(
                ('-Xrunjdwp:transport=dt_socket,address=%s,'
                 'server=y,suspend=n') % (engineDebugAddress))

        # Enable verbose garbage collection if required:
        if self._config.getboolean('ENGINE_VERBOSE_GC'):
            self._engineArgs.extend([
                '-verbose:gc',
                '-XX:+PrintGCTimeStamps',
                '-XX:+PrintGCDetails',
            ])

        # Add arguments for JBoss:
        self._engineArgs.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',
            '-Djboss.home.dir=%s' % self._config.get('JBOSS_HOME'),
            '-Djboss.server.base.dir=%s' % self._config.get('ENGINE_USR'),
            '-Djboss.server.data.dir=%s' % self._config.get('ENGINE_VAR'),
            '-Djboss.server.log.dir=%s' % self._config.get('ENGINE_LOG'),
            '-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._engineEnv = os.environ.copy()
        self._engineEnv.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',
            'ENGINE_DEFAULTS':
            self._defaults,
            'ENGINE_VARS':
            config.ENGINE_VARS,
            'ENGINE_ETC':
            self._config.get('ENGINE_ETC'),
            'ENGINE_LOG':
            self._config.get('ENGINE_LOG'),
            'ENGINE_TMP':
            self._config.get('ENGINE_TMP'),
            'ENGINE_USR':
            self._config.get('ENGINE_USR'),
            'ENGINE_VAR':
            self._config.get('ENGINE_VAR'),
            'ENGINE_CACHE':
            self._config.get('ENGINE_CACHE'),
        })