Esempio n. 1
0
 def start_db_with_conf_changes(self, context, config_contents):
     """
     Start this redis instance with new conf changes.
     """
     LOG.debug("Start DB with conf changes called.")
     app = RedisApp(RedisAppStatus.get())
     app.start_db_with_conf_changes(config_contents)
Esempio n. 2
0
 def start_db_with_conf_changes(self, context, config_contents):
     """
     Start this redis instance with new conf changes.
     """
     LOG.debug("Start DB with conf changes called.")
     app = RedisApp(RedisAppStatus.get())
     app.start_db_with_conf_changes(config_contents)
Esempio n. 3
0
 def reset_configuration(self, context, configuration):
     """
     Resets to the default configuration,
     currently this does nothing.
     """
     LOG.debug("Reset configuration called.")
     app = RedisApp(RedisAppStatus.get())
     app.reset_configuration(configuration)
Esempio n. 4
0
 def reset_configuration(self, context, configuration):
     """
     Resets to the default configuration,
     currently this does nothing.
     """
     LOG.debug("Reset configuration called.")
     app = RedisApp(RedisAppStatus.get())
     app.reset_configuration(configuration)
Esempio n. 5
0
 def stop_db(self, context, do_not_start_on_reboot=False):
     """
     Stop this redis instance.
     This method is called when the guest agent
     gets a stop message from the taskmanager.
     """
     LOG.debug("Stop DB called.")
     app = RedisApp(RedisAppStatus.get())
     app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)
Esempio n. 6
0
 def restart(self, context):
     """
     Restart this redis instance.
     This method is called when the guest agent
     gets a restart message from the taskmanager.
     """
     LOG.debug("Restart called.")
     app = RedisApp(RedisAppStatus.get())
     app.restart()
Esempio n. 7
0
 def stop_db(self, context, do_not_start_on_reboot=False):
     """
     Stop this redis instance.
     This method is called when the guest agent
     gets a stop message from the taskmanager.
     """
     LOG.debug("Stop DB called.")
     app = RedisApp(RedisAppStatus.get())
     app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)
Esempio n. 8
0
 def restart(self, context):
     """
     Restart this redis instance.
     This method is called when the guest agent
     gets a restart message from the taskmanager.
     """
     LOG.debug("Restart called.")
     app = RedisApp(RedisAppStatus.get())
     app.restart()
Esempio n. 9
0
 def prepare(self, context, packages, databases, memory_mb, users,
             device_path=None, mount_point=None, backup_info=None,
             config_contents=None, root_password=None, overrides=None,
             cluster_config=None, snapshot=None):
     """
     This is called when the trove instance first comes online.
     It is the first rpc message passed from the task manager.
     prepare handles all the base configuration of the redis instance.
     """
     try:
         app = RedisApp(RedisAppStatus.get())
         RedisAppStatus.get().begin_install()
         if device_path:
             device = volume.VolumeDevice(device_path)
             # unmount if device is already mounted
             device.unmount_device(device_path)
             device.format()
             device.mount(mount_point)
             operating_system.chown(mount_point, 'redis', 'redis',
                                    as_root=True)
             LOG.debug('Mounted the volume.')
         app.install_if_needed(packages)
         LOG.info(_('Writing redis configuration.'))
         app.write_config(config_contents)
         app.restart()
         LOG.info(_('Redis instance has been setup and configured.'))
     except Exception:
         LOG.exception(_("Error setting up Redis instance."))
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise RuntimeError("prepare call has failed.")
Esempio n. 10
0
 def prepare(self,
             context,
             packages,
             databases,
             memory_mb,
             users,
             device_path=None,
             mount_point=None,
             backup_info=None,
             config_contents=None,
             root_password=None,
             overrides=None,
             cluster_config=None,
             snapshot=None):
     """
     This is called when the trove instance first comes online.
     It is the first rpc message passed from the task manager.
     prepare handles all the base configuration of the redis instance.
     """
     try:
         app = RedisApp(RedisAppStatus.get())
         RedisAppStatus.get().begin_install()
         if device_path:
             device = volume.VolumeDevice(device_path)
             # unmount if device is already mounted
             device.unmount_device(device_path)
             device.format()
             device.mount(mount_point)
             operating_system.chown(mount_point,
                                    'redis',
                                    'redis',
                                    as_root=True)
             LOG.debug('Mounted the volume.')
         app.install_if_needed(packages)
         LOG.info(_('Writing redis configuration.'))
         app.write_config(config_contents)
         app.restart()
         LOG.info(_('Redis instance has been setup and configured.'))
     except Exception:
         LOG.exception(_("Error setting up Redis instance."))
         app.status.set_status(rd_instance.ServiceStatuses.FAILED)
         raise RuntimeError("prepare call has failed.")
Esempio n. 11
0
 def __init__(self):
     super(Manager, self).__init__(CONF)
     self._app = RedisApp()
Esempio n. 12
0
class Manager(periodic_task.PeriodicTasks):
    """
    This is the Redis manager class. It is dynamically loaded
    based off of the service_type of the trove instance
    """
    def __init__(self):
        super(Manager, self).__init__(CONF)
        self._app = RedisApp()

    @periodic_task.periodic_task
    def update_status(self, context):
        """
        Updates the redis trove instance. It is decorated with
        perodic task so it is automatically called every 3 ticks.
        """
        LOG.debug("Update status called.")
        self._app.status.update()

    def rpc_ping(self, context):
        LOG.debug("Responding to RPC ping.")
        return True

    def change_passwords(self, context, users):
        """
        Changes the redis instance password,
        it is currently not not implemented.
        """
        LOG.debug("Change passwords called.")
        raise exception.DatastoreOperationNotSupported(
            operation='change_passwords', datastore=MANAGER)

    def reset_configuration(self, context, configuration):
        """
        Resets to the default configuration,
        currently this does nothing.
        """
        LOG.debug("Reset configuration called.")
        self._app.reset_configuration(configuration)

    def _perform_restore(self, backup_info, context, restore_location, app):
        """
        Perform a restore on this instance,
        currently it is not implemented.
        """
        LOG.debug("Perform restore called.")
        raise exception.DatastoreOperationNotSupported(
            operation='_perform_restore', datastore=MANAGER)

    def prepare(self,
                context,
                packages,
                databases,
                memory_mb,
                users,
                device_path=None,
                mount_point=None,
                backup_info=None,
                config_contents=None,
                root_password=None,
                overrides=None,
                cluster_config=None,
                snapshot=None):
        """
        This is called when the trove instance first comes online.
        It is the first rpc message passed from the task manager.
        prepare handles all the base configuration of the redis instance.
        """
        try:
            self._app.status.begin_install()
            if device_path:
                device = volume.VolumeDevice(device_path)
                # unmount if device is already mounted
                device.unmount_device(device_path)
                device.format()
                device.mount(mount_point)
                operating_system.chown(mount_point,
                                       'redis',
                                       'redis',
                                       as_root=True)
                LOG.debug('Mounted the volume.')
            self._app.install_if_needed(packages)
            LOG.info(_('Writing redis configuration.'))
            self._app.configuration_manager.save_configuration(config_contents)
            self._app.apply_initial_guestagent_configuration()
            self._app.restart()
            LOG.info(_('Redis instance has been setup and configured.'))
        except Exception:
            LOG.exception(_("Error setting up Redis instance."))
            self._app.status.set_status(rd_instance.ServiceStatuses.FAILED)
            raise RuntimeError("prepare call has failed.")

    def restart(self, context):
        """
        Restart this redis instance.
        This method is called when the guest agent
        gets a restart message from the taskmanager.
        """
        LOG.debug("Restart called.")
        self._app.restart()

    def start_db_with_conf_changes(self, context, config_contents):
        """
        Start this redis instance with new conf changes.
        """
        LOG.debug("Start DB with conf changes called.")
        self._app.start_db_with_conf_changes(config_contents)

    def stop_db(self, context, do_not_start_on_reboot=False):
        """
        Stop this redis instance.
        This method is called when the guest agent
        gets a stop message from the taskmanager.
        """
        LOG.debug("Stop DB called.")
        self._app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)

    def get_filesystem_stats(self, context, fs_path):
        """Gets the filesystem stats for the path given."""
        LOG.debug("Get Filesystem Stats.")
        mount_point = CONF.get('mysql' if not MANAGER else MANAGER).mount_point
        return dbaas.get_filesystem_volume_stats(mount_point)

    def create_backup(self, context, backup_info):
        """
        This will eventually create a backup. Right now
        it does nothing.
        """
        LOG.debug("Create Backup called.")
        raise exception.DatastoreOperationNotSupported(
            operation='create_backup', datastore=MANAGER)

    def mount_volume(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.mount(mount_point, write_to_fstab=False)
        LOG.debug("Mounted the device %s at the mount point %s." %
                  (device_path, mount_point))

    def unmount_volume(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.unmount(mount_point)
        LOG.debug("Unmounted the device %s from the mount point %s." %
                  (device_path, mount_point))

    def resize_fs(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.resize_fs(mount_point)
        LOG.debug("Resized the filesystem at %s." % mount_point)

    def update_overrides(self, context, overrides, remove=False):
        LOG.debug("Updating overrides.")
        if remove:
            self._app.remove_overrides()
        else:
            self._app.update_overrides(context, overrides, remove)

    def apply_overrides(self, context, overrides):
        LOG.debug("Applying overrides.")
        self._app.apply_overrides(self._app.admin, overrides)

    def update_attributes(self, context, username, hostname, user_attrs):
        LOG.debug("Updating attributes.")
        raise exception.DatastoreOperationNotSupported(
            operation='update_attributes', datastore=MANAGER)

    def create_database(self, context, databases):
        LOG.debug("Creating database.")
        raise exception.DatastoreOperationNotSupported(
            operation='create_database', datastore=MANAGER)

    def create_user(self, context, users):
        LOG.debug("Creating user.")
        raise exception.DatastoreOperationNotSupported(operation='create_user',
                                                       datastore=MANAGER)

    def delete_database(self, context, database):
        LOG.debug("Deleting database.")
        raise exception.DatastoreOperationNotSupported(
            operation='delete_database', datastore=MANAGER)

    def delete_user(self, context, user):
        LOG.debug("Deleting user.")
        raise exception.DatastoreOperationNotSupported(operation='delete_user',
                                                       datastore=MANAGER)

    def get_user(self, context, username, hostname):
        LOG.debug("Getting user.")
        raise exception.DatastoreOperationNotSupported(operation='get_user',
                                                       datastore=MANAGER)

    def grant_access(self, context, username, hostname, databases):
        LOG.debug("Granting access.")
        raise exception.DatastoreOperationNotSupported(
            operation='grant_access', datastore=MANAGER)

    def revoke_access(self, context, username, hostname, database):
        LOG.debug("Revoking access.")
        raise exception.DatastoreOperationNotSupported(
            operation='revoke_access', datastore=MANAGER)

    def list_access(self, context, username, hostname):
        LOG.debug("Listing access.")
        raise exception.DatastoreOperationNotSupported(operation='list_access',
                                                       datastore=MANAGER)

    def list_databases(self,
                       context,
                       limit=None,
                       marker=None,
                       include_marker=False):
        LOG.debug("Listing databases.")
        raise exception.DatastoreOperationNotSupported(
            operation='list_databases', datastore=MANAGER)

    def list_users(self,
                   context,
                   limit=None,
                   marker=None,
                   include_marker=False):
        LOG.debug("Listing users.")
        raise exception.DatastoreOperationNotSupported(operation='list_users',
                                                       datastore=MANAGER)

    def enable_root(self, context):
        LOG.debug("Enabling root.")
        raise exception.DatastoreOperationNotSupported(operation='enable_root',
                                                       datastore=MANAGER)

    def is_root_enabled(self, context):
        LOG.debug("Checking if root is enabled.")
        raise exception.DatastoreOperationNotSupported(
            operation='is_root_enabled', datastore=MANAGER)

    def get_replication_snapshot(self,
                                 context,
                                 snapshot_info,
                                 replica_source_config=None):
        LOG.debug("Getting replication snapshot.")
        raise exception.DatastoreOperationNotSupported(
            operation='get_replication_snapshot', datastore=MANAGER)

    def attach_replication_slave(self, context, snapshot, slave_config):
        LOG.debug("Attaching replica.")
        raise exception.DatastoreOperationNotSupported(
            operation='attach_replication_slave', datastore=MANAGER)

    def detach_replica(self, context, for_failover=False):
        LOG.debug("Detaching replica.")
        raise exception.DatastoreOperationNotSupported(
            operation='detach_replica', datastore=MANAGER)

    def get_replica_context(self, context):
        raise exception.DatastoreOperationNotSupported(
            operation='get_replica_context', datastore=MANAGER)

    def make_read_only(self, context, read_only):
        raise exception.DatastoreOperationNotSupported(
            operation='make_read_only', datastore=MANAGER)

    def enable_as_master(self, context, replica_source_config):
        raise exception.DatastoreOperationNotSupported(
            operation='enable_as_master', datastore=MANAGER)

    def get_txn_count(self):
        raise exception.DatastoreOperationNotSupported(
            operation='get_txn_count', datastore=MANAGER)

    def get_latest_txn_id(self):
        raise exception.DatastoreOperationNotSupported(
            operation='get_latest_txn_id', datastore=MANAGER)

    def wait_for_txn(self, txn):
        raise exception.DatastoreOperationNotSupported(
            operation='wait_for_txn', datastore=MANAGER)

    def demote_replication_master(self, context):
        LOG.debug("Demoting replica source.")
        raise exception.DatastoreOperationNotSupported(
            operation='demote_replication_master', datastore=MANAGER)
Esempio n. 13
0
 def __init__(self):
     super(Manager, self).__init__(CONF)
     self._app = RedisApp()
Esempio n. 14
0
class Manager(periodic_task.PeriodicTasks):
    """
    This is the Redis manager class. It is dynamically loaded
    based off of the service_type of the trove instance
    """

    def __init__(self):
        super(Manager, self).__init__(CONF)
        self._app = RedisApp()

    @periodic_task.periodic_task
    def update_status(self, context):
        """
        Updates the redis trove instance. It is decorated with
        perodic task so it is automatically called every 3 ticks.
        """
        LOG.debug("Update status called.")
        self._app.status.update()

    def rpc_ping(self, context):
        LOG.debug("Responding to RPC ping.")
        return True

    def change_passwords(self, context, users):
        """
        Changes the redis instance password,
        it is currently not not implemented.
        """
        LOG.debug("Change passwords called.")
        raise exception.DatastoreOperationNotSupported(
            operation='change_passwords', datastore=MANAGER)

    def reset_configuration(self, context, configuration):
        """
        Resets to the default configuration,
        currently this does nothing.
        """
        LOG.debug("Reset configuration called.")
        self._app.reset_configuration(configuration)

    def _perform_restore(self, backup_info, context, restore_location, app):
        """
        Perform a restore on this instance,
        currently it is not implemented.
        """
        LOG.debug("Perform restore called.")
        raise exception.DatastoreOperationNotSupported(
            operation='_perform_restore', datastore=MANAGER)

    def prepare(self, context, packages, databases, memory_mb, users,
                device_path=None, mount_point=None, backup_info=None,
                config_contents=None, root_password=None, overrides=None,
                cluster_config=None, snapshot=None):
        """
        This is called when the trove instance first comes online.
        It is the first rpc message passed from the task manager.
        prepare handles all the base configuration of the redis instance.
        """
        try:
            self._app.status.begin_install()
            if device_path:
                device = volume.VolumeDevice(device_path)
                # unmount if device is already mounted
                device.unmount_device(device_path)
                device.format()
                device.mount(mount_point)
                operating_system.chown(mount_point, 'redis', 'redis',
                                       as_root=True)
                LOG.debug('Mounted the volume.')
            self._app.install_if_needed(packages)
            LOG.info(_('Writing redis configuration.'))
            self._app.configuration_manager.save_configuration(config_contents)
            self._app.apply_initial_guestagent_configuration()
            self._app.restart()
            LOG.info(_('Redis instance has been setup and configured.'))
        except Exception:
            LOG.exception(_("Error setting up Redis instance."))
            self._app.status.set_status(rd_instance.ServiceStatuses.FAILED)
            raise RuntimeError("prepare call has failed.")

    def restart(self, context):
        """
        Restart this redis instance.
        This method is called when the guest agent
        gets a restart message from the taskmanager.
        """
        LOG.debug("Restart called.")
        self._app.restart()

    def start_db_with_conf_changes(self, context, config_contents):
        """
        Start this redis instance with new conf changes.
        """
        LOG.debug("Start DB with conf changes called.")
        self._app.start_db_with_conf_changes(config_contents)

    def stop_db(self, context, do_not_start_on_reboot=False):
        """
        Stop this redis instance.
        This method is called when the guest agent
        gets a stop message from the taskmanager.
        """
        LOG.debug("Stop DB called.")
        self._app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)

    def get_filesystem_stats(self, context, fs_path):
        """Gets the filesystem stats for the path given."""
        LOG.debug("Get Filesystem Stats.")
        mount_point = CONF.get(
            'mysql' if not MANAGER else MANAGER).mount_point
        return dbaas.get_filesystem_volume_stats(mount_point)

    def create_backup(self, context, backup_info):
        """
        This will eventually create a backup. Right now
        it does nothing.
        """
        LOG.debug("Create Backup called.")
        raise exception.DatastoreOperationNotSupported(
            operation='create_backup', datastore=MANAGER)

    def mount_volume(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.mount(mount_point, write_to_fstab=False)
        LOG.debug("Mounted the device %s at the mount point %s." %
                  (device_path, mount_point))

    def unmount_volume(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.unmount(mount_point)
        LOG.debug("Unmounted the device %s from the mount point %s." %
                  (device_path, mount_point))

    def resize_fs(self, context, device_path=None, mount_point=None):
        device = volume.VolumeDevice(device_path)
        device.resize_fs(mount_point)
        LOG.debug("Resized the filesystem at %s." % mount_point)

    def update_overrides(self, context, overrides, remove=False):
        LOG.debug("Updating overrides.")
        if remove:
            self._app.remove_overrides()
        else:
            self._app.update_overrides(context, overrides, remove)

    def apply_overrides(self, context, overrides):
        LOG.debug("Applying overrides.")
        self._app.apply_overrides(self._app.admin, overrides)

    def update_attributes(self, context, username, hostname, user_attrs):
        LOG.debug("Updating attributes.")
        raise exception.DatastoreOperationNotSupported(
            operation='update_attributes', datastore=MANAGER)

    def create_database(self, context, databases):
        LOG.debug("Creating database.")
        raise exception.DatastoreOperationNotSupported(
            operation='create_database', datastore=MANAGER)

    def create_user(self, context, users):
        LOG.debug("Creating user.")
        raise exception.DatastoreOperationNotSupported(
            operation='create_user', datastore=MANAGER)

    def delete_database(self, context, database):
        LOG.debug("Deleting database.")
        raise exception.DatastoreOperationNotSupported(
            operation='delete_database', datastore=MANAGER)

    def delete_user(self, context, user):
        LOG.debug("Deleting user.")
        raise exception.DatastoreOperationNotSupported(
            operation='delete_user', datastore=MANAGER)

    def get_user(self, context, username, hostname):
        LOG.debug("Getting user.")
        raise exception.DatastoreOperationNotSupported(
            operation='get_user', datastore=MANAGER)

    def grant_access(self, context, username, hostname, databases):
        LOG.debug("Granting access.")
        raise exception.DatastoreOperationNotSupported(
            operation='grant_access', datastore=MANAGER)

    def revoke_access(self, context, username, hostname, database):
        LOG.debug("Revoking access.")
        raise exception.DatastoreOperationNotSupported(
            operation='revoke_access', datastore=MANAGER)

    def list_access(self, context, username, hostname):
        LOG.debug("Listing access.")
        raise exception.DatastoreOperationNotSupported(
            operation='list_access', datastore=MANAGER)

    def list_databases(self, context, limit=None, marker=None,
                       include_marker=False):
        LOG.debug("Listing databases.")
        raise exception.DatastoreOperationNotSupported(
            operation='list_databases', datastore=MANAGER)

    def list_users(self, context, limit=None, marker=None,
                   include_marker=False):
        LOG.debug("Listing users.")
        raise exception.DatastoreOperationNotSupported(
            operation='list_users', datastore=MANAGER)

    def enable_root(self, context):
        LOG.debug("Enabling root.")
        raise exception.DatastoreOperationNotSupported(
            operation='enable_root', datastore=MANAGER)

    def is_root_enabled(self, context):
        LOG.debug("Checking if root is enabled.")
        raise exception.DatastoreOperationNotSupported(
            operation='is_root_enabled', datastore=MANAGER)

    def get_replication_snapshot(self, context, snapshot_info,
                                 replica_source_config=None):
        LOG.debug("Getting replication snapshot.")
        raise exception.DatastoreOperationNotSupported(
            operation='get_replication_snapshot', datastore=MANAGER)

    def attach_replication_slave(self, context, snapshot, slave_config):
        LOG.debug("Attaching replica.")
        raise exception.DatastoreOperationNotSupported(
            operation='attach_replication_slave', datastore=MANAGER)

    def detach_replica(self, context, for_failover=False):
        LOG.debug("Detaching replica.")
        raise exception.DatastoreOperationNotSupported(
            operation='detach_replica', datastore=MANAGER)

    def get_replica_context(self, context):
        raise exception.DatastoreOperationNotSupported(
            operation='get_replica_context', datastore=MANAGER)

    def make_read_only(self, context, read_only):
        raise exception.DatastoreOperationNotSupported(
            operation='make_read_only', datastore=MANAGER)

    def enable_as_master(self, context, replica_source_config):
        raise exception.DatastoreOperationNotSupported(
            operation='enable_as_master', datastore=MANAGER)

    def get_txn_count(self):
        raise exception.DatastoreOperationNotSupported(
            operation='get_txn_count', datastore=MANAGER)

    def get_latest_txn_id(self):
        raise exception.DatastoreOperationNotSupported(
            operation='get_latest_txn_id', datastore=MANAGER)

    def wait_for_txn(self, txn):
        raise exception.DatastoreOperationNotSupported(
            operation='wait_for_txn', datastore=MANAGER)

    def demote_replication_master(self, context):
        LOG.debug("Demoting replica source.")
        raise exception.DatastoreOperationNotSupported(
            operation='demote_replication_master', datastore=MANAGER)