def make_read_only(self, context, read_only): LOG.debug("Executing make_read_only(%s)" % read_only) app = MySqlApp(MySqlAppStatus.get()) app.make_read_only(read_only)
def detach_replica(self, context, for_failover=False): LOG.debug("Detaching replica.") app = MySqlApp(MySqlAppStatus.get()) replication = REPLICATION_STRATEGY_CLASS(context) replica_info = replication.detach_slave(app, for_failover) return replica_info
def get_replica_context(self, context): LOG.debug("Getting replica context.") app = MySqlApp(MySqlAppStatus.get()) replication = REPLICATION_STRATEGY_CLASS(context) replica_info = replication.get_replica_context(app) return replica_info
def get_latest_txn_id(self, context): LOG.debug("Calling get_latest_txn_id.") return MySqlApp(MySqlAppStatus.get()).get_latest_txn_id()
def wait_for_txn(self, context, txn): LOG.debug("Calling wait_for_txn.") MySqlApp(MySqlAppStatus.get()).wait_for_txn(txn)
def update_overrides(self, context, overrides, remove=False): LOG.debug("Updating overrides (%s)." % overrides) app = MySqlApp(MySqlAppStatus.get()) app.update_overrides(overrides, remove=remove)
def get_last_txn(self, context): LOG.debug("Calling get_last_txn") return MySqlApp(MySqlAppStatus.get()).get_last_txn()
def apply_overrides(self, context, overrides): LOG.debug("Applying overrides (%s)." % overrides) app = MySqlApp(MySqlAppStatus.get()) app.apply_overrides(overrides)
def enable_as_master(self, context, replica_source_config): LOG.debug("Calling enable_as_master.") app = MySqlApp(MySqlAppStatus.get()) replication = REPLICATION_STRATEGY_CLASS(context) replication.enable_as_master(app, replica_source_config)
def stop_db(self, context, do_not_start_on_reboot=False): app = MySqlApp(MySqlAppStatus.get()) app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot)
def update_overrides(self, context, overrides, remove=False): app = MySqlApp(MySqlAppStatus.get()) if remove: app.remove_overrides() app.update_overrides(overrides)
def start_db_with_conf_changes(self, context, config_contents): app = MySqlApp(MySqlAppStatus.get()) app.start_db_with_conf_changes(config_contents)
def restart(self, context): app = MySqlApp(MySqlAppStatus.get()) app.restart()
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): """Makes ready DBAAS on a Guest container.""" MySqlAppStatus.get().begin_install() # status end_mysql_install set with secure() app = MySqlApp(MySqlAppStatus.get()) app.install_if_needed(packages) if device_path: # stop and do not update database app.stop_db() 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 existing data to a "data" sub-directory # on the new volume device.migrate_data(mount_point, target_subdir="data") # mount the volume device.mount(mount_point) operating_system.chown( mount_point, service.MYSQL_OWNER, service.MYSQL_OWNER, recursive=False, as_root=True) LOG.debug("Mounted the volume at %s." % mount_point) # We need to temporarily update the default my.cnf so that # mysql will start after the volume is mounted. Later on it # will be changed based on the config template # (see MySqlApp.secure()) and restart. app.set_data_dir(mount_point + '/data') app.start_mysql() if backup_info: self._perform_restore(backup_info, context, mount_point + "/data", app) LOG.debug("Securing MySQL now.") app.secure(config_contents, overrides) enable_root_on_restore = (backup_info and MySqlAdmin().is_root_enabled()) if root_password and not backup_info: app.secure_root(secure_remote_root=True) MySqlAdmin().enable_root(root_password) elif enable_root_on_restore: app.secure_root(secure_remote_root=False) MySqlAppStatus.get().report_root(context, 'root') else: app.secure_root(secure_remote_root=True) app.complete_install_or_restart() if databases: self.create_database(context, databases) if users: self.create_user(context, users) if snapshot: self.attach_replica(context, snapshot, snapshot['config']) LOG.info(_('Completed setup of MySQL database instance.'))
def demote_replication_master(self, context): LOG.debug("Demoting replication master.") app = MySqlApp(MySqlAppStatus.get()) replication = REPLICATION_STRATEGY_CLASS(context) replication.demote_master(app)
def get_txn_count(self, context): LOG.debug("Calling get_txn_count") return MySqlApp(MySqlAppStatus.get()).get_txn_count()
def reset_configuration(self, context, configuration): app = MySqlApp(MySqlAppStatus.get()) app.reset_configuration(configuration)
def apply_overrides(self, context, overrides): app = MySqlApp(MySqlAppStatus.get()) app.apply_overrides(overrides)