diff options
author | Gábor Antal <antal@inf.u-szeged.hu> | 2017-02-15 15:25:47 +0100 |
---|---|---|
committer | Gábor Antal <antal@inf.u-szeged.hu> | 2017-03-06 17:47:57 +0100 |
commit | 1419875066749c797c9a39fd9bda6c2afe3c4235 (patch) | |
tree | 7d0198e48e6e4730a831792c84705d73d2c7c979 /trove/guestagent | |
parent | 3d3181f56fd3137883ef166f5a8b46dbf23118c1 (diff) | |
download | trove-1419875066749c797c9a39fd9bda6c2afe3c4235.tar.gz |
Handle log message interpolation by the logger part 9
The following directories were fixed in this commit:
- guestagent/backup
- guestagent/datastore
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.
[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I437ffa2d3d6f756c6af1f6b94781b3f03a83814f
Related-Bug: #1642552
Diffstat (limited to 'trove/guestagent')
24 files changed, 292 insertions, 271 deletions
diff --git a/trove/guestagent/backup/backupagent.py b/trove/guestagent/backup/backupagent.py index 7854035a..71ccaa52 100644 --- a/trove/guestagent/backup/backupagent.py +++ b/trove/guestagent/backup/backupagent.py @@ -114,11 +114,11 @@ class BackupAgent(object): except Exception: LOG.exception( - _("Error saving backup: %(backup_id)s.") % backup_state) + _("Error saving backup: %(backup_id)s."), backup_state) backup_state.update({'state': BackupState.FAILED}) raise finally: - LOG.info(_("Completed backup %(backup_id)s.") % backup_state) + LOG.info(_("Completed backup %(backup_id)s."), backup_state) conductor.update_backup(CONF.guest_id, sent=timeutils.float_utcnow(), **backup_state) @@ -175,8 +175,8 @@ class BackupAgent(object): LOG.debug("Restore size: %s.", content_size) except Exception: - LOG.exception(_("Error restoring backup %(id)s.") % backup_info) + LOG.exception(_("Error restoring backup %(id)s."), backup_info) raise else: - LOG.debug("Restored backup %(id)s." % backup_info) + LOG.debug("Restored backup %(id)s.", backup_info) diff --git a/trove/guestagent/datastore/experimental/cassandra/manager.py b/trove/guestagent/datastore/experimental/cassandra/manager.py index 219b2d8b..f584e16a 100644 --- a/trove/guestagent/datastore/experimental/cassandra/manager.py +++ b/trove/guestagent/datastore/experimental/cassandra/manager.py @@ -83,7 +83,7 @@ class Manager(manager.Manager): self.app.set_logging_level('OFF') else: log_level = CONF.get(self.manager_name).get('system_log_level') - LOG.debug("Enabling system log with logging level: %s" % log_level) + LOG.debug("Enabling system log with logging level: %s", log_level) self.app.set_logging_level(log_level) return False @@ -239,13 +239,13 @@ class Manager(manager.Manager): return self.app.is_root_enabled() def _perform_restore(self, backup_info, context, restore_location): - LOG.info(_("Restoring database from backup %s.") % backup_info['id']) + LOG.info(_("Restoring database from backup %s."), backup_info['id']) try: backup.restore(context, backup_info, restore_location) self.app._apply_post_restore_updates(backup_info) except Exception as e: LOG.error(e) - LOG.error(_("Error performing restore from backup %s.") % + LOG.error(_("Error performing restore from backup %s."), backup_info['id']) self.app.status.set_status(trove_instance.ServiceStatuses.FAILED) raise diff --git a/trove/guestagent/datastore/experimental/cassandra/service.py b/trove/guestagent/datastore/experimental/cassandra/service.py index a961446a..40bfaaff 100644 --- a/trove/guestagent/datastore/experimental/cassandra/service.py +++ b/trove/guestagent/datastore/experimental/cassandra/service.py @@ -379,8 +379,8 @@ class CassandraApp(object): operating_system.enable_service_on_boot(self.service_candidates) def __reset_user_password_to_default(self, username): - LOG.debug("Resetting the password of user '%s' to '%s'." - % (username, self.default_superuser_password)) + LOG.debug("Resetting the password of user '%(user)s' to '%(pw)s'.", + {'user': username, 'pw': self.default_superuser_password}) user = models.CassandraUser(username, self.default_superuser_password) with CassandraLocalhostConnection(user) as client: @@ -401,7 +401,7 @@ class CassandraApp(object): raise RuntimeError(_("Cannot change the cluster name. " "The service is not running.")) - LOG.debug("Changing the cluster name to '%s'." % cluster_name) + LOG.debug("Changing the cluster name to '%s'.", cluster_name) # Update the in-database value. self.__reset_cluster_name(cluster_name) @@ -444,8 +444,8 @@ class CassandraApp(object): LOG.warning( _("Trove administrative user has not been configured yet. " - "Using the built-in default: %s") - % models.CassandraUser.root_username) + "Using the built-in default: %s"), + models.CassandraUser.root_username) return models.CassandraUser(models.CassandraUser.root_username, self.default_superuser_password) @@ -604,7 +604,7 @@ class CassandraApp(object): return config['rack'] def set_seeds(self, seeds): - LOG.debug("Setting seed nodes: %s" % seeds) + LOG.debug("Setting seed nodes: %s", seeds) updates = { 'seed_provider': {'parameters': [{'seeds': ','.join(seeds)}] @@ -638,7 +638,7 @@ class CassandraApp(object): without data. It must be turned back ON once the cluster is initialized. """ - LOG.debug("Setting auto-bootstrapping: %s" % enabled) + LOG.debug("Setting auto-bootstrapping: %s", enabled) updates = {'auto_bootstrap': enabled} self.configuration_manager.apply_system_override(updates) @@ -827,7 +827,7 @@ class CassandraAdmin(object): def _create_user(self, client, user): # Create only NOSUPERUSER accounts here. - LOG.debug("Creating a new user '%s'." % user.name) + LOG.debug("Creating a new user '%s'.", user.name) client.execute("CREATE USER '{}' WITH PASSWORD %s NOSUPERUSER;", (user.name,), (user.password,)) @@ -835,7 +835,7 @@ class CassandraAdmin(object): """Create a new superuser account and grant it full superuser-level access to all keyspaces. """ - LOG.debug("Creating a new superuser '%s'." % user.name) + LOG.debug("Creating a new superuser '%s'.", user.name) self.client.execute("CREATE USER '{}' WITH PASSWORD %s SUPERUSER;", (user.name,), (user.password,)) self.client.execute( @@ -848,7 +848,7 @@ class CassandraAdmin(object): self._drop_user(self.client, user) def _drop_user(self, client, user): - LOG.debug("Deleting user '%s'." % user.name) + LOG.debug("Deleting user '%s'.", user.name) client.execute("DROP USER '{}';", (user.name, )) def get_user(self, context, username, hostname): @@ -1010,8 +1010,10 @@ class CassandraAdmin(object): Grant a non-superuser permission on a keyspace to a given user. Raise an exception if the caller attempts to grant a superuser access. """ - LOG.debug("Granting '%s' access on '%s' to user '%s'." - % (modifier, keyspace.name, user.name)) + LOG.debug("Granting '%(mod)s' access on '%(keyspace_name)s' to " + "user '%(user)s'.", + {'mod': modifier, 'keyspace_name': keyspace.name, + 'user': user.name}) if modifier in self.__NO_SUPERUSER_MODIFIERS: client.execute("GRANT {} ON KEYSPACE \"{}\" TO '{}';", (modifier, keyspace.name, user.name)) @@ -1026,8 +1028,9 @@ class CassandraAdmin(object): user.check_reserved() keyspace.check_reserved() - LOG.debug("Revoking all permissions on '%s' from user '%s'." - % (keyspace.name, user.name)) + LOG.debug("Revoking all permissions on '%(keyspace_name)s' " + "from user '%(user)s'.", {'keyspace_name': keyspace.name, + 'user': user.name}) client.execute("REVOKE ALL PERMISSIONS ON KEYSPACE \"{}\" FROM '{}';", (keyspace.name, user.name)) @@ -1065,7 +1068,8 @@ class CassandraAdmin(object): Transfer the current permissions to the new username. Drop the old username therefore revoking its permissions. """ - LOG.debug("Renaming user '%s' to '%s'" % (user.name, new_username)) + LOG.debug("Renaming user '%(old)s' to '%(new)s'", + {'old': user.name, 'new': new_username}) new_user = models.CassandraUser(new_username, new_password) new_user.databases.extend(user.databases) self._create_user_and_grant(client, new_user) @@ -1080,7 +1084,7 @@ class CassandraAdmin(object): self._deserialize_user(user)) def _alter_user_password(self, client, user): - LOG.debug("Changing password of user '%s'." % user.name) + LOG.debug("Changing password of user '%s'.", user.name) client.execute("ALTER USER '{}' " "WITH PASSWORD %s;", (user.name,), (user.password,)) @@ -1118,7 +1122,7 @@ class CassandraAdmin(object): self._deserialize_keyspace(database)) def _drop_keyspace(self, client, keyspace): - LOG.debug("Dropping keyspace '%s'." % keyspace.name) + LOG.debug("Dropping keyspace '%s'.", keyspace.name) client.execute("DROP KEYSPACE \"{}\";", (keyspace.name,)) def list_databases(self, context, limit=None, marker=None, @@ -1240,17 +1244,19 @@ class CassandraConnection(object): def _connect(self): if not self._cluster.is_shutdown: - LOG.debug("Connecting to a Cassandra cluster as '%s'." - % self.__user.name) + LOG.debug("Connecting to a Cassandra cluster as '%s'.", + self.__user.name) if not self.is_active(): self.__session = self._cluster.connect() else: LOG.debug("Connection already open.") - LOG.debug("Connected to cluster: '%s'" - % self._cluster.metadata.cluster_name) + LOG.debug("Connected to cluster: '%s'", + self._cluster.metadata.cluster_name) for host in self._cluster.metadata.all_hosts(): - LOG.debug("Connected to node: '%s' in rack '%s' at datacenter " - "'%s'" % (host.address, host.rack, host.datacenter)) + LOG.debug("Connected to node: '%(address)s' in rack " + "'%(rack)s' at datacenter '%(datacenter)s'", + {'address': host.address, 'rack': host.rack, + 'datacenter': host.datacenter}) else: LOG.debug("Cannot perform this operation on a terminated cluster.") raise exception.UnprocessableEntity() @@ -1258,8 +1264,8 @@ class CassandraConnection(object): def _disconnect(self): if self.is_active(): try: - LOG.debug("Disconnecting from cluster: '%s'" - % self._cluster.metadata.cluster_name) + LOG.debug("Disconnecting from cluster: '%s'", + self._cluster.metadata.cluster_name) self._cluster.shutdown() except Exception: LOG.debug("Failed to disconnect from a Cassandra cluster.") diff --git a/trove/guestagent/datastore/experimental/couchbase/manager.py b/trove/guestagent/datastore/experimental/couchbase/manager.py index daeede87..e34c323f 100644 --- a/trove/guestagent/datastore/experimental/couchbase/manager.py +++ b/trove/guestagent/datastore/experimental/couchbase/manager.py @@ -59,7 +59,7 @@ class Manager(manager.Manager): device.unmount_device(device_path) device.format() device.mount(mount_point) - LOG.debug('Mounted the volume (%s).' % device_path) + LOG.debug('Mounted the volume (%s).', device_path) self.app.start_db_with_conf_changes(config_contents) LOG.debug('Securing couchbase now.') self.app.initial_setup() @@ -104,12 +104,11 @@ class Manager(manager.Manager): Restores all couchbase buckets and their documents from the backup. """ - LOG.info(_("Restoring database from backup %s") % - backup_info['id']) + LOG.info(_("Restoring database from backup %s"), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception as e: - LOG.error(_("Error performing restore from backup %s") % + LOG.error(_("Error performing restore from backup %s"), backup_info['id']) LOG.error(e) self.status.set_status(rd_instance.ServiceStatuses.FAILED) diff --git a/trove/guestagent/datastore/experimental/couchbase/service.py b/trove/guestagent/datastore/experimental/couchbase/service.py index be5cfaf8..d33bed75 100644 --- a/trove/guestagent/datastore/experimental/couchbase/service.py +++ b/trove/guestagent/datastore/experimental/couchbase/service.py @@ -98,7 +98,7 @@ class CouchbaseApp(object): """ Install the Couchbase Server. """ - LOG.debug('Installing Couchbase Server. Creating %s' % + LOG.debug('Installing Couchbase Server. Creating %s', system.COUCHBASE_CONF_DIR) operating_system.create_directory(system.COUCHBASE_CONF_DIR, as_root=True) @@ -126,10 +126,10 @@ class CouchbaseApp(object): def start_db_with_conf_changes(self, config_contents): LOG.info(_("Starting Couchbase with configuration changes.\n" - "Configuration contents:\n %s.") % config_contents) + "Configuration contents:\n %s."), config_contents) if self.status.is_running: LOG.error(_("Cannot start Couchbase with configuration changes. " - "Couchbase state == %s.") % self.status) + "Couchbase state == %s."), self.status) raise RuntimeError(_("Couchbase is not stopped.")) self._write_config(config_contents) self.start_db(True) diff --git a/trove/guestagent/datastore/experimental/couchdb/manager.py b/trove/guestagent/datastore/experimental/couchdb/manager.py index 3479b120..43f5c4f0 100644 --- a/trove/guestagent/datastore/experimental/couchdb/manager.py +++ b/trove/guestagent/datastore/experimental/couchdb/manager.py @@ -57,7 +57,7 @@ class Manager(manager.Manager): if os.path.exists(mount_point): device.migrate_data(mount_point) device.mount(mount_point) - LOG.debug('Mounted the volume (%s).' % device_path) + LOG.debug('Mounted the volume (%s).', device_path) self.app.start_db() self.app.change_permissions() self.app.make_host_reachable() @@ -92,12 +92,12 @@ class Manager(manager.Manager): Restores all CouchDB databases and their documents from the backup. """ - LOG.info(_("Restoring database from backup %s") % + LOG.info(_("Restoring database from backup %s"), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception: - LOG.exception(_("Error performing restore from backup %s") % + LOG.exception(_("Error performing restore from backup %s"), backup_info['id']) self.status.set_status(rd_instance.ServiceStatuses.FAILED) raise @@ -127,7 +127,7 @@ class Manager(manager.Manager): return service.CouchDBAdmin().list_users(limit, marker, include_marker) def get_user(self, context, username, hostname): - LOG.debug("Show details of user %s." % username) + LOG.debug("Show details of user %s.", username) return service.CouchDBAdmin().get_user(username, hostname) def grant_access(self, context, username, hostname, databases): diff --git a/trove/guestagent/datastore/experimental/couchdb/service.py b/trove/guestagent/datastore/experimental/couchdb/service.py index 4ffe61ce..534c1766 100644 --- a/trove/guestagent/datastore/experimental/couchdb/service.py +++ b/trove/guestagent/datastore/experimental/couchdb/service.py @@ -56,7 +56,7 @@ class CouchDBApp(object): state_change_wait_time if state_change_wait_time else CONF.state_change_wait_time ) - LOG.debug("state_change_wait_time = %s." % self.state_change_wait_time) + LOG.debug("state_change_wait_time = %s.", self.state_change_wait_time) self.status = status def install_if_needed(self, packages): @@ -65,7 +65,7 @@ class CouchDBApp(object): """ LOG.info(_('Preparing guest as a CouchDB server.')) if not packager.pkg_is_installed(packages): - LOG.debug("Installing packages: %s." % str(packages)) + LOG.debug("Installing packages: %s.", str(packages)) packager.pkg_install(packages, {}, system.TIME_OUT) LOG.info(_("Finished installing CouchDB server.")) @@ -175,7 +175,7 @@ class CouchDBAppStatus(service.BaseDbStatus): out, err = utils.execute_with_timeout( system.COUCHDB_SERVER_STATUS, shell=True ) - LOG.debug("CouchDB status = %r" % out) + LOG.debug("CouchDB status = %r", out) server_status = json.loads(out) status = server_status["couchdb"] if status == 'Welcome': @@ -220,7 +220,7 @@ class CouchDBAdmin(object): for item in users: user = models.CouchDBUser.deserialize(item) try: - LOG.debug("Creating user: %s." % user.name) + LOG.debug("Creating user: %s.", user.name) utils.execute_with_timeout( system.CREATE_USER_COMMAND % {'admin_name': self._admin_user().name, @@ -230,14 +230,15 @@ class CouchDBAdmin(object): 'password': user.password}, shell=True) except exception.ProcessExecutionError as pe: - LOG.exception(_("Error creating user: %s.") % user.name) + LOG.exception(_("Error creating user: %s."), user.name) pass for database in user.databases: mydb = models.CouchDBSchema.deserialize(database) try: - LOG.debug("Granting user: %s access to database: %s." - % (user.name, mydb.name)) + LOG.debug("Granting user: %(user)s access to " + "database: %(db)s.", + {'user': user.name, 'db': mydb.name}) out, err = utils.execute_with_timeout( system.GRANT_ACCESS_COMMAND % {'admin_name': self._admin_user().name, @@ -246,12 +247,13 @@ class CouchDBAdmin(object): 'username': user.name}, shell=True) except exception.ProcessExecutionError as pe: - LOG.debug("Error granting user: %s access to" - "database: %s." % (user.name, mydb.name)) + LOG.debug("Error granting user: %(user)s access to" + "database: %(db)s.", + {'user': user.name, 'db': mydb.name}) LOG.debug(pe) pass except exception.ProcessExecutionError as pe: - LOG.exception(_("An error occurred creating users: %s.") % + LOG.exception(_("An error occurred creating users: %s."), pe.message) pass @@ -271,7 +273,7 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError: LOG.debug( - "Error while trying to get the users for database: %s." % + "Error while trying to get the users for database: %s.", db) continue @@ -317,7 +319,7 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError as pe: LOG.exception(_( - "There was an error while deleting user: %s.") % pe) + "There was an error while deleting user: %s."), pe) raise exception.GuestError(original_message=_( "Unable to delete user: %s.") % couchdb_user.name) @@ -355,8 +357,8 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError: LOG.debug( - "Error while trying to get users for database: %s." - % db) + "Error while trying to get users for database: %s.", + db) continue evalout2 = ast.literal_eval(out2) if evalout2: @@ -371,7 +373,7 @@ class CouchDBAdmin(object): def get_user(self, username, hostname): '''Get Information about the given user.''' - LOG.debug('Getting user %s.' % username) + LOG.debug('Getting user %s.', username) user = self._get_user(username, hostname) if not user: return None @@ -390,7 +392,7 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError: LOG.debug( - "Error while trying to get the users for database: %s." % + "Error while trying to get the users for database: %s.", db) continue @@ -412,7 +414,7 @@ class CouchDBAdmin(object): user = models.CouchDBUser(username) if not self._is_modifiable_user(user.name): LOG.warning(_('Cannot grant access for reserved user ' - '%(user)s') % {'user': username}) + '%(user)s'), {'user': username}) if not user: raise exception.BadRequest(_( 'Cannot grant access for reserved or non-existant user ' @@ -488,7 +490,7 @@ class CouchDBAdmin(object): for database in databases: dbName = models.CouchDBSchema.deserialize(database).name if self._is_modifiable_database(dbName): - LOG.debug('Creating CouchDB database %s' % dbName) + LOG.debug('Creating CouchDB database %s', dbName) try: utils.execute_with_timeout( system.CREATE_DB_COMMAND % @@ -498,15 +500,15 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError: LOG.exception(_( - "There was an error creating database: %s.") % dbName) + "There was an error creating database: %s."), dbName) db_create_failed.append(dbName) pass else: LOG.warning(_('Cannot create database with a reserved name ' - '%(db)s') % {'db': dbName}) + '%(db)s'), {'db': dbName}) db_create_failed.append(dbName) if len(db_create_failed) > 0: - LOG.exception(_("Creating the following databases failed: %s.") % + LOG.exception(_("Creating the following databases failed: %s."), db_create_failed) def list_database_names(self): @@ -538,7 +540,7 @@ class CouchDBAdmin(object): dbName = models.CouchDBSchema.deserialize(database).name if self._is_modifiable_database(dbName): try: - LOG.debug("Deleting CouchDB database: %s." % dbName) + LOG.debug("Deleting CouchDB database: %s.", dbName) utils.execute_with_timeout( system.DELETE_DB_COMMAND % {'admin_name': self._admin_user().name, @@ -547,12 +549,12 @@ class CouchDBAdmin(object): shell=True) except exception.ProcessExecutionError: LOG.exception(_( - "There was an error while deleting database:%s.") % dbName) + "There was an error while deleting database:%s."), dbName) raise exception.GuestError(original_message=_( "Unable to delete database: %s.") % dbName) else: LOG.warning(_('Cannot delete a reserved database ' - '%(db)s') % {'db': dbName}) + '%(db)s'), {'db': dbName}) class CouchDBCredentials(object): @@ -576,7 +578,7 @@ class CouchDBCredentials(object): @staticmethod def clear_file(filename): - LOG.debug("Creating clean file %s" % filename) + LOG.debug("Creating clean file %s", filename) if operating_system.file_discovery([filename]): operating_system.remove(filename) # force file creation by just opening it diff --git a/trove/guestagent/datastore/experimental/db2/manager.py b/trove/guestagent/datastore/experimental/db2/manager.py index c45ce562..0aa33fbf 100644 --- a/trove/guestagent/datastore/experimental/db2/manager.py +++ b/trove/guestagent/datastore/experimental/db2/manager.py @@ -89,12 +89,12 @@ class Manager(manager.Manager): self.app.stop_db(do_not_start_on_reboot=do_not_start_on_reboot) def create_database(self, context, databases): - LOG.debug("Creating database(s)." % databases) + LOG.debug("Creating database(s) %s.", databases) with EndNotification(context): self.admin.create_database(databases) def delete_database(self, context, database): - LOG.debug("Deleting database %s." % database) + LOG.debug("Deleting database %s.", database) with EndNotification(context): return self.admin.delete_database(database) @@ -109,12 +109,12 @@ class Manager(manager.Manager): self.admin.create_user(users) def delete_user(self, context, user): - LOG.debug("Delete a user %s." % user) + LOG.debug("Delete a user %s.", user) with EndNotification(context): self.admin.delete_user(user) def get_user(self, context, username, hostname): - LOG.debug("Show details of user %s." % username) + LOG.debug("Show details of user %s.", username) return self.admin.get_user(username, hostname) def list_users(self, context, limit=None, marker=None, @@ -131,11 +131,11 @@ class Manager(manager.Manager): self.app.start_db_with_conf_changes(config_contents) def _perform_restore(self, backup_info, context, restore_location): - LOG.info(_("Restoring database from backup %s.") % backup_info['id']) + LOG.info(_("Restoring database from backup %s."), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception: - LOG.exception(_("Error performing restore from backup %s.") % + LOG.exception(_("Error performing restore from backup %s."), backup_info['id']) self.status.set_status(ds_instance.ServiceStatuses.FAILED) raise @@ -154,5 +154,5 @@ class Manager(manager.Manager): def apply_overrides(self, context, overrides): if overrides: - LOG.debug("Applying overrides: " + str(overrides)) + LOG.debug("Applying overrides: %s", str(overrides)) self.app.apply_overrides(overrides) diff --git a/trove/guestagent/datastore/experimental/db2/service.py b/trove/guestagent/datastore/experimental/db2/service.py index c14005e7..8bca135f 100644 --- a/trove/guestagent/datastore/experimental/db2/service.py +++ b/trove/guestagent/datastore/experimental/db2/service.py @@ -50,7 +50,7 @@ class DB2App(object): state_change_wait_time if state_change_wait_time else CONF.state_change_wait_time ) - LOG.debug("state_change_wait_time = %s." % self.state_change_wait_time) + LOG.debug("state_change_wait_time = %s.", self.state_change_wait_time) self.status = status self.dbm_default_config = {} self.init_config() @@ -275,7 +275,7 @@ class DB2App(object): "parameter": param, "value": value}) except exception.ProcessExecutionError: - LOG.exception(_("Failed to update config %s") % param) + LOG.exception(_("Failed to update config %s"), param) raise def _reset_config(self, config): @@ -349,12 +349,12 @@ class DB2Admin(object): mydb = models.DatastoreSchema.deserialize(item) mydb.check_create() dbName = mydb.name - LOG.debug("Creating DB2 database: %s." % dbName) + LOG.debug("Creating DB2 database: %s.", dbName) try: run_command(system.CREATE_DB_COMMAND % {'dbname': dbName}) except exception.ProcessExecutionError: LOG.exception(_( - "There was an error creating database: %s.") % dbName) + "There was an error creating database: %s."), dbName) db_create_failed.append(dbName) pass @@ -375,10 +375,10 @@ class DB2Admin(object): except exception.ProcessExecutionError: LOG.exception(_( "There was an error while configuring the database for " - "online backup: %s.") % dbName) + "online backup: %s."), dbName) if len(db_create_failed) > 0: - LOG.exception(_("Creating the following databases failed: %s.") % + LOG.exception(_("Creating the following databases failed: %s."), db_create_failed) def delete_database(self, database): @@ -388,11 +388,11 @@ class DB2Admin(object): mydb = models.DatastoreSchema.deserialize(database) mydb.check_delete() dbName = mydb.name - LOG.debug("Deleting DB2 database: %s." % dbName) + LOG.debug("Deleting DB2 database: %s.", dbName) run_command(system.DELETE_DB_COMMAND % {'dbname': dbName}) except exception.ProcessExecutionError: LOG.exception(_( - "There was an error while deleting database:%s.") % dbName) + "There was an error while deleting database:%s."), dbName) raise exception.GuestError(original_message=_( "Unable to delete database: %s.") % dbName) @@ -424,7 +424,7 @@ class DB2Admin(object): count = count + 1 if (limit and count <= limit) or limit is None: db2_db = models.DatastoreSchema(name=item) - LOG.debug("database = %s ." % item) + LOG.debug("database = %s .", item) next_marker = db2_db.name databases.append(db2_db.serialize()) item = next(result) @@ -433,10 +433,10 @@ class DB2Admin(object): break except StopIteration: next_marker = None - LOG.debug("databases = %s." % str(databases)) + LOG.debug("databases = %s.", str(databases)) except exception.ProcessExecutionError as pe: err_msg = encodeutils.exception_to_unicode(pe) - LOG.exception(_("An error occurred listing databases: %s.") % + LOG.exception(_("An error occurred listing databases: %s."), err_msg) pass return databases, next_marker @@ -448,30 +448,31 @@ class DB2Admin(object): user = models.DatastoreUser.deserialize(item) user.check_create() try: - LOG.debug("Creating OS user: %s." % user.name) + LOG.debug("Creating OS user: %s.", user.name) utils.execute_with_timeout( system.CREATE_USER_COMMAND % { 'login': user.name, 'login': user.name, 'passwd': user.password}, shell=True) except exception.ProcessExecutionError as pe: - LOG.exception(_("Error creating user: %s.") % user.name) + LOG.exception(_("Error creating user: %s."), user.name) continue for database in user.databases: mydb = models.DatastoreSchema.deserialize(database) try: - LOG.debug("Granting user: %s access to database: %s." - % (user.name, mydb.name)) + LOG.debug("Granting user: %(user)s access to " + "database: %(db)s.", + {'user': user.name, 'db': mydb.name}) run_command(system.GRANT_USER_ACCESS % { 'dbname': mydb.name, 'login': user.name}) except exception.ProcessExecutionError as pe: - LOG.debug( - "Error granting user: %s access to database: %s." - % (user.name, mydb.name)) + LOG.debug("Error granting user: %(user)s access to " + "database: %(db)s.", + {'user': user.name, 'db': mydb.name}) LOG.debug(pe) pass except exception.ProcessExecutionError as pe: - LOG.exception(_("An error occurred creating users: %s.") % + LOG.exception(_("An error occurred creating users: %s."), pe.message) pass @@ -481,25 +482,26 @@ class DB2Admin(object): db2_user.check_delete() userName = db2_user.name user_dbs = db2_user.databases - LOG.debug("For user %s, databases to be deleted = %r." % ( - userName, user_dbs)) + LOG.debug("For user %(user)s, databases to be deleted = %(dbs)r.", + {'user': userName, 'dbs': user_dbs}) if len(user_dbs) == 0: databases = self.list_access(db2_user.name, None) else: databases = user_dbs - LOG.debug("databases for user = %r." % databases) + LOG.debug("databases for user = %r.", databases) for database in databases: mydb = models.DatastoreSchema.deserialize(database) try: run_command(system.REVOKE_USER_ACCESS % { 'dbname': mydb.name, 'login': userName}) - LOG.debug("Revoked access for user:%s on database:%s." % ( - userName, mydb.name)) + LOG.debug("Revoked access for user:%(user)s on " + "database:%(db)s.", + {'user': userName, 'db': mydb.name}) except exception.ProcessExecutionError as pe: - LOG.debug("Error occurred while revoking access to %s." % + LOG.debug("Error occurred while revoking access to %s.", mydb.name) pass try: @@ -507,7 +509,7 @@ class DB2Admin(object): 'login': db2_user.name.lower()}, shell=True) except exception.ProcessExecutionError as pe: LOG.exception(_( - "There was an error while deleting user: %s.") % pe) + "There was an error while deleting user: %s."), pe) raise exception.GuestError(original_message=_( "Unable to delete user: %s.") % userName) @@ -528,15 +530,15 @@ class DB2Admin(object): system.LIST_DB_USERS % {'dbname': db2_db.name}) except exception.ProcessExecutionError: LOG.debug( - "There was an error while listing users for database: %s." - % db2_db.name) + "There was an error while listing users for database: %s.", + db2_db.name) continue userlist = [] for item in out.split('\n'): - LOG.debug("item = %r" % item) + LOG.debug("item = %r", item) user = item.split() if item != "" else None - LOG.debug("user = %r" % (user)) + LOG.debug("user = %r", user) if (user is not None and (user[0] not in cfg.get_ignored_users() and user[1] == 'Y')): @@ -596,7 +598,7 @@ class DB2Admin(object): return user.serialize() def _get_user(self, username, hostname): - LOG.debug("Get details of a given database user %s." % username) + LOG.debug("Get details of a given database user %s.", username) user = models.DatastoreUser(name=username) databases, marker = self.list_databases() out = None @@ -607,7 +609,7 @@ class DB2Admin(object): system.LIST_DB_USERS % {'dbname': db2_db.name}) except exception.ProcessExecutionError: LOG.debug( - "Error while trying to get the users for database: %s." % + "Error while trying to get the users for database: %s.", db2_db.name) continue @@ -625,6 +627,6 @@ class DB2Admin(object): Show all the databases to which the user has more than USAGE granted. """ - LOG.debug("Listing databases that user: %s has access to." % username) + LOG.debug("Listing databases that user: %s has access to.", username) user = self._get_user(username, hostname) return user.databases diff --git a/trove/guestagent/datastore/experimental/mariadb/service.py b/trove/guestagent/datastore/experimental/mariadb/service.py index a851e023..f659ef99 100644 --- a/trove/guestagent/datastore/experimental/mariadb/service.py +++ b/trove/guestagent/datastore/experimental/mariadb/service.py @@ -88,7 +88,7 @@ class MariaDBApp(galera_service.GaleraApp): return self._get_gtid_executed() def wait_for_txn(self, txn): - LOG.info(_("Waiting on txn '%s'.") % txn) + LOG.info(_("Waiting on txn '%s'."), txn) with self.local_sql_client(self.get_engine()) as client: client.execute("SELECT MASTER_GTID_WAIT('%s')" % txn) diff --git a/trove/guestagent/datastore/experimental/mongodb/manager.py b/trove/guestagent/datastore/experimental/mongodb/manager.py index c4e6d5ad..defefa1b 100644 --- a/trove/guestagent/datastore/experimental/mongodb/manager.py +++ b/trove/guestagent/datastore/experimental/mongodb/manager.py @@ -69,7 +69,7 @@ class Manager(manager.Manager): system.MONGO_USER, system.MONGO_USER, as_root=True) - LOG.debug("Mounted the volume %(path)s as %(mount)s." % + LOG.debug("Mounted the volume %(path)s as %(mount)s.", {'path': device_path, "mount": mount_point}) if config_contents: @@ -182,11 +182,11 @@ class Manager(manager.Manager): return service.MongoDBAdmin().is_root_enabled() def _perform_restore(self, backup_info, context, restore_location, app): - LOG.info(_("Restoring database from backup %s.") % backup_info['id']) + LOG.info(_("Restoring database from backup %s."), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception: - LOG.exception(_("Error performing restore from backup %s.") % + LOG.exception(_("Error performing restore from backup %s."), backup_info['id']) self.status.set_status(ds_instance.ServiceStatuses.FAILED) raise @@ -211,7 +211,7 @@ class Manager(manager.Manager): def add_members(self, context, members): try: LOG.debug("add_members called.") - LOG.debug("args: members=%s." % members) + LOG.debug("args: members=%s.", members) self.app.add_members(members) LOG.debug("add_members call has finished.") except Exception: @@ -221,7 +221,7 @@ class Manager(manager.Manager): def add_config_servers(self, context, config_servers): try: LOG.debug("add_config_servers called.") - LOG.debug("args: config_servers=%s." % config_servers) + LOG.debug("args: config_servers=%s.", config_servers) self.app.add_config_servers(config_servers) LOG.debug("add_config_servers call has finished.") except Exception: @@ -231,8 +231,9 @@ class Manager(manager.Manager): def add_shard(self, context, replica_set_name, replica_set_member): try: LOG.debug("add_shard called.") - LOG.debug("args: replica_set_name=%s, replica_set_member=%s." % - (replica_set_name, replica_set_member)) + LOG.debug("args: replica_set_name=%(name)s, " + "replica_set_member=%(member)s.", + {'name': replica_set_name, 'member': replica_set_member}) self.app.add_shard(replica_set_name, replica_set_member) LOG.debug("add_shard call has finished.") except Exception: diff --git a/trove/guestagent/datastore/experimental/mongodb/service.py b/trove/guestagent/datastore/experimental/mongodb/service.py index 5986af3f..50f985a9 100644 --- a/trove/guestagent/datastore/experimental/mongodb/service.py +++ b/trove/guestagent/datastore/experimental/mongodb/service.py @@ -69,7 +69,7 @@ class MongoDBApp(object): """Prepare the guest machine with a MongoDB installation.""" LOG.info(_("Preparing Guest as MongoDB.")) if not system.PACKAGER.pkg_is_installed(packages): - LOG.debug("Installing packages: %s." % str(packages)) + LOG.debug("Installing packages: %s.", str(packages)) system.PACKAGER.pkg_install(packages, {}, system.TIME_OUT) LOG.info(_("Finished installing MongoDB server.")) @@ -144,7 +144,7 @@ class MongoDBApp(object): (e.g. PID-file). """ mongodb_run_dir = os.path.dirname(system.MONGO_PID_FILE) - LOG.debug("Initializing a runtime directory: %s" % mongodb_run_dir) + LOG.debug("Initializing a runtime directory: %s", mongodb_run_dir) operating_system.create_directory( mongodb_run_dir, user=system.MONGO_USER, group=system.MONGO_USER, force=True, as_root=True) @@ -162,7 +162,7 @@ class MongoDBApp(object): cluster_config['replica_set_name']) else: LOG.error(_("Bad cluster configuration; instance type " - "given as %s.") % cluster_config['instance_type']) + "given as %s."), cluster_config['instance_type']) return ds_instance.ServiceStatuses.FAILED if 'key' in cluster_config: @@ -236,7 +236,7 @@ class MongoDBApp(object): def clear_storage(self): mount_point = "/var/lib/mongodb/*" - LOG.debug("Clearing storage at %s." % mount_point) + LOG.debug("Clearing storage at %s.", mount_point) try: operating_system.remove(mount_point, force=True, as_root=True) except exception.ProcessExecutionError: @@ -256,7 +256,7 @@ class MongoDBApp(object): """ config_servers_string = ','.join(['%s:%s' % (host, CONFIGSVR_PORT) for host in config_server_hosts]) - LOG.info(_("Setting config servers: %s") % config_servers_string) + LOG.info(_("Setting config servers: %s"), config_servers_string) self.configuration_manager.apply_system_override( {'sharding.configDB': config_servers_string}, CNF_CLUSTER) self.start_db(True) @@ -426,10 +426,10 @@ class MongoDBApp(object): def is_shard_active(self, replica_set_name): shards = MongoDBAdmin().list_active_shards() if replica_set_name in [shard['_id'] for shard in shards]: - LOG.debug('Replica set %s is active.' % replica_set_name) + LOG.debug('Replica set %s is active.', replica_set_name) return True else: - LOG.debug('Replica set %s is not active.' % replica_set_name) + LOG.debug('Replica set %s is not active.', replica_set_name) return False @@ -501,8 +501,10 @@ class MongoDBAdmin(object): this action is valid. :param user: a MongoDBUser object """ - LOG.debug('Creating user %s on database %s with roles %s.' - % (user.username, user.database.name, str(user.roles))) + LOG.debug('Creating user %(user)s on database %(db)s with roles ' + '%(role)s.', + {'user': user.username, 'db': user.database.name, + 'role': str(user.roles)}) if client: self._create_user_with_client(user, client) else: @@ -527,15 +529,15 @@ class MongoDBAdmin(object): except (ValueError, pymongo.errors.PyMongoError) as e: LOG.error(e) LOG.warning(_('Skipping creation of user with name ' - '%(user)s') % {'user': user.name}) + '%(user)s'), {'user': user.name}) def delete_validated_user(self, user): """Deletes a user from their database. The caller should ensure that this action is valid. :param user: a MongoDBUser object """ - LOG.debug('Deleting user %s from database %s.' - % (user.username, user.database.name)) + LOG.debug('Deleting user %(user)s from database %(db)s.', + {'user': user.username, 'db': user.database.name}) with MongoDBClient(self._admin_user()) as admin_client: admin_client[user.database.name].remove_user(user.username) @@ -552,7 +554,7 @@ class MongoDBAdmin(object): user = models.MongoDBUser(name) if user.is_ignored: LOG.warning(_('Skipping retrieval of user with reserved ' - 'name %(user)s') % {'user': user.name}) + 'name %(user)s'), {'user': user.name}) return None if client: user_info = client.admin.system.users.find_one( @@ -576,7 +578,7 @@ class MongoDBAdmin(object): def get_user(self, name): """Get information for the given user.""" - LOG.debug('Getting user %s.' % name) + LOG.debug('Getting user %s.', name) user = self._get_user_record(name) if not user: return None @@ -606,13 +608,13 @@ class MongoDBAdmin(object): user.check_create() self.get_existing_user(user.name) self.create_validated_user(user, admin_client) - LOG.debug('Changing password for user %(user)s' - % {'user': user.name}) + LOG.debug('Changing password for user %(user)s', + {'user': user.name}) self._create_user_with_client(user, admin_client) except (ValueError, pymongo.errors.PyMongoError) as e: LOG.error(e) LOG.warning(_('Skipping password change for user with ' - 'name %(user)s') % {'user': user.name}) + 'name %(user)s'), {'user': user.name}) def update_attributes(self, name, user_attrs): """Update user attributes.""" @@ -658,13 +660,13 @@ class MongoDBAdmin(object): models.MongoDBSchema(db_name) role = {'db': db_name, 'role': 'readWrite'} if role not in user.roles: - LOG.debug('Adding role %s to user %s.' - % (str(role), username)) + LOG.debug('Adding role %(role)s to user %(user)s.', + {'role': str(role), 'user': username}) user.roles = role else: - LOG.debug('User %s already has role %s.' - % (username, str(role))) - LOG.debug('Updating user %s.' % username) + LOG.debug('User %(user)s already has role %(role)s.', + {'user': username, 'role': str(role)}) + LOG.debug('Updating user %s.', username) self._update_user_roles(user) def revoke_access(self, username, database): @@ -673,10 +675,10 @@ class MongoDBAdmin(object): # verify the database name models.MongoDBSchema(database) role = {'db': database, 'role': 'readWrite'} - LOG.debug('Removing role %s from user %s.' - % (str(role), username)) + LOG.debug('Removing role %(role)s from user %(user)s.', + {'role': str(role), 'user': username}) user.revoke_role(role) - LOG.debug('Updating user %s.' % username) + LOG.debug('Updating user %s.', username) self._update_user_roles(user) def list_access(self, username): @@ -695,7 +697,7 @@ class MongoDBAdmin(object): for item in databases: schema = models.MongoDBSchema.deserialize(item) schema.check_create() - LOG.debug('Creating MongoDB database %s' % schema.name) + LOG.debug('Creating MongoDB database %s', schema.name) db = admin_client[schema.name] db[tmp].insert({'dummy': True}) db.drop_collection(tmp) @@ -733,7 +735,7 @@ class MongoDBAdmin(object): """Runs the replSetGetStatus command.""" with MongoDBClient(self._admin_user()) as admin_client: status = admin_client.admin.command('replSetGetStatus') - LOG.debug('Replica set status: %s' % status) + LOG.debug('Replica set status: %s', status) return status def rs_initiate(self): @@ -795,15 +797,15 @@ class MongoDBClient(object): if new_client: host = type(self).engine['host'] port = type(self).engine['port'] - LOG.debug("Creating MongoDB client to %(host)s:%(port)s." - % {'host': host, 'port': port}) + LOG.debug("Creating MongoDB client to %(host)s:%(port)s.", + {'host': host, 'port': port}) type(self).engine['client'] = pymongo.MongoClient(host=host, port=port, connect=False) self.session = type(self).engine['client'] if user: db_name = user.database.name - LOG.debug("Authenticating MongoDB client on %s." % db_name) + LOG.debug("Authenticating MongoDB client on %s.", db_name) self._db = self.session[db_name] self._db.authenticate(user.username, password=user.password) self._logged_in = True diff --git a/trove/guestagent/datastore/experimental/percona/service.py b/trove/guestagent/datastore/experimental/percona/service.py index b65e0758..cfcb88b8 100644 --- a/trove/guestagent/datastore/experimental/percona/service.py +++ b/trove/guestagent/datastore/experimental/percona/service.py @@ -67,7 +67,7 @@ class MySqlApp(service.BaseMySqlApp): return self._get_gtid_executed() def wait_for_txn(self, txn): - LOG.info(_("Waiting on txn '%s'.") % txn) + LOG.info(_("Waiting on txn '%s'."), txn) with self.local_sql_client(self.get_engine()) as client: client.execute("SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('%s')" % txn) diff --git a/trove/guestagent/datastore/experimental/postgresql/manager.py b/trove/guestagent/datastore/experimental/postgresql/manager.py index 33a1d474..64d9864b 100644 --- a/trove/guestagent/datastore/experimental/postgresql/manager.py +++ b/trove/guestagent/datastore/experimental/postgresql/manager.py @@ -234,7 +234,7 @@ class Manager(manager.Manager): self.app.set_current_admin_user(os_admin) if snapshot: - LOG.info(_("Found snapshot info: ") + str(snapshot)) + LOG.info(_("Found snapshot info: %s"), str(snapshot)) self.attach_replica(context, snapshot, snapshot['config']) self.app.start_db() @@ -284,7 +284,7 @@ class Manager(manager.Manager): lsn = self.app.pg_last_xlog_replay_location() else: lsn = self.app.pg_current_xlog_location() - LOG.info(_("Last xlog location found: %s") % lsn) + LOG.info(_("Last xlog location found: %s"), lsn) return lsn def get_last_txn(self, context): @@ -299,7 +299,7 @@ class Manager(manager.Manager): def _wait_for_txn(): lsn = self.app.pg_last_xlog_replay_location() - LOG.info(_("Last xlog location found: %s") % lsn) + LOG.info(_("Last xlog location found: %s"), lsn) return lsn >= txn try: utils.poll_until(_wait_for_txn, time_out=120) diff --git a/trove/guestagent/datastore/experimental/redis/manager.py b/trove/guestagent/datastore/experimental/redis/manager.py index 3e111056..5b67783f 100644 --- a/trove/guestagent/datastore/experimental/redis/manager.py +++ b/trove/guestagent/datastore/experimental/redis/manager.py @@ -50,11 +50,11 @@ class Manager(manager.Manager): def _perform_restore(self, backup_info, context, restore_location, app): """Perform a restore on this instance.""" - LOG.info(_("Restoring database from backup %s.") % backup_info['id']) + LOG.info(_("Restoring database from backup %s."), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception: - LOG.exception(_("Error performing restore from backup %s.") % + LOG.exception(_("Error performing restore from backup %s."), backup_info['id']) app.status.set_status(rd_instance.ServiceStatuses.FAILED) raise @@ -196,7 +196,7 @@ class Manager(manager.Manager): raise def make_read_only(self, context, read_only): - LOG.debug("Executing make_read_only(%s)" % read_only) + LOG.debug("Executing make_read_only(%s)", read_only) self._app.make_read_only(read_only) def _get_repl_info(self): @@ -208,10 +208,11 @@ class Manager(manager.Manager): def _get_repl_offset(self): repl_info = self._get_repl_info() - LOG.debug("Got repl info: %s" % repl_info) + LOG.debug("Got repl info: %s", repl_info) offset_key = '%s_repl_offset' % repl_info['role'] offset = repl_info[offset_key] - LOG.debug("Found offset %s for key %s." % (offset, offset_key)) + LOG.debug("Found offset %(offset)s for key %(key)s.", + {'offset': offset, 'key': offset_key}) return int(offset) def get_last_txn(self, context): @@ -224,11 +225,11 @@ class Manager(manager.Manager): return self._get_repl_offset() def wait_for_txn(self, context, txn): - LOG.info(_("Waiting on repl offset '%s'.") % txn) + LOG.info(_("Waiting on repl offset '%s'."), txn) def _wait_for_txn(): current_offset = self._get_repl_offset() - LOG.debug("Current offset: %s." % current_offset) + LOG.debug("Current offset: %s.", current_offset) return current_offset >= txn try: diff --git a/trove/guestagent/datastore/experimental/redis/service.py b/trove/guestagent/datastore/experimental/redis/service.py index 4b3d86a8..8c3c158b 100644 --- a/trove/guestagent/datastore/experimental/redis/service.py +++ b/trove/guestagent/datastore/experimental/redis/service.py @@ -125,8 +125,7 @@ class RedisApp(object): Install the redis server. """ LOG.debug('Installing redis server.') - msg = "Creating %s." % system.REDIS_CONF_DIR - LOG.debug(msg) + LOG.debug("Creating %s.", system.REDIS_CONF_DIR) operating_system.create_directory(system.REDIS_CONF_DIR, as_root=True) pkg_opts = {} packager.pkg_install(packages, pkg_opts, TIME_OUT) @@ -443,7 +442,7 @@ class RedisAdmin(object): elif not self.__client.save(): raise exception.BackupCreationError(_("Could not persist " "Redis data (%s)") % save_cmd) - LOG.debug("Redis data persist (%s) completed" % save_cmd) + LOG.debug("Redis data persist (%s) completed", save_cmd) def set_master(self, host=None, port=None): self.__client.slaveof(host, port) @@ -476,15 +475,17 @@ class RedisAdmin(object): def wait_until(self, key, wait_value, section=None, timeout=None): """Polls redis until the specified 'key' changes to 'wait_value'.""" timeout = timeout or CONF.usage_timeout - LOG.debug("Waiting for Redis '%s' to be: %s." % (key, wait_value)) + LOG.debug("Waiting for Redis '%(key)s' to be: %(value)s.", + {'key': key, 'value': wait_value}) def _check_info(): redis_info = self.get_info(section) if key in redis_info: current_value = redis_info[key] - LOG.debug("Found '%s' for field %s." % (current_value, key)) + LOG.debug("Found '%(value)s' for field %(key)s.", + {'value': current_value, 'key': key}) else: - LOG.error(_('Output from Redis command: %s') % redis_info) + LOG.error(_('Output from Redis command: %s'), redis_info) raise RuntimeError(_("Field %(field)s not found " "(Section: '%(sec)s').") % ({'field': key, 'sec': section})) diff --git a/trove/guestagent/datastore/experimental/vertica/manager.py b/trove/guestagent/datastore/experimental/vertica/manager.py index 7fabeb01..58c62992 100644 --- a/trove/guestagent/datastore/experimental/vertica/manager.py +++ b/trove/guestagent/datastore/experimental/vertica/manager.py @@ -101,16 +101,16 @@ class Manager(manager.Manager): self.app.start_db_with_conf_changes(config_contents) def get_public_keys(self, context, user): - LOG.debug("Retrieving public keys for %s." % user) + LOG.debug("Retrieving public keys for %s.", user) return self.app.get_public_keys(user) def authorize_public_keys(self, context, user, public_keys): - LOG.debug("Authorizing public keys for %s." % user) + LOG.debug("Authorizing public keys for %s.", user) return self.app.authorize_public_keys(user, public_keys) def install_cluster(self, context, members): try: - LOG.debug("Installing cluster on members: %s." % members) + LOG.debug("Installing cluster on members: %s.", members) self.app.install_cluster(members) self.app.add_udls() LOG.debug("install_cluster call has finished.") @@ -133,7 +133,7 @@ class Manager(manager.Manager): def grow_cluster(self, context, members): try: - LOG.debug("Growing cluster to members: %s." % members) + LOG.debug("Growing cluster to members: %s.", members) self.app.grow_cluster(members) LOG.debug("grow_cluster call has finished.") except Exception: @@ -143,7 +143,7 @@ class Manager(manager.Manager): def shrink_cluster(self, context, members): try: - LOG.debug("Shrinking cluster members: %s." % members) + LOG.debug("Shrinking cluster members: %s.", members) self.app.shrink_cluster(members) LOG.debug("shrink_cluster call has finished.") except Exception: @@ -153,7 +153,7 @@ class Manager(manager.Manager): def mark_design_ksafe(self, context, k): try: - LOG.debug("Setting vertica k-safety to %s." % k) + LOG.debug("Setting vertica k-safety to %s.", k) self.app.mark_design_ksafe(k) except Exception: LOG.exception(_('K-safety setting failed.')) diff --git a/trove/guestagent/datastore/experimental/vertica/service.py b/trove/guestagent/datastore/experimental/vertica/service.py index 3af55116..9a09e695 100644 --- a/trove/guestagent/datastore/experimental/vertica/service.py +++ b/trove/guestagent/datastore/experimental/vertica/service.py @@ -304,7 +304,7 @@ class VerticaApp(object): LOG.info(_("install_vertica completed.")) def update_vertica(self, command, members=netutils.get_my_ipv4()): - LOG.info(_("Calling update_vertica with command %s") % command) + LOG.info(_("Calling update_vertica with command %s"), command) try: update_vertica_cmd = (system.UPDATE_VERTICA % (command, members, MOUNT_POINT)) @@ -327,8 +327,8 @@ class VerticaApp(object): factory = lib['factory'] path = lib['path'] if os.path.isfile(path): - LOG.debug("Adding the %s library as %s." % - (func_name, lib_name)) + LOG.debug("Adding the %(func)s library as %(lib)s.", + {'func': func_name, 'lib': lib_name}) out, err = system.exec_vsql_command( password, system.CREATE_LIBRARY % (lib_name, path) @@ -355,9 +355,9 @@ class VerticaApp(object): loaded_udls.append(func_name) else: LOG.warning(_("Skipping %(func)s as path %(path)s not " - "found.") % {"func": func_name, "path": path}) - LOG.info(_("The following UDL functions are available for use: %s") - % loaded_udls) + "found."), {"func": func_name, "path": path}) + LOG.info(_("The following UDL functions are available for use: %s"), + loaded_udls) def _generate_database_password(self): """Generate and write the password to vertica.cnf file.""" @@ -371,7 +371,7 @@ class VerticaApp(object): unlink_function=os.unlink, temp_function=tempfile.NamedTemporaryFile): """Write the configuration contents to vertica.cnf file.""" - LOG.debug('Defining config holder at %s.' % system.VERTICA_CONF) + LOG.debug('Defining config holder at %s.', system.VERTICA_CONF) tempfile = temp_function('w', delete=False) try: config.write(tempfile) @@ -392,7 +392,7 @@ class VerticaApp(object): config.read(system.VERTICA_CONF) return config except Exception: - LOG.exception(_("Failed to read config %s.") % system.VERTICA_CONF) + LOG.exception(_("Failed to read config %s."), system.VERTICA_CONF) raise RuntimeError def _get_database_password(self): @@ -429,7 +429,7 @@ class VerticaApp(object): def mark_design_ksafe(self, k): """Wrapper for mark_design_ksafe function for setting k-safety """ - LOG.info(_("Setting Vertica k-safety to %s") % str(k)) + LOG.info(_("Setting Vertica k-safety to %s"), str(k)) out, err = system.exec_vsql_command(self._get_database_password(), system.MARK_DESIGN_KSAFE % k) # Only fail if we get an ERROR as opposed to a warning complaining @@ -479,7 +479,7 @@ class VerticaApp(object): if not self.is_root_enabled(): self._create_user(user.name, user.password, 'pseudosuperuser') else: - LOG.debug("Updating %s password." % user.name) + LOG.debug("Updating %s password.", user.name) try: out, err = system.exec_vsql_command( self._get_database_password(), @@ -492,7 +492,7 @@ class VerticaApp(object): raise RuntimeError(_("Failed to update %s " "password.") % user.name) except exception.ProcessExecutionError: - LOG.error(_("Failed to update %s password.") % user.name) + LOG.error(_("Failed to update %s password."), user.name) raise RuntimeError(_("Failed to update %s password.") % user.name) return user.serialize() @@ -513,7 +513,7 @@ class VerticaApp(object): def get_public_keys(self, user): """Generates key (if not found), and sends public key for user.""" - LOG.debug("Public keys requested for user: %s." % user) + LOG.debug("Public keys requested for user: %s.", user) user_home_directory = os.path.expanduser('~' + user) public_key_file_name = user_home_directory + '/.ssh/id_rsa.pub' @@ -533,7 +533,7 @@ class VerticaApp(object): def authorize_public_keys(self, user, public_keys): """Adds public key to authorized_keys for user.""" - LOG.debug("public keys to be added for user: %s." % (user)) + LOG.debug("public keys to be added for user: %s.", user) user_home_directory = os.path.expanduser('~' + user) authorized_file_name = user_home_directory + '/.ssh/authorized_keys' @@ -573,27 +573,27 @@ class VerticaApp(object): def install_cluster(self, members): """Installs & configures cluster.""" cluster_members = ','.join(members) - LOG.debug("Installing cluster with members: %s." % cluster_members) + LOG.debug("Installing cluster with members: %s.", cluster_members) self.install_vertica(cluster_members) self._export_conf_to_members(members) - LOG.debug("Creating database with members: %s." % cluster_members) + LOG.debug("Creating database with members: %s.", cluster_members) self.create_db(cluster_members) - LOG.debug("Cluster configured on members: %s." % cluster_members) + LOG.debug("Cluster configured on members: %s.", cluster_members) def grow_cluster(self, members): """Adds nodes to cluster.""" cluster_members = ','.join(members) - LOG.debug("Growing cluster with members: %s." % cluster_members) + LOG.debug("Growing cluster with members: %s.", cluster_members) self.update_vertica("--add-hosts", cluster_members) self._export_conf_to_members(members) - LOG.debug("Creating database with members: %s." % cluster_members) + LOG.debug("Creating database with members: %s.", cluster_members) self.add_db_to_node(cluster_members) - LOG.debug("Cluster configured on members: %s." % cluster_members) + LOG.debug("Cluster configured on members: %s.", cluster_members) def shrink_cluster(self, members): """Removes nodes from cluster.""" cluster_members = ','.join(members) - LOG.debug("Shrinking cluster with members: %s." % cluster_members) + LOG.debug("Shrinking cluster with members: %s.", cluster_members) self.remove_db_from_node(cluster_members) self.update_vertica("--remove-hosts", cluster_members) @@ -603,7 +603,7 @@ class VerticaApp(object): def _wait_for_node_status(): out, err = system.exec_vsql_command(self._get_database_password(), system.NODE_STATUS % status) - LOG.debug("Polled vertica node states: %s" % out) + LOG.debug("Polled vertica node states: %s", out) if err: LOG.error(err) diff --git a/trove/guestagent/datastore/galera_common/service.py b/trove/guestagent/datastore/galera_common/service.py index 336d16b2..1e6a8bae 100644 --- a/trove/guestagent/datastore/galera_common/service.py +++ b/trove/guestagent/datastore/galera_common/service.py @@ -66,7 +66,7 @@ class GaleraApp(service.BaseMySqlApp): self.stop_db() self.write_cluster_configuration_overrides(cluster_configuration) self.wipe_ib_logfiles() - LOG.debug("bootstrap the instance? : %s" % bootstrap) + LOG.debug("bootstrap the instance? : %s", bootstrap) # Have to wait to sync up the joiner instances with the donor instance. if bootstrap: self._bootstrap_cluster(timeout=CONF.restore_usage_timeout) diff --git a/trove/guestagent/datastore/manager.py b/trove/guestagent/datastore/manager.py index 0133eefa..0baa7b30 100644 --- a/trove/guestagent/datastore/manager.py +++ b/trove/guestagent/datastore/manager.py @@ -110,8 +110,8 @@ class Manager(periodic_task.PeriodicTasks): try: return repl_strategy.get_instance(self.manager) except Exception as ex: - LOG.debug("Cannot get replication instance for '%s': %s" % ( - self.manager, ex.message)) + LOG.debug("Cannot get replication instance for '%(manager)s': " + "%(msg)s", {'manager': self.manager, 'msg': ex.message}) return None @@ -121,8 +121,8 @@ class Manager(periodic_task.PeriodicTasks): try: return repl_strategy.get_strategy(self.manager) except Exception as ex: - LOG.debug("Cannot get replication strategy for '%s': %s" % ( - self.manager, ex.message)) + LOG.debug("Cannot get replication strategy for '%(manager)s': " + "%(msg)s", {'manager': self.manager, 'msg': ex.message}) return None @@ -220,16 +220,17 @@ class Manager(periodic_task.PeriodicTasks): 'guest_log_exposed_logs') except oslo_cfg.NoSuchOptError: exposed_logs = '' - LOG.debug("Available log defs: %s" % ",".join(gl_defs.keys())) + LOG.debug("Available log defs: %s", ",".join(gl_defs.keys())) exposed_logs = exposed_logs.lower().replace(',', ' ').split() - LOG.debug("Exposing log defs: %s" % ",".join(exposed_logs)) + LOG.debug("Exposing log defs: %s", ",".join(exposed_logs)) expose_all = 'all' in exposed_logs for log_name in gl_defs.keys(): gl_def = gl_defs[log_name] exposed = expose_all or log_name in exposed_logs - LOG.debug("Building guest log '%s' from def: %s " - "(exposed: %s)" % - (log_name, gl_def, exposed)) + LOG.debug("Building guest log '%(name)s' from def: %(def)s" + " (exposed: %(exposed)s)", + {'name': log_name, 'def': gl_def, + 'exposed': exposed}) self._guest_log_cache[log_name] = guest_log.GuestLog( self.guest_log_context, log_name, gl_def[self.GUEST_LOG_TYPE_LABEL], @@ -272,7 +273,7 @@ class Manager(periodic_task.PeriodicTasks): device_path, mount_point, backup_info, config_contents, root_password, overrides, cluster_config, snapshot, modules): - LOG.info(_("Starting datastore prepare for '%s'.") % self.manager) + LOG.info(_("Starting datastore prepare for '%s'."), self.manager) self.status.begin_install() post_processing = True if cluster_config else False try: @@ -288,18 +289,18 @@ class Manager(periodic_task.PeriodicTasks): self.apply_overrides_on_prepare(context, overrides) except Exception as ex: self.prepare_error = True - LOG.exception(_("An error occurred preparing datastore: %s") % + LOG.exception(_("An error occurred preparing datastore: %s"), encodeutils.exception_to_unicode(ex)) raise finally: - LOG.info(_("Ending datastore prepare for '%s'.") % self.manager) + LOG.info(_("Ending datastore prepare for '%s'."), self.manager) self.status.end_install(error_occurred=self.prepare_error, post_processing=post_processing) # At this point critical 'prepare' work is done and the instance # is now in the correct 'ACTIVE' 'INSTANCE_READY' or 'ERROR' state. # Of cource if an error has occurred, none of the code that follows # will run. - LOG.info(_("Completed setup of '%s' datastore successfully.") % + LOG.info(_("Completed setup of '%s' datastore successfully."), self.manager) # The following block performs additional instance initialization. @@ -312,7 +313,7 @@ class Manager(periodic_task.PeriodicTasks): LOG.info(_('Module apply completed.')) except Exception as ex: LOG.exception(_("An error occurred applying modules: " - "%s") % ex.message) + "%s"), ex.message) # The following block performs single-instance initialization. # Failures will be recorded, but won't stop the provisioning # or change the instance state. @@ -324,7 +325,7 @@ class Manager(periodic_task.PeriodicTasks): LOG.info(_('Databases created successfully.')) except Exception as ex: LOG.exception(_("An error occurred creating databases: " - "%s") % ex.message) + "%s"), ex.message) try: if users: LOG.info(_("Creating users (called from 'prepare')")) @@ -332,7 +333,7 @@ class Manager(periodic_task.PeriodicTasks): LOG.info(_('Users created successfully.')) except Exception as ex: LOG.exception(_("An error occurred creating users: " - "%s") % ex.message) + "%s"), ex.message) # We only enable-root automatically if not restoring a backup # that may already have root enabled in which case we keep it @@ -344,19 +345,19 @@ class Manager(periodic_task.PeriodicTasks): LOG.info(_('Root enabled successfully.')) except Exception as ex: LOG.exception(_("An error occurred enabling root user: " - "%s") % ex.message) + "%s"), ex.message) try: - LOG.info(_("Calling post_prepare for '%s' datastore.") % + LOG.info(_("Calling post_prepare for '%s' datastore."), self.manager) self.post_prepare(context, packages, databases, memory_mb, users, device_path, mount_point, backup_info, config_contents, root_password, overrides, cluster_config, snapshot) - LOG.info(_("Post prepare for '%s' datastore completed.") % + LOG.info(_("Post prepare for '%s' datastore completed."), self.manager) except Exception as ex: - LOG.exception(_("An error occurred in post prepare: %s") % + LOG.exception(_("An error occurred in post prepare: %s"), ex.message) raise @@ -423,24 +424,26 @@ class Manager(periodic_task.PeriodicTasks): """Gets the filesystem stats for the path given.""" # TODO(peterstac) - note that fs_path is not used in this method. mount_point = CONF.get(self.manager).mount_point - LOG.debug("Getting file system stats for '%s'" % mount_point) + LOG.debug("Getting file system stats for '%s'", mount_point) return dbaas.get_filesystem_volume_stats(mount_point) def mount_volume(self, context, device_path=None, mount_point=None, write_to_fstab=False): - LOG.debug("Mounting the device %s at the mount point %s." % - (device_path, mount_point)) + LOG.debug("Mounting the device %(path)s at the mount point " + "%(mount_point)s.", {'path': device_path, + 'mount_point': mount_point}) device = volume.VolumeDevice(device_path) device.mount(mount_point, write_to_fstab=write_to_fstab) def unmount_volume(self, context, device_path=None, mount_point=None): - LOG.debug("Unmounting the device %s from the mount point %s." % - (device_path, mount_point)) + LOG.debug("Unmounting the device %(path)s from the mount point " + "%(mount_point)s.", {'path': device_path, + 'mount_point': mount_point}) device = volume.VolumeDevice(device_path) device.unmount(mount_point) def resize_fs(self, context, device_path=None, mount_point=None): - LOG.debug("Resizing the filesystem at %s." % mount_point) + LOG.debug("Resizing the filesystem at %s.", mount_point) device = volume.VolumeDevice(device_path) device.resize_fs(mount_point) @@ -475,7 +478,7 @@ class Manager(periodic_task.PeriodicTasks): result = filter(None, [gl_cache[log_name].show() if gl_cache[log_name].exposed else None for log_name in gl_cache.keys()]) - LOG.info(_("Returning list of logs: %s") % result) + LOG.info(_("Returning list of logs: %s"), result) return result def guest_log_action(self, context, log_name, enable, disable, @@ -488,7 +491,7 @@ class Manager(periodic_task.PeriodicTasks): enable = True LOG.info(_("Processing guest log '%(log)s' " "(enable=%(en)s, disable=%(dis)s, " - "publish=%(pub)s, discard=%(disc)s).") % + "publish=%(pub)s, discard=%(disc)s)."), {'log': log_name, 'en': enable, 'dis': disable, 'pub': publish, 'disc': discard}) self.guest_log_context = context @@ -519,7 +522,7 @@ class Manager(periodic_task.PeriodicTasks): log_details = gl_cache[log_name].discard_log() if publish: log_details = gl_cache[log_name].publish_log() - LOG.info(_("Details for log '%(log)s': %(det)s") % + LOG.info(_("Details for log '%(log)s': %(det)s"), {'log': log_name, 'det': log_details}) return log_details @@ -536,7 +539,8 @@ class Manager(periodic_task.PeriodicTasks): restart_required = False verb = ("Disabling" if disable else "Enabling") if self.configuration_manager: - LOG.debug("%s log '%s'" % (verb, log_name)) + LOG.debug("%(verb)s log '%(log)s'", {'verb': verb, + 'log': log_name}) gl_def = self.guest_log_defs[log_name] enable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_ENABLE_LABEL, log_name) @@ -631,7 +635,7 @@ class Manager(periodic_task.PeriodicTasks): as_root=True) operating_system.chmod(log_file, FileMode.ADD_USR_RW_GRP_RW_OTH_R, as_root=True) - LOG.debug("Set log file '%s' as readable" % log_file) + LOG.debug("Set log file '%s' as readable", log_file) return log_file ################ @@ -641,7 +645,7 @@ class Manager(periodic_task.PeriodicTasks): LOG.info(_("Getting list of modules.")) results = module_manager.ModuleManager.read_module_results( is_admin=context.is_admin, include_contents=include_contents) - LOG.info(_("Returning list of modules: %s") % results) + LOG.info(_("Returning list of modules: %s"), results) return results def module_apply(self, context, modules=None): @@ -695,7 +699,7 @@ class Manager(periodic_task.PeriodicTasks): driver, module_type, name, tenant, datastore, ds_version, contents, id, md5, auto_apply, visible, is_admin) results.append(result) - LOG.info(_("Returning list of modules: %s") % results) + LOG.info(_("Returning list of modules: %s"), results) return results def module_remove(self, context, module=None): @@ -715,7 +719,7 @@ class Manager(periodic_task.PeriodicTasks): module_type) module_manager.ModuleManager.remove_module( driver, module_type, id, name, datastore, ds_version) - LOG.info(_("Deleted module: %s") % name) + LOG.info(_("Deleted module: %s"), name) ############### # Not Supported diff --git a/trove/guestagent/datastore/mysql/service.py b/trove/guestagent/datastore/mysql/service.py index 75dd013f..743e173a 100644 --- a/trove/guestagent/datastore/mysql/service.py +++ b/trove/guestagent/datastore/mysql/service.py @@ -85,7 +85,7 @@ class MySqlApp(service.BaseMySqlApp): return self._get_gtid_executed() def wait_for_txn(self, txn): - LOG.info(_("Waiting on txn '%s'.") % txn) + LOG.info(_("Waiting on txn '%s'."), txn) with self.local_sql_client(self.get_engine()) as client: client.execute("SELECT WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS('%s')" % txn) diff --git a/trove/guestagent/datastore/mysql_common/manager.py b/trove/guestagent/datastore/mysql_common/manager.py index 54b3c4a6..78b41071 100644 --- a/trove/guestagent/datastore/mysql_common/manager.py +++ b/trove/guestagent/datastore/mysql_common/manager.py @@ -185,11 +185,11 @@ class MySqlManager(manager.Manager): return self.mysql_admin().disable_root() def _perform_restore(self, backup_info, context, restore_location, app): - LOG.info(_("Restoring database from backup %s.") % backup_info['id']) + LOG.info(_("Restoring database from backup %s."), backup_info['id']) try: backup.restore(context, backup_info, restore_location) except Exception: - LOG.exception(_("Error performing restore from backup %s.") % + LOG.exception(_("Error performing restore from backup %s."), backup_info['id']) app.status.set_status(rd_instance.ServiceStatuses.FAILED) raise @@ -220,7 +220,7 @@ class MySqlManager(manager.Manager): service.MYSQL_OWNER, recursive=False, as_root=True) - LOG.debug("Mounted the volume at %s." % mount_point) + 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 @@ -325,7 +325,7 @@ class MySqlManager(manager.Manager): app.update_overrides(overrides) def apply_overrides(self, context, overrides): - LOG.debug("Applying overrides (%s)." % overrides) + LOG.debug("Applying overrides (%s).", overrides) app = self.mysql_app(self.mysql_app_status.get()) app.apply_overrides(overrides) @@ -420,7 +420,7 @@ class MySqlManager(manager.Manager): raise def make_read_only(self, context, read_only): - LOG.debug("Executing make_read_only(%s)" % read_only) + LOG.debug("Executing make_read_only(%s)", read_only) app = self.mysql_app(self.mysql_app_status.get()) app.make_read_only(read_only) diff --git a/trove/guestagent/datastore/mysql_common/service.py b/trove/guestagent/datastore/mysql_common/service.py index fe8358a3..49c3d4ab 100644 --- a/trove/guestagent/datastore/mysql_common/service.py +++ b/trove/guestagent/datastore/mysql_common/service.py @@ -159,7 +159,7 @@ class BaseMySqlAppStatus(service.BaseDbStatus): pid = out.split()[0] # TODO(rnirmal): Need to create new statuses for instances # where the mysql service is up, but unresponsive - LOG.info(_('MySQL Service Status %(pid)s is BLOCKED.') % + LOG.info(_('MySQL Service Status %(pid)s is BLOCKED.'), {'pid': pid}) return rd_instance.ServiceStatuses.BLOCKED except exception.ProcessExecutionError: @@ -230,8 +230,8 @@ class BaseMySqlAdmin(object): def _associate_dbs(self, user): """Internal. Given a MySQLUser, populate its databases attribute.""" - LOG.debug("Associating dbs to user %s at %s." % - (user.name, user.host)) + LOG.debug("Associating dbs to user %(name)s at %(host)s.", + {'name': user.name, 'host': user.host}) with self.local_sql_client(self.mysql_app.get_engine()) as client: q = sql_query.Query() q.columns = ["grantee", "table_schema"] @@ -241,7 +241,7 @@ class BaseMySqlAdmin(object): t = text(str(q)) db_result = client.execute(t) for db in db_result: - LOG.debug("\t db: %s." % db) + LOG.debug("\t db: %s.", db) if db['grantee'] == "'%s'@'%s'" % (user.name, user.host): user.databases = db['table_schema'] @@ -250,12 +250,12 @@ class BaseMySqlAdmin(object): LOG.debug("Changing the password of some users.") with self.local_sql_client(self.mysql_app.get_engine()) as client: for item in users: - LOG.debug("Changing password for user %s." % item) + LOG.debug("Changing password for user %s.", item) user_dict = {'_name': item['name'], '_host': item['host'], '_password': item['password']} user = models.MySQLUser.deserialize(user_dict) - LOG.debug("\tDeserialized: %s." % user.__dict__) + LOG.debug("\tDeserialized: %s.", user.__dict__) uu = sql_query.SetPassword(user.name, host=user.host, new_password=user.password) t = text(str(uu)) @@ -263,7 +263,7 @@ class BaseMySqlAdmin(object): def update_attributes(self, username, hostname, user_attrs): """Change the attributes of an existing user.""" - LOG.debug("Changing user attributes for user %s." % username) + LOG.debug("Changing user attributes for user %s.", username) user = self._get_user(username, hostname) new_name = user_attrs.get('name') @@ -374,7 +374,7 @@ class BaseMySqlAdmin(object): q.order = ['User', 'Host'] t = text(str(q)) result = client.execute(t).fetchall() - LOG.debug("Getting user information %s." % result) + LOG.debug("Getting user information %s.", result) if len(result) != 1: return None found_user = result[0] @@ -407,7 +407,7 @@ class BaseMySqlAdmin(object): def is_root_enabled(self): """Return True if root access is enabled; False otherwise.""" - LOG.debug("Class type of mysql_root_access is %s " % + LOG.debug("Class type of mysql_root_access is %s ", self.mysql_root_access) return self.mysql_root_access.is_root_enabled() @@ -427,7 +427,7 @@ class BaseMySqlAdmin(object): LOG.debug("---Listing Databases---") ignored_database_names = "'%s'" % "', '".join(cfg.get_ignored_dbs()) LOG.debug("The following database names are on ignore list and will " - "be omitted from the listing: %s" % ignored_database_names) + "be omitted from the listing: %s", ignored_database_names) databases = [] with self.local_sql_client(self.mysql_app.get_engine()) as client: # If you have an external volume mounted at /var/lib/mysql @@ -452,17 +452,17 @@ class BaseMySqlAdmin(object): t = text(str(q)) database_names = client.execute(t) next_marker = None - LOG.debug("database_names = %r." % database_names) + LOG.debug("database_names = %r.", database_names) for count, database in enumerate(database_names): if limit is not None and count >= limit: break - LOG.debug("database = %s." % str(database)) + LOG.debug("database = %s.", str(database)) mysql_db = models.MySQLSchema(name=database[0], character_set=database[1], collate=database[2]) next_marker = mysql_db.name databases.append(mysql_db.serialize()) - LOG.debug("databases = " + str(databases)) + LOG.debug("databases = %s", str(databases)) if limit is not None and database_names.rowcount <= limit: next_marker = None return databases, next_marker @@ -490,7 +490,7 @@ class BaseMySqlAdmin(object): LOG.debug("---Listing Users---") ignored_user_names = "'%s'" % "', '".join(cfg.get_ignored_users()) LOG.debug("The following user names are on ignore list and will " - "be omitted from the listing: %s" % ignored_user_names) + "be omitted from the listing: %s", ignored_user_names) users = [] with self.local_sql_client(self.mysql_app.get_engine()) as client: iq = sql_query.Query() # Inner query. @@ -515,11 +515,11 @@ class BaseMySqlAdmin(object): t = text(str(oq)) result = client.execute(t) next_marker = None - LOG.debug("result = " + str(result)) + LOG.debug("result = %s", str(result)) for count, row in enumerate(result): if limit is not None and count >= limit: break - LOG.debug("user = " + str(row)) + LOG.debug("user = %s", str(row)) mysql_user = models.MySQLUser(name=row['User'], host=row['Host']) mysql_user.check_reserved() @@ -528,7 +528,7 @@ class BaseMySqlAdmin(object): users.append(mysql_user.serialize()) if limit is not None and result.rowcount <= limit: next_marker = None - LOG.debug("users = " + str(users)) + LOG.debug("users = %s", str(users)) return users, next_marker @@ -656,13 +656,13 @@ class BaseMySqlApp(object): Create a os_admin user with a random password with all privileges similar to the root user. """ - LOG.debug("Creating Trove admin user '%s'." % ADMIN_USER_NAME) + LOG.debug("Creating Trove admin user '%s'.", ADMIN_USER_NAME) localhost = "localhost" g = sql_query.Grant(permissions='ALL', user=ADMIN_USER_NAME, host=localhost, grant_option=True, clear=password) t = text(str(g)) client.execute(t) - LOG.debug("Trove admin user '%s' created." % ADMIN_USER_NAME) + LOG.debug("Trove admin user '%s' created.", ADMIN_USER_NAME) @staticmethod def _generate_root_password(client): @@ -700,7 +700,7 @@ class BaseMySqlApp(object): with self.local_sql_client(engine, use_flush=False) as client: self._create_admin_user(client, admin_password) - LOG.debug("Switching to the '%s' user now." % ADMIN_USER_NAME) + LOG.debug("Switching to the '%s' user now.", ADMIN_USER_NAME) engine = sqlalchemy.create_engine( CONNECTION_STR_FORMAT % (ADMIN_USER_NAME, urllib.parse.quote(admin_password)), @@ -746,14 +746,15 @@ class BaseMySqlApp(object): try: old_conf_backup = "%s_%s" % (config, random_uuid) operating_system.move(config, old_conf_backup, as_root=True) - LOG.debug("%s saved to %s_%s." % - (config, config, random_uuid)) + LOG.debug("%(cfg)s saved to %(saved_cfg)s_%(uuid)s.", + {'cfg': config, 'saved_cfg': config, + 'uuid': random_uuid}) except exception.ProcessExecutionError: pass def _create_mysql_confd_dir(self): conf_dir = "/etc/mysql/conf.d" - LOG.debug("Creating %s." % conf_dir) + LOG.debug("Creating %s.", conf_dir) operating_system.create_directory(conf_dir, as_root=True) def _enable_mysql_on_boot(self): @@ -833,7 +834,7 @@ class BaseMySqlApp(object): except exc.OperationalError: output = {'key': k, 'value': byte_value} LOG.exception(_("Unable to set %(key)s with value " - "%(value)s.") % output) + "%(value)s."), output) def make_read_only(self, read_only): with self.local_sql_client(self.get_engine()) as client: @@ -889,7 +890,7 @@ class BaseMySqlApp(object): def grant_replication_privilege(self, replication_user): LOG.info(_("Granting Replication Slave privilege.")) - LOG.debug("grant_replication_privilege: %s" % replication_user) + LOG.debug("grant_replication_privilege: %s", replication_user) with self.local_sql_client(self.get_engine()) as client: g = sql_query.Grant(permissions=['REPLICATION SLAVE'], @@ -914,7 +915,7 @@ class BaseMySqlApp(object): return binlog_position def execute_on_client(self, sql_statement): - LOG.debug("Executing SQL: %s" % sql_statement) + LOG.debug("Executing SQL: %s", sql_statement) with self.local_sql_client(self.get_engine()) as client: return client.execute(sql_statement) @@ -955,7 +956,7 @@ class BaseMySqlApp(object): try: utils.poll_until(verify_slave_status, sleep_time=3, time_out=max_time) - LOG.info(_("Replication is now %s.") % status.lower()) + LOG.info(_("Replication is now %s."), status.lower()) except PollTimeOut: raise RuntimeError( _("Replication is not %(status)s after %(max)d seconds.") % { @@ -1000,11 +1001,11 @@ class BaseMySqlApp(object): def start_db_with_conf_changes(self, config_contents): LOG.info(_("Starting MySQL with conf changes.")) - LOG.debug("Inside the guest - Status is_running = (%s)." - % self.status.is_running) + LOG.debug("Inside the guest - Status is_running = (%s).", + self.status.is_running) if self.status.is_running: LOG.error(_("Cannot execute start_db_with_conf_changes because " - "MySQL state == %s.") % self.status) + "MySQL state == %s."), self.status) raise RuntimeError(_("MySQL not stopped.")) LOG.info(_("Resetting configuration.")) self._reset_configuration(config_contents) @@ -1045,7 +1046,7 @@ class BaseMySqlRootAccess(object): with self.local_sql_client(self.mysql_app.get_engine()) as client: t = text(sql_query.ROOT_ENABLED) result = client.execute(t) - LOG.debug("Found %s with remote root access." % result.rowcount) + LOG.debug("Found %s with remote root access.", result.rowcount) return result.rowcount != 0 def enable_root(self, root_password=None): @@ -1068,8 +1069,10 @@ class BaseMySqlRootAccess(object): t = text(str(uu)) client.execute(t) - LOG.debug("CONF.root_grant: %s CONF.root_grant_option: %s." % - (CONF.root_grant, CONF.root_grant_option)) + LOG.debug("CONF.root_grant: %(grant)s CONF.root_grant_option: " + "%(grant_option)s.", + {'grant': CONF.root_grant, + 'grant_option': CONF.root_grant_option}) g = sql_query.Grant(permissions=CONF.root_grant, user=user.name, diff --git a/trove/guestagent/datastore/service.py b/trove/guestagent/datastore/service.py index 48dae63e..d03d87f8 100644 --- a/trove/guestagent/datastore/service.py +++ b/trove/guestagent/datastore/service.py @@ -118,7 +118,7 @@ class BaseDbStatus(object): final_status = instance.ServiceStatuses.INSTANCE_READY if final_status: - LOG.info(_("Set final status to %s.") % final_status) + LOG.info(_("Set final status to %s."), final_status) self.set_status(final_status, force=True) else: self._end_install_or_restart(True) @@ -133,7 +133,7 @@ class BaseDbStatus(object): Updates the database with the actual DB server status. """ real_status = self._get_actual_db_status() - LOG.info(_("Current database status is '%s'.") % real_status) + LOG.info(_("Current database status is '%s'."), real_status) self.set_status(real_status, force=force) def _get_actual_db_status(self): @@ -162,7 +162,7 @@ class BaseDbStatus(object): if force or self.is_installed: LOG.debug("Casting set_status message to conductor " - "(status is '%s')." % status.description) + "(status is '%s').", status.description) context = trove_context.TroveContext() heartbeat = {'service_status': status.description} @@ -317,8 +317,8 @@ class BaseDbStatus(object): if not self.wait_for_real_status_to_change_to( status, timeout, update_db): LOG.info(_("Service status did not change to %(status)s " - "within the given timeout: %(timeout)ds") - % {'status': status, 'timeout': timeout}) + "within the given timeout: %(timeout)ds"), + {'status': status, 'timeout': timeout}) LOG.debug("Attempting to cleanup stalled services.") try: self.cleanup_stalled_db_services() @@ -360,14 +360,14 @@ class BaseDbStatus(object): # just going to error out anyway. if loop: LOG.debug("Waiting for DB status to change from " - "%(actual_status)s to %(status)s." % + "%(actual_status)s to %(status)s.", {"actual_status": self.status, "status": status}) time.sleep(CONF.state_change_poll_time) LOG.error(_("Timeout while waiting for database status to change." "Expected state %(status)s, " - "current state is %(actual_status)s") % + "current state is %(actual_status)s"), {"status": status, "actual_status": self.status}) return False |