diff --git a/trove/datastore/models.py b/trove/datastore/models.py index 07d70554d3..08753eac92 100644 --- a/trove/datastore/models.py +++ b/trove/datastore/models.py @@ -134,7 +134,7 @@ class Capabilities(object): self.capabilities = [override(obj) for obj in capability_defaults] - LOG.debug('Capabilities for datastore %(ds_id)s: %(capabilities)s' % + LOG.debug('Capabilities for datastore %(ds_id)s: %(capabilities)s', {'ds_id': self.datastore_version_id, 'capabilities': self.capabilities}) diff --git a/trove/db/models.py b/trove/db/models.py index 90dc4800d3..c7e7f56c13 100644 --- a/trove/db/models.py +++ b/trove/db/models.py @@ -59,14 +59,14 @@ class DatabaseModelBase(models.ModelBase): if not self.is_valid(): raise exception.InvalidModelError(errors=self.errors) self['updated'] = utils.utcnow() - LOG.debug("Saving %(name)s: %(dict)s" % + LOG.debug("Saving %(name)s: %(dict)s", {'name': self.__class__.__name__, 'dict': strutils.mask_dict_password(self.__dict__)}) return self.db_api.save(self) def delete(self): self['updated'] = utils.utcnow() - LOG.debug("Deleting %(name)s: %(dict)s" % + LOG.debug("Deleting %(name)s: %(dict)s", {'name': self.__class__.__name__, 'dict': strutils.mask_dict_password(self.__dict__)}) @@ -105,13 +105,12 @@ class DatabaseModelBase(models.ModelBase): if ((context and not context.is_admin and hasattr(model, 'tenant_id') and model.tenant_id != context.tenant)): msg = _("Tenant %(s_tenant)s tried to access " - "%(s_name)s, owned by %(s_owner)s.") - LOG.error(msg % ( - {"s_tenant": context.tenant, "s_name": cls.__name__, - "s_owner": model.tenant_id})) - raise exception.ModelNotFoundError( - _("Tenant %(s_tenant)s cannot access %(s_name)s") % ( - {"s_tenant": context.tenant, "s_name": cls.__name__})) + "%(s_name)s, owned by %(s_owner)s.") % { + "s_tenant": context.tenant, "s_name": cls.__name__, + "s_owner": model.tenant_id} + + LOG.error(msg) + raise exception.ModelNotFoundError(msg) return model diff --git a/trove/db/sqlalchemy/migrate_repo/schema.py b/trove/db/sqlalchemy/migrate_repo/schema.py index bf47d152be..ecc58f064a 100644 --- a/trove/db/sqlalchemy/migrate_repo/schema.py +++ b/trove/db/sqlalchemy/migrate_repo/schema.py @@ -65,13 +65,13 @@ class Float(sqlalchemy.types.Float): def create_tables(tables): for table in tables: - logger.info("creating table %(table)s" % {'table': table}) + logger.info("creating table %(table)s", {'table': table}) table.create() def drop_tables(tables): for table in tables: - logger.info("dropping table %(table)s" % {'table': table}) + logger.info("dropping table %(table)s", {'table': table}) table.drop() diff --git a/trove/db/sqlalchemy/migration.py b/trove/db/sqlalchemy/migration.py index 84b42518ec..57936417e8 100644 --- a/trove/db/sqlalchemy/migration.py +++ b/trove/db/sqlalchemy/migration.py @@ -59,7 +59,7 @@ def upgrade(options, version=None, repo_path=None): repo_path = get_migrate_repo_path(repo_path) sql_connection = options['database']['connection'] version_str = version or 'latest' - logger.info("Upgrading %(sql_connection)s to version %(version_str)s" % + logger.info("Upgrading %(sql_connection)s to version %(version_str)s", {'sql_connection': sql_connection, 'version_str': version_str}) return versioning_api.upgrade(sql_connection, repo_path, version) diff --git a/trove/db/sqlalchemy/session.py b/trove/db/sqlalchemy/session.py index e6a3f8ed27..188b7d5123 100644 --- a/trove/db/sqlalchemy/session.py +++ b/trove/db/sqlalchemy/session.py @@ -88,8 +88,8 @@ def _create_facade(options): LOG.warning(_('Configuration option "query_log" has been ' 'depracated. Use "connection_debug" ' 'instead. Setting connection_debug = ' - '%(debug_level)s instead.') - % conf.get('connection_debug')) + '%(debug_level)s instead.'), + conf.get('connection_debug')) # TODO(mvandijk): once query_log is removed, # use enginefacade.from_config() instead database_opts = dict(CONF.database) diff --git a/trove/dns/designate/driver.py b/trove/dns/designate/driver.py index 35cc38b710..ddbac94a2d 100644 --- a/trove/dns/designate/driver.py +++ b/trove/dns/designate/driver.py @@ -87,7 +87,7 @@ class DesignateDriver(driver.DnsDriver): raise TypeError(_("The entry's dns_zone must have an ID " "specified.")) name = entry.name - LOG.debug("Creating DNS entry %s." % name) + LOG.debug("Creating DNS entry %s.", name) client = self.dns_client # Record name has to end with a '.' by dns standard record = Record(name=entry.name + '.', @@ -105,7 +105,7 @@ class DesignateDriver(driver.DnsDriver): if rec.name == name + '.' and rec.type == type] if not matching_record: raise exception.DnsRecordNotFound(name) - LOG.debug("Deleting DNS entry %s." % name) + LOG.debug("Deleting DNS entry %s.", name) self.dns_client.records.delete(dns_zone.id, matching_record[0].id) def get_entries_by_content(self, content, dns_zone=None): diff --git a/trove/dns/manager.py b/trove/dns/manager.py index c4f35e9f78..ed54ecda58 100644 --- a/trove/dns/manager.py +++ b/trove/dns/manager.py @@ -51,10 +51,10 @@ class DnsManager(object): """ entry = self.entry_factory.create_entry(instance_id) if entry: - LOG.debug("Creating entry address %s." % str(entry)) + LOG.debug("Creating entry address %s.", str(entry)) self.driver.create_entry(entry, content) else: - LOG.debug("Entry address not found for instance %s" % instance_id) + LOG.debug("Entry address not found for instance %s", instance_id) def delete_instance_entry(self, instance_id, content=None): """Removes a DNS entry associated to an instance. @@ -64,7 +64,7 @@ class DnsManager(object): """ entry = self.entry_factory.create_entry(instance_id) - LOG.debug("Deleting instance entry with %s" % str(entry)) + LOG.debug("Deleting instance entry with %s", str(entry)) if entry: self.driver.delete_entry(entry.name, entry.type) diff --git a/trove/dns/models.py b/trove/dns/models.py index 6c77c1bbdc..6ffb1e66ef 100644 --- a/trove/dns/models.py +++ b/trove/dns/models.py @@ -53,12 +53,12 @@ class DnsRecord(ModelBase): def save(self): if not self.is_valid(): raise exception.InvalidModelError(errors=self.errors) - LOG.debug("Saving %(name)s: %(dict)s" % + LOG.debug("Saving %(name)s: %(dict)s", {'name': self.__class__.__name__, 'dict': self.__dict__}) return get_db_api().save(self) def delete(self): - LOG.debug("Deleting %(name)s: %(dict)s" % + LOG.debug("Deleting %(name)s: %(dict)s", {'name': self.__class__.__name__, 'dict': self.__dict__}) return get_db_api().delete(self) diff --git a/trove/instance/models.py b/trove/instance/models.py index 0621c2cc3f..3793e46f76 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -982,8 +982,8 @@ class Instance(BuiltInstance): except exception.ModelNotFoundError: LOG.exception( _("Cannot create a replica of %(id)s " - "as that instance could not be found.") - % {'id': slave_of_id}) + "as that instance could not be found."), + {'id': slave_of_id}) raise exception.NotFound(uuid=slave_of_id) elif replica_count and replica_count != 1: raise exception.Forbidden(_( @@ -1516,7 +1516,7 @@ class Instances(object): except exception.NotFound: # The instance may be gone if we're in the middle of a # shrink operation, so just log and continue - LOG.debug("Instance %s is no longer available, skipping." % + LOG.debug("Instance %s is no longer available, skipping.", db_instance.id) return db_insts @@ -1591,7 +1591,7 @@ class DBInstance(dbmodels.DatabaseModelBase): kwargs["encrypted_key"] = cu.encode_data(cu.encrypt_data( key, CONF.inst_rpc_key_encr_key)) LOG.debug("Generated unique RPC encryption key for " - "instance. key = %s" % key) + "instance. key = %s", key) else: kwargs["encrypted_key"] = None diff --git a/trove/instance/service.py b/trove/instance/service.py index e0cd404b45..c4f09b59cb 100644 --- a/trove/instance/service.py +++ b/trove/instance/service.py @@ -193,7 +193,7 @@ class InstanceController(wsgi.Controller): with StartNotification(context, instance_id=instance.id): instance.reset_status() - LOG.debug("Failing backups for instance %s." % instance.id) + LOG.debug("Failing backups for instance %s.", instance.id) backup_model.fail_for_instance(instance.id) return wsgi.Result(None, 202) @@ -470,7 +470,7 @@ class InstanceController(wsgi.Controller): def guest_log_list(self, req, tenant_id, id): """Return all information about all logs for an instance.""" - LOG.debug("Listing logs for tenant %s" % tenant_id) + LOG.debug("Listing logs for tenant %s", tenant_id) context = req.environ[wsgi.CONTEXT_KEY] instance = models.Instance.load(context, id) if not instance: @@ -559,6 +559,8 @@ class InstanceController(wsgi.Controller): context, instance_id=id, module_id=module_id) for instance_module in instance_modules: module_models.InstanceModule.delete(context, instance_module) - LOG.debug("Deleted IM record %s (instance %s, module %s)." % - (instance_module.id, id, module_id)) + LOG.debug("Deleted IM record %(instance_module_id)s " + "(instance %(id)s, module %(module_id)s).", + {'instance_module_id': instance_module.id, 'id': id, + 'module_id': module_id}) return wsgi.Result(None, 200)