示例#1
0
文件: service.py 项目: vmazur/trove
    def start_db_service(self,
                         service_candidates,
                         timeout,
                         enable_on_boot=True,
                         update_db=False):
        """Start the database service and wait for the database to become
        available.
        The service auto-start will be updated only if the service command
        succeeds.

        :param service_candidates:   List of possible system service names.
        :type service_candidates:    list

        :param timeout:              Wait timeout in seconds.
        :type timeout:               integer

        :param enable_on_boot:       Enable service auto-start.
                                     The auto-start setting will be updated
                                     only if the service command succeeds.
        :type enable_on_boot:        boolean

        :param update_db:            Suppress the Trove instance heartbeat.
        :type update_db:             boolean

        :raises:              :class:`RuntimeError` on failure.
        """
        LOG.info(_("Starting database service."))
        operating_system.start_service(service_candidates)

        self.wait_for_database_service_start(timeout, update_db=update_db)

        if enable_on_boot:
            LOG.info(_("Enable service auto-start on boot."))
            operating_system.enable_service_on_boot(service_candidates)
示例#2
0
    def start_db_service(self, service_candidates, timeout,
                         enable_on_boot=True, update_db=False):
        """Start the database service and wait for the database to become
        available.
        The service auto-start will be updated only if the service command
        succeeds.

        :param service_candidates:   List of possible system service names.
        :type service_candidates:    list

        :param timeout:              Wait timeout in seconds.
        :type timeout:               integer

        :param enable_on_boot:       Enable service auto-start.
                                     The auto-start setting will be updated
                                     only if the service command succeeds.
        :type enable_on_boot:        boolean

        :param update_db:            Suppress the Trove instance heartbeat.
        :type update_db:             boolean

        :raises:              :class:`RuntimeError` on failure.
        """
        LOG.info(_("Starting database service."))
        operating_system.start_service(service_candidates, timeout=timeout)

        self.wait_for_database_service_start(timeout, update_db=update_db)

        if enable_on_boot:
            LOG.info(_("Enable service auto-start on boot."))
            operating_system.enable_service_on_boot(service_candidates)
示例#3
0
文件: service.py 项目: jjmob/trove
 def start_redis(self, update_db=False):
     """
     Start the redis daemon.
     """
     LOG.info(_("Starting redis."))
     self._enable_redis_on_boot()
     operating_system.start_service(system.SERVICE_CANDIDATES)
     if not self.status.wait_for_real_status_to_change_to(
             rd_instance.ServiceStatuses.RUNNING,
             self.state_change_wait_time, update_db):
         LOG.error(_("Start up of redis failed."))
         try:
             utils.execute_with_timeout('pkill', '-9',
                                        'redis-server',
                                        run_as_root=True,
                                        root_helper='sudo')
         except exception.ProcessExecutionError:
             LOG.exception(_('Error killing stalled redis start command.'))
         self.status.end_restart()
示例#4
0
 def start_redis(self, update_db=False):
     """
     Start the redis daemon.
     """
     LOG.info(_("Starting redis."))
     self._enable_redis_on_boot()
     operating_system.start_service(system.SERVICE_CANDIDATES)
     if not self.status.wait_for_real_status_to_change_to(
             rd_instance.ServiceStatuses.RUNNING,
             self.state_change_wait_time, update_db):
         LOG.error(_("Start up of redis failed."))
         try:
             utils.execute_with_timeout('pkill', '-9',
                                        'redis-server',
                                        run_as_root=True,
                                        root_helper='sudo')
         except exception.ProcessExecutionError:
             LOG.exception(_('Error killing stalled redis start command.'))
         self.status.end_install_or_restart()
示例#5
0
 def enable_ldap(self):
     LOG.debug("Starting saslauthd for LDAP support.")
     # Ubuntu and RHEL have different ways of enabling the service
     saslauthd_init_file = operating_system.file_discovery(
         ['/etc/default/saslauthd'])
     if saslauthd_init_file:
         codec = stream_codecs.KeyValueCodec(line_terminator='\n')
         saslauthd_init = operating_system.read_file(
             saslauthd_init_file, codec=codec, as_root=True)
         saslauthd_init['START'] = 'yes'
         operating_system.write_file(
             saslauthd_init_file, saslauthd_init, codec=codec, as_root=True)
     elif operating_system.file_discovery(['/etc/sysconfig/saslauthd']):
         operating_system.enable_service_on_boot(['saslauthd'])
     else:
         LOG.exception(_("Cannot find saslauthd service to enable for LDAP "
                         "client. Skipping."))
         return
     operating_system.start_service(['saslauthd'])
     saslauthd_conf_file = '/etc/saslauthd.conf'
     saslauthd_conf = operating_system.read_file(
         saslauthd_conf_file, stream_codecs.YamlCodec(), as_root=True)
     saslauthd_conf.update({
         'ldap_servers': CONF.get(self.manager).get('ldap_servers'),
         'ldap_search_base': CONF.get(self.manager).get('ldap_search_base')
     })
     ldap_tls_cacert_dir = CONF.get(self.manager).get('ldap_tls_cacert_dir',
                                                      None)
     if ldap_tls_cacert_dir:
         saslauthd_conf.update({
             'ldap_tls_cacert_dir': ldap_tls_cacert_dir,
         })
     ldap_tls_cacert_file = (CONF.get(self.manager)
                                 .get('ldap_tls_cacert_file', None))
     if ldap_tls_cacert_file:
         saslauthd_conf.update({
             'ldap_tls_cacert_file': ldap_tls_cacert_file,
         })
     operating_system.write_file(
         saslauthd_conf_file, saslauthd_conf,
         stream_codecs.YamlCodec(), as_root=True)
     LOG.debug("Enabled saslauthd as an LDAP client.")