diff --git a/reddwarf/common/auth.py b/reddwarf/common/auth.py index 2ba08dd19c..12ac5638e4 100644 --- a/reddwarf/common/auth.py +++ b/reddwarf/common/auth.py @@ -29,22 +29,22 @@ class AuthorizationMiddleware(wsgi.Middleware): def __init__(self, application, auth_providers, **local_config): self.auth_providers = auth_providers - LOG.debug(_("Auth middleware providers: %s" % auth_providers)) + LOG.debug(_("Auth middleware providers: %s") % auth_providers) super(AuthorizationMiddleware, self).__init__(application, **local_config) def process_request(self, request): roles = request.headers.get('X_ROLE', '').split(',') - LOG.debug(_("Processing auth request with roles: %s" % roles)) + LOG.debug(_("Processing auth request with roles: %s") % roles) tenant_id = request.headers.get('X-Tenant-Id', None) - LOG.debug(_("Processing auth request with tenant_id: %s" % tenant_id)) + LOG.debug(_("Processing auth request with tenant_id: %s") % tenant_id) for provider in self.auth_providers: provider.authorize(request, tenant_id, roles) @classmethod def factory(cls, global_config, **local_config): def _factory(app): - LOG.debug(_("Created auth middleware with config: %s" % local_config)) + LOG.debug(_("Created auth middleware with config: %s") % local_config) return cls(app, [TenantBasedAuth()], **local_config) return _factory @@ -58,13 +58,13 @@ class TenantBasedAuth(object): def authorize(self, request, tenant_id, roles): if 'admin' in [role.lower() for role in roles]: - LOG.debug(_("Authorized admin request: %s" % request)) + LOG.debug(_("Authorized admin request: %s") % request) return True match_for_tenant = self.tenant_scoped_url.match(request.path_info) if (match_for_tenant and tenant_id == match_for_tenant.group('tenant_id')): LOG.debug(_("Authorized tenant '%(tenant_id)s' request: " - "%(request)s" % locals())) + "%(request)s") % locals()) return True raise webob.exc.HTTPForbidden(_("User with tenant id %s cannot " "access this resource") % tenant_id) diff --git a/reddwarf/common/exception.py b/reddwarf/common/exception.py index d8ccad4e53..112d4ca395 100644 --- a/reddwarf/common/exception.py +++ b/reddwarf/common/exception.py @@ -37,9 +37,9 @@ class ReddwarfError(openstack_exception.OpenstackException): self.message = message if self.internal_message is not None: try: - LOG.error(_(self.internal_message % kwargs)) + LOG.error(self.internal_message % kwargs) except Exception: - LOG.error(_(self.internal_message)) + LOG.error(self.internal_message) super(ReddwarfError, self).__init__(**kwargs) diff --git a/reddwarf/common/wsgi.py b/reddwarf/common/wsgi.py index e1b120d783..3516732655 100644 --- a/reddwarf/common/wsgi.py +++ b/reddwarf/common/wsgi.py @@ -275,7 +275,7 @@ class ContextMiddleware(openstack_wsgi.Middleware): @classmethod def factory(cls, global_config, **local_config): def _factory(app): - LOG.debug(_("Created context middleware with config: %s" % - local_config)) + LOG.debug(_("Created context middleware with config: %s") % + local_config) return cls(app) return _factory diff --git a/reddwarf/db/sqlalchemy/session.py b/reddwarf/db/sqlalchemy/session.py index 76fffdacdf..9ba33504bd 100644 --- a/reddwarf/db/sqlalchemy/session.py +++ b/reddwarf/db/sqlalchemy/session.py @@ -64,7 +64,7 @@ def _create_engine(options): type='bool', default=False), } - LOG.info(_("Creating SQLAlchemy engine with args: %s" % engine_args)) + LOG.info(_("Creating SQLAlchemy engine with args: %s") % engine_args) return create_engine(options['sql_connection'], **engine_args) diff --git a/reddwarf/extensions/mysql/service.py b/reddwarf/extensions/mysql/service.py index cffb911402..23fc26b020 100644 --- a/reddwarf/extensions/mysql/service.py +++ b/reddwarf/extensions/mysql/service.py @@ -61,16 +61,16 @@ class RootController(BaseController): def index(self, req, tenant_id, instance_id): """ Returns True if root is enabled for the given instance; False otherwise. """ - LOG.info(_("Getting root enabled for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Getting root enabled for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] is_root_enabled = models.Root.load(context, instance_id) return wsgi.Result(views.RootEnabledView(is_root_enabled).data(), 200) def create(self, req, body, tenant_id, instance_id): """ Enable the root user for the db instance """ - LOG.info(_("Enabling root for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Enabling root for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] root = models.Root.create(context, instance_id) return wsgi.Result(views.RootCreatedView(root).data(), 200) @@ -95,17 +95,17 @@ class UserController(BaseController): def index(self, req, tenant_id, instance_id): """Return all users.""" - LOG.info(_("Listing users for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Listing users for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] users = models.Users.load(context, instance_id) return wsgi.Result(views.UsersView(users).data(), 200) def create(self, req, body, tenant_id, instance_id): """Creates a set of users""" - LOG.info(_("Creating users for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("body : '%s'\n\n" % body)) + LOG.info(_("Creating users for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("body : '%s'\n\n") % body) context = req.environ[wsgi.CONTEXT_KEY] self.validate(body) users = body['users'] @@ -114,8 +114,8 @@ class UserController(BaseController): return wsgi.Result(202) def delete(self, req, tenant_id, instance_id, id): - LOG.info(_("Deleting user for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Deleting user for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] user = guest_models.MySQLUser() user.name = id @@ -139,8 +139,8 @@ class SchemaController(BaseController): def index(self, req, tenant_id, instance_id): """Return all schemas.""" - LOG.info(_("Listing schemas for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Listing schemas for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] schemas = models.Schemas.load(context, instance_id) # Not exactly sure why we cant return a wsgi.Result() here @@ -148,9 +148,9 @@ class SchemaController(BaseController): def create(self, req, body, tenant_id, instance_id): """Creates a set of schemas""" - LOG.info(_("Creating schema for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("body : '%s'\n\n" % body)) + LOG.info(_("Creating schema for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("body : '%s'\n\n") % body) context = req.environ[wsgi.CONTEXT_KEY] self.validate(body) schemas = body['databases'] @@ -159,8 +159,8 @@ class SchemaController(BaseController): return wsgi.Result(202) def delete(self, req, tenant_id, instance_id, id): - LOG.info(_("Deleting schema for instance '%s'" % instance_id)) - LOG.info(_("req : '%s'\n\n" % req)) + LOG.info(_("Deleting schema for instance '%s'") % instance_id) + LOG.info(_("req : '%s'\n\n") % req) context = req.environ[wsgi.CONTEXT_KEY] schema = guest_models.MySQLDatabase() schema.name = id diff --git a/reddwarf/guestagent/dbaas.py b/reddwarf/guestagent/dbaas.py index ffac1b94b4..081f5f95eb 100644 --- a/reddwarf/guestagent/dbaas.py +++ b/reddwarf/guestagent/dbaas.py @@ -132,9 +132,9 @@ class DBaaSAgent(object): t = text("""select User from mysql.user where host != 'localhost';""") result = client.execute(t) - LOG.debug(_("result = " + str(result))) + LOG.debug(_("result = %s") % str(result)) for row in result: - LOG.debug(_("user = " + str(row))) + LOG.debug(_("user = %s" % str(row)) mysql_user = models.MySQLUser() mysql_user.name = row['User'] # Now get the databases @@ -150,7 +150,7 @@ class DBaaSAgent(object): mysql_db.name = db['table_schema'] mysql_user.databases.append(mysql_db.serialize()) users.append(mysql_user.serialize()) - LOG.debug(_("users = " + str(users))) + LOG.debug(_("users = %s") str(users)) return users def delete_user(self, user): @@ -198,15 +198,15 @@ class DBaaSAgent(object): schema_name ASC; ''') database_names = client.execute(t) - LOG.debug(_("database_names = %r" % database_names)) + LOG.debug(_("database_names = %r") % database_names) for database in database_names: - LOG.debug(_("database = %s " % str(database))) + LOG.debug(_("database = %s ") % str(database)) mysql_db = models.MySQLDatabase() mysql_db.name = database[0] mysql_db.character_set = database[1] mysql_db.collate = database[2] databases.append(mysql_db.serialize()) - LOG.debug(_("databases = " + str(databases))) + LOG.debug(_("databases = ") + str(databases)) return databases def delete_database(self, database): @@ -265,7 +265,7 @@ class DBaaSAgent(object): t = text("""SELECT User FROM mysql.user where User = 'root' and host != 'localhost';""") result = client.execute(t) - LOG.debug(_("result = " + str(result))) + LOG.debug(_("result = ") + str(result)) return result.rowcount != 0 def prepare(self, databases, memory_mb): diff --git a/reddwarf/guestagent/manager.py b/reddwarf/guestagent/manager.py index 28e3441fbf..95eb584ccd 100644 --- a/reddwarf/guestagent/manager.py +++ b/reddwarf/guestagent/manager.py @@ -71,8 +71,8 @@ class GuestManager(service.Manager): try: getattr(self.driver, status_method)() except AttributeError as ae: - LOG.error(_("Method %s not found for driver %s", status_method, - self.driver)) + LOG.error(_("Method %s not found for driver %s"), status_method, + self.driver) if raise_on_error: raise ae @@ -89,6 +89,6 @@ class GuestManager(service.Manager): try: return getattr(self.driver, method)(*args, **kwargs) except AttributeError: - LOG.error(_("Method %s not found for driver %s", method, self.driver)) + LOG.error(_("Method %s not found for driver %s"), method, self.driver) raise exception.NotFound("Method not available for the " "chosen driver") diff --git a/reddwarf/instance/models.py b/reddwarf/instance/models.py index 03e6cc4bd7..2bc3c3d64b 100644 --- a/reddwarf/instance/models.py +++ b/reddwarf/instance/models.py @@ -97,12 +97,12 @@ class Instance(object): return Instance(context, db_info, server, service_status) def delete(self, force=False): - LOG.debug(_("Deleting instance %s..." % self.id)) + LOG.debug(_("Deleting instance %s...") % self.id) if not force and self.server.status in SERVER_INVALID_DELETE_STATUSES: raise rd_exceptions.UnprocessableEntity("Instance %s is not ready." % self.id) - LOG.debug(_(" ... deleting compute id = %s" % - self.server.id)) + LOG.debug(_(" ... deleting compute id = %s") % + self.server.id) self._delete_server() LOG.debug(_(" ... setting status to DELETING.")) self.db_info.task_status = InstanceTasks.DELETING @@ -122,11 +122,11 @@ class Instance(object): def create(cls, context, name, flavor_ref, image_id): db_info = DBInstance.create(name=name, task_status=InstanceTasks.BUILDING) - LOG.debug(_("Created new Reddwarf instance %s..." % db_info.id)) + LOG.debug(_("Created new Reddwarf instance %s...") % db_info.id) client = create_nova_client(context) server = client.servers.create(name, image_id, flavor_ref, files={"/etc/guest_info": "guest_id=%s" % db_info.id}) - LOG.debug(_("Created new compute instance %s." % server.id)) + LOG.debug(_("Created new compute instance %s.") % server.id) db_info.compute_instance_id = server.id db_info.save() service_status = InstanceServiceStatus.create(instance_id=db_info.id, @@ -172,7 +172,7 @@ class Instance(object): return InstanceStatus.SHUTDOWN else: LOG.error(_("While shutting down instance %s: server had status " - " %s." % (self.id, self.server.status))) + " %s.") % (self.id, self.server.status)) return InstanceStatus.ERROR # For everything else we can look at the service status mapping. return self.service_status.status.api_status @@ -231,8 +231,8 @@ def create_server_list_matcher(server_list): instance_id=instance_id, server_id=server_id) else: # Should never happen, but never say never. - LOG.error(_("Server %s for instance %s was found twice!" - % (server_id, instance_id))) + LOG.error(_("Server %s for instance %s was found twice!") + % (server_id, instance_id)) raise rd_exceptions.ReddwarfError(uuid=instance_id) return find_server @@ -281,7 +281,7 @@ class DatabaseModelBase(ModelBase): if not self.is_valid(): raise InvalidModelError(self.errors) self['updated_at'] = utils.utcnow() - LOG.debug(_("Saving %s: %s" % (self.__class__.__name__, self.__dict__))) + LOG.debug(_("Saving %s: %s") % (self.__class__.__name__, self.__dict__)) return db.db_api.save(self) def __init__(self, **kwargs): diff --git a/reddwarf/instance/service.py b/reddwarf/instance/service.py index 54d0a6ff64..6d0517ce90 100644 --- a/reddwarf/instance/service.py +++ b/reddwarf/instance/service.py @@ -87,15 +87,15 @@ class InstanceController(BaseController): def detail(self, req, tenant_id): """Return all instances.""" - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("Detailing a database instance for tenant '%s'" % tenant_id)) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("Detailing a database instance for tenant '%s'") % tenant_id) #TODO(cp16net) return a detailed list instead of index return self.index(req, tenant_id, detailed=True) def index(self, req, tenant_id, detailed=False): """Return all instances.""" - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("Indexing a database instance for tenant '%s'" % tenant_id)) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("Indexing a database instance for tenant '%s'") % tenant_id) context = req.environ[wsgi.CONTEXT_KEY] servers = models.Instances.load(context) # TODO(cp16net): need to set the return code correctly @@ -105,9 +105,9 @@ class InstanceController(BaseController): def show(self, req, tenant_id, id): """Return a single instance.""" - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("Showing a database instance for tenant '%s'" % tenant_id)) - LOG.info(_("id : '%s'\n\n" % id)) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("Showing a database instance for tenant '%s'") % tenant_id) + LOG.info(_("id : '%s'\n\n") % id) context = req.environ[wsgi.CONTEXT_KEY] try: @@ -123,9 +123,9 @@ class InstanceController(BaseController): def delete(self, req, tenant_id, id): """Delete a single instance.""" - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("Deleting a database instance for tenant '%s'" % tenant_id)) - LOG.info(_("id : '%s'\n\n" % id)) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("Deleting a database instance for tenant '%s'") % tenant_id) + LOG.info(_("id : '%s'\n\n") % id) # TODO(hub-cap): turn this into middleware context = req.environ[wsgi.CONTEXT_KEY] try: @@ -156,9 +156,9 @@ class InstanceController(BaseController): # code. Or maybe we shouldnt due to the nature of changing images. # This needs discussion. # TODO(hub-cap): turn this into middleware - LOG.info(_("Creating a database instance for tenant '%s'" % tenant_id)) - LOG.info(_("req : '%s'\n\n" % req)) - LOG.info(_("body : '%s'\n\n" % body)) + LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id) + LOG.info(_("req : '%s'\n\n") % req) + LOG.info(_("body : '%s'\n\n") % body) context = req.environ[wsgi.CONTEXT_KEY] database = models.ServiceImage.find_by(service_name="database") image_id = database['image_id'] @@ -208,7 +208,7 @@ class InstanceController(BaseController): # TODO(cp16net) add in volume to the mix # volume_size = body['instance']['volume']['size'] except KeyError as e: - LOG.error(_("Create Instance Required field(s) - %s" % e)) + LOG.error(_("Create Instance Required field(s) - %s") % e) raise rd_exceptions.ReddwarfError("Required element/key - %s " "was not specified" % e) # Instance._validate_volume_size(volume_size) @@ -220,7 +220,7 @@ class InstanceController(BaseController): body['resize'] body['resize']['flavorRef'] except KeyError as e: - LOG.error(_("Resize Instance Required field(s) - %s" % e)) + LOG.error(_("Resize Instance Required field(s) - %s") % e) raise rd_exceptions.ReddwarfError("Required element/key - %s " "was not specified" % e) @@ -235,7 +235,7 @@ class InstanceController(BaseController): LOG.error(_(msg)) raise rd_exceptions.ReddwarfError(msg) except KeyError as e: - LOG.error(_("Resize Instance Required field(s) - %s" % e)) + LOG.error(_("Resize Instance Required field(s) - %s") % e) raise rd_exceptions.ReddwarfError("Required element/key - %s " "was not specified" % e) @@ -250,7 +250,7 @@ class InstanceController(BaseController): body['resize']['volume'] new_volume_size = body['resize']['volume']['size'] except KeyError as e: - LOG.error(_("Resize Instance Required field(s) - %s" % e)) + LOG.error(_("Resize Instance Required field(s) - %s") % e) raise rd_exceptions.ReddwarfError("Required element/key - %s " "was not specified" % e) Instance._validate_volume_size(new_volume_size) diff --git a/reddwarf/rpc/impl_kombu.py b/reddwarf/rpc/impl_kombu.py index 33ae8f4776..6d89b61400 100644 --- a/reddwarf/rpc/impl_kombu.py +++ b/reddwarf/rpc/impl_kombu.py @@ -415,7 +415,7 @@ class Connection(object): for consumer in self.consumers: consumer.reconnect(self.channel) LOG.info(_('Connected to AMQP server on ' - '%(hostname)s:%(port)d' % self.params)) + '%(hostname)s:%(port)d') % self.params) def reconnect(self): """Handles reconnecting and re-establishing queues. @@ -578,8 +578,8 @@ class Connection(object): def _publish(): publisher = cls(self.channel, topic, **kwargs) - LOG.info(_("_publish info%s %s %s %s" % (self.channel, topic, - kwargs, publisher))) + LOG.info(_("_publish info%s %s %s %s") % (self.channel, topic, + kwargs, publisher)) publisher.send(msg) self.ensure(_error_callback, _publish) diff --git a/reddwarf/rpc/impl_qpid.py b/reddwarf/rpc/impl_qpid.py index 2e71d470d4..9366c2dd4a 100644 --- a/reddwarf/rpc/impl_qpid.py +++ b/reddwarf/rpc/impl_qpid.py @@ -337,12 +337,12 @@ class Connection(object): try: self.connection.open() except qpid.messaging.exceptions.ConnectionError, e: - LOG.error(_('Unable to connect to AMQP server: %s ' % str(e))) + LOG.error(_('Unable to connect to AMQP server: %s ') % str(e)) time.sleep(FLAGS.qpid_reconnect_interval or 1) else: break - LOG.info(_('Connected to AMQP server on %s' % self.broker)) + LOG.info(_('Connected to AMQP server on %s') % self.broker) self.session = self.connection.session() diff --git a/reddwarf/taskmanager/manager.py b/reddwarf/taskmanager/manager.py index 263f59e846..cb4ace2a70 100644 --- a/reddwarf/taskmanager/manager.py +++ b/reddwarf/taskmanager/manager.py @@ -24,10 +24,10 @@ class TaskManager(object): """Task manager impl""" def __init__(self, *args, **kwargs): - LOG.info(_("TaskManager init %s %s" % (args, kwargs))) + LOG.info(_("TaskManager init %s %s") % (args, kwargs)) def periodic_tasks(self, raise_on_error=False): LOG.info(_("Launching a periodic task")) def test_method(self, context): - LOG.info(_("test_method called with context %s" % context)) + LOG.info(_("test_method called with context %s") % context)