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)
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)
def _reset_admin_password(self): """ Reset the password of the Trove's administrative superuser. The service should not be running at this point. A general password reset procedure is: - disable user authentication and remote access - restart the service - update the password in the 'system_auth.credentials' table - re-enable authentication and make the host reachable - restart the service """ if self.status.is_running: raise RuntimeError(_("Cannot reset the administrative password. " "The service is still running.")) try: # Disable automatic startup in case the node goes down before # we have the superuser secured. operating_system.disable_service_on_boot(self.service_candidates) self.__disable_remote_access() self.__disable_authentication() # We now start up the service and immediately re-enable # authentication in the configuration file (takes effect after # restart). # Then we reset the superuser password to its default value # and restart the service to get user functions back. self.start_db(update_db=False, enable_on_boot=False) self.__enable_authentication() os_admin = self.__reset_user_password_to_default(self._ADMIN_USER) self.status = CassandraAppStatus(os_admin) self.restart() # Now change the administrative password to a new secret value. self.secure(update_user=os_admin) finally: self.stop_db() # Always restore the initial state of the service. # At this point, we should have a secured database with new Trove-only # superuser password. # Proceed to re-enable remote access and automatic startup. self.__enable_remote_access() operating_system.enable_service_on_boot(self.service_candidates)
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.")
def _enable_redis_on_boot(self): """ Enables redis on boot. """ LOG.info(_('Enabling Redis on boot.')) operating_system.enable_service_on_boot(system.SERVICE_CANDIDATES)
def _enable_redis_on_boot(self): """ Enables redis on boot. """ LOG.info(_('Enabling Redis on boot.')) operating_system.enable_service_on_boot(system.SERVICE_CANDIDATES)