Fixed some of the overzealous _() wrapping to exclude the parameters being handed to the format strings.
This commit is contained in:
parent
cb7feed9d4
commit
da616fe58d
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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")
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user