Exemplo n.º 1
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info,
                   config_contents, root_password, overrides,
                   cluster_config, snapshot):
        """This is called from prepare in the base class."""
        self.app.install_if_needed(packages)
        self.app.init_storage_structure(mount_point)

        if config_contents or device_path:
            # Stop the db while we configure
            # FIXME(amrith) Once the cassandra bug
            # https://issues.apache.org/jira/browse/CASSANDRA-2356
            # is fixed, this code may have to be revisited.
            LOG.debug("Stopping database prior to initial configuration.")
            self.app.stop_db()

            if config_contents:
                LOG.debug("Applying configuration.")
                self.app.configuration_manager.save_configuration(
                    config_contents)
                self.app.apply_initial_guestagent_configuration()

            if device_path:
                LOG.debug("Preparing data volume.")
                device = volume.VolumeDevice(device_path)
                # unmount if device is already mounted
                device.unmount_device(device_path)
                device.format()
                if os.path.exists(mount_point):
                    # rsync exiting data
                    LOG.debug("Migrating existing data.")
                    device.migrate_data(mount_point)
                # mount the volume
                LOG.debug("Mounting new volume.")
                device.mount(mount_point)

            LOG.debug("Starting database with configuration changes.")
            self.app.start_db(update_db=False)

            if not self.app.has_user_config():
                LOG.debug("Securing superuser access.")
                self.app.secure()
                self.app.restart()

            self.__admin = CassandraAdmin(self.app.get_current_superuser())
Exemplo n.º 2
0
 def __init__(self):
     self._app = service.CassandraApp()
     self.__admin = CassandraAdmin(self.app.get_current_superuser())
     super(Manager, self).__init__('cassandra')
Exemplo n.º 3
0
 def store_admin_credentials(self, context, admin_credentials):
     self.app.store_admin_credentials(admin_credentials)
     self.__admin = CassandraAdmin(self.app.get_current_superuser())
Exemplo n.º 4
0
    def do_prepare(self, context, packages, databases, memory_mb, users,
                   device_path, mount_point, backup_info, config_contents,
                   root_password, overrides, cluster_config, snapshot):
        """This is called from prepare in the base class."""
        self.app.install_if_needed(packages)
        self.app.init_storage_structure(mount_point)

        if config_contents or device_path or backup_info:

            # FIXME(pmalik) Once the cassandra bug
            # https://issues.apache.org/jira/browse/CASSANDRA-2356
            # is fixed, this code may have to be revisited.
            #
            # Cassandra generates system keyspaces on the first start.
            # The stored properties include the 'cluster_name', which once
            # saved cannot be easily changed without removing the system
            # tables. It is crucial that the service does not boot up in
            # the middle of the configuration procedure.
            # We wait here for the service to come up, stop it properly and
            # remove the generated keyspaces before proceeding with
            # configuration. If it does not start up within the time limit
            # we assume it is not going to and proceed with configuration
            # right away.
            LOG.debug("Waiting for database first boot.")
            if (self.app.status.wait_for_real_status_to_change_to(
                    trove_instance.ServiceStatuses.RUNNING,
                    CONF.state_change_wait_time, False)):
                LOG.debug("Stopping database prior to initial configuration.")
                self.app.stop_db()
                self.app._remove_system_tables()

            LOG.debug("Starting initial configuration.")
            if config_contents:
                LOG.debug("Applying configuration.")
                self.app.configuration_manager.save_configuration(
                    config_contents)
                cluster_name = None
                if cluster_config:
                    cluster_name = cluster_config.get('id', None)
                self.app.apply_initial_guestagent_configuration(
                    cluster_name=cluster_name)

            if cluster_config:
                self.app.write_cluster_topology(cluster_config['dc'],
                                                cluster_config['rack'],
                                                prefer_local=True)

            if device_path:
                LOG.debug("Preparing data volume.")
                device = volume.VolumeDevice(device_path)
                # unmount if device is already mounted
                device.unmount_device(device_path)
                device.format()
                if os.path.exists(mount_point):
                    # rsync exiting data
                    LOG.debug("Migrating existing data.")
                    device.migrate_data(mount_point)
                # mount the volume
                LOG.debug("Mounting new volume.")
                device.mount(mount_point)

            if not cluster_config:
                if backup_info:
                    self._perform_restore(backup_info, context, mount_point)

                LOG.debug("Starting database with configuration changes.")
                self.app.start_db(update_db=False)

                if not self.app.has_user_config():
                    LOG.debug("Securing superuser access.")
                    self.app.secure()
                    self.app.restart()

            self.__admin = CassandraAdmin(self.app.get_current_superuser())

        if not cluster_config and self.is_root_enabled(context):
            self.status.report_root(context, self.app.default_superuser_name)
Exemplo n.º 5
0
 def cluster_secure(self, context, password):
     os_admin = self.app.cluster_secure(password)
     self.__admin = CassandraAdmin(self.app.get_current_superuser())
     return os_admin