summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-07 06:22:57 +0000
committerGerrit Code Review <review@openstack.org>2017-06-07 06:22:57 +0000
commitc5d5007d18bd43555804ac91a550d055efcd8ddb (patch)
treea4c98474315466d41d41408e5833d479be82152b
parentea9f8aec5c6efe93aa4aabd56daf1ac0d4e5d9f2 (diff)
parentded64b45c6db4e22d27aa66a7cfcd5784a771a1d (diff)
Merge "Handle log message interpolation by the logger in common/"8.0.0.0b2
-rw-r--r--trove/common/auth.py8
-rw-r--r--trove/common/cfg.py2
-rw-r--r--trove/common/exception.py2
-rw-r--r--trove/common/notification.py6
-rw-r--r--trove/common/server_group.py16
-rw-r--r--trove/common/utils.py4
-rw-r--r--trove/common/wsgi.py11
-rw-r--r--trove/tests/unittests/common/test_utils.py6
8 files changed, 30 insertions, 25 deletions
diff --git a/trove/common/auth.py b/trove/common/auth.py
index d32f9a6..674a963 100644
--- a/trove/common/auth.py
+++ b/trove/common/auth.py
@@ -30,22 +30,22 @@ class AuthorizationMiddleware(wsgi.Middleware):
30 30
31 def __init__(self, application, auth_providers, **local_config): 31 def __init__(self, application, auth_providers, **local_config):
32 self.auth_providers = auth_providers 32 self.auth_providers = auth_providers
33 LOG.debug("Auth middleware providers: %s" % auth_providers) 33 LOG.debug("Auth middleware providers: %s", auth_providers)
34 super(AuthorizationMiddleware, self).__init__(application, 34 super(AuthorizationMiddleware, self).__init__(application,
35 **local_config) 35 **local_config)
36 36
37 def process_request(self, request): 37 def process_request(self, request):
38 roles = request.headers.get('X_ROLE', '').split(',') 38 roles = request.headers.get('X_ROLE', '').split(',')
39 LOG.debug("Processing auth request with roles: %s" % roles) 39 LOG.debug("Processing auth request with roles: %s", roles)
40 tenant_id = request.headers.get('X-Tenant-Id', None) 40 tenant_id = request.headers.get('X-Tenant-Id', None)
41 LOG.debug("Processing auth request with tenant_id: %s" % tenant_id) 41 LOG.debug("Processing auth request with tenant_id: %s", tenant_id)
42 for provider in self.auth_providers: 42 for provider in self.auth_providers:
43 provider.authorize(request, tenant_id, roles) 43 provider.authorize(request, tenant_id, roles)
44 44
45 @classmethod 45 @classmethod
46 def factory(cls, global_config, **local_config): 46 def factory(cls, global_config, **local_config):
47 def _factory(app): 47 def _factory(app):
48 LOG.debug("Created auth middleware with config: %s" % 48 LOG.debug("Created auth middleware with config: %s",
49 local_config) 49 local_config)
50 return cls(app, [TenantBasedAuth()], **local_config) 50 return cls(app, [TenantBasedAuth()], **local_config)
51 return _factory 51 return _factory
diff --git a/trove/common/cfg.py b/trove/common/cfg.py
index e9e3dd1..b96eb03 100644
--- a/trove/common/cfg.py
+++ b/trove/common/cfg.py
@@ -1574,7 +1574,7 @@ def get_configuration_property(property_name):
1574 if not datastore_manager: 1574 if not datastore_manager:
1575 datastore_manager = 'mysql' 1575 datastore_manager = 'mysql'
1576 LOG.warning(_("Manager name ('datastore_manager') not defined, " 1576 LOG.warning(_("Manager name ('datastore_manager') not defined, "
1577 "using '%s' options instead.") % datastore_manager) 1577 "using '%s' options instead."), datastore_manager)
1578 1578
1579 try: 1579 try:
1580 return CONF.get(datastore_manager).get(property_name) 1580 return CONF.get(datastore_manager).get(property_name)
diff --git a/trove/common/exception.py b/trove/common/exception.py
index 50194f2..58f81f9 100644
--- a/trove/common/exception.py
+++ b/trove/common/exception.py
@@ -44,7 +44,7 @@ class TroveError(openstack_exception.OpenstackException):
44 self.message = message 44 self.message = message
45 if self.internal_message is not None: 45 if self.internal_message is not None:
46 try: 46 try:
47 LOG.error(safe_fmt_string(self.internal_message) % kwargs) 47 LOG.error(safe_fmt_string(self.internal_message), kwargs)
48 except Exception: 48 except Exception:
49 LOG.error(self.internal_message) 49 LOG.error(self.internal_message)
50 self.message = safe_fmt_string(self.message) 50 self.message = safe_fmt_string(self.message)
diff --git a/trove/common/notification.py b/trove/common/notification.py
index fa25b4c..73ec799 100644
--- a/trove/common/notification.py
+++ b/trove/common/notification.py
@@ -142,7 +142,7 @@ class TroveBaseTraits(object):
142 publisher_id = publisher_id or CONF.host 142 publisher_id = publisher_id or CONF.host
143 event_type = self.event_type_format % event_type 143 event_type = self.event_type_format % event_type
144 event_payload = self.serialize(self.context) 144 event_payload = self.serialize(self.context)
145 LOG.debug('Sending event: %(event_type)s, %(payload)s' % 145 LOG.debug('Sending event: %(event_type)s, %(payload)s',
146 {'event_type': event_type, 'payload': event_payload}) 146 {'event_type': event_type, 'payload': event_payload})
147 147
148 notifier = rpc.get_notifier( 148 notifier = rpc.get_notifier(
@@ -275,7 +275,7 @@ class DBaaSQuotas(object):
275 } 275 }
276 276
277 def notify(self): 277 def notify(self):
278 LOG.debug('Sending event: %(event_type)s, %(payload)s' % 278 LOG.debug('Sending event: %(event_type)s, %(payload)s',
279 {'event_type': DBaaSQuotas.event_type, 279 {'event_type': DBaaSQuotas.event_type,
280 'payload': self.payload}) 280 'payload': self.payload})
281 281
@@ -401,7 +401,7 @@ class DBaaSAPINotification(object):
401 401
402 qualified_event_type = (DBaaSAPINotification.event_type_format 402 qualified_event_type = (DBaaSAPINotification.event_type_format
403 % (self.event_type(), event_qualifier)) 403 % (self.event_type(), event_qualifier))
404 LOG.debug('Sending event: %(event_type)s, %(payload)s' % 404 LOG.debug('Sending event: %(event_type)s, %(payload)s',
405 {'event_type': qualified_event_type, 'payload': payload}) 405 {'event_type': qualified_event_type, 'payload': payload})
406 406
407 context = copy.copy(self.context) 407 context = copy.copy(self.context)
diff --git a/trove/common/server_group.py b/trove/common/server_group.py
index f66f6a2..a51a693 100644
--- a/trove/common/server_group.py
+++ b/trove/common/server_group.py
@@ -36,7 +36,7 @@ class ServerGroup(object):
36 if compute_id in sg.members: 36 if compute_id in sg.members:
37 server_group = sg 37 server_group = sg
38 except Exception: 38 except Exception:
39 LOG.exception(_("Could not load server group for compute %s") % 39 LOG.exception(_("Could not load server group for compute %s"),
40 compute_id) 40 compute_id)
41 return server_group 41 return server_group
42 42
@@ -46,8 +46,10 @@ class ServerGroup(object):
46 server_group_name = "%s_%s" % ('locality', name_suffix) 46 server_group_name = "%s_%s" % ('locality', name_suffix)
47 server_group = client.server_groups.create( 47 server_group = client.server_groups.create(
48 name=server_group_name, policies=[locality]) 48 name=server_group_name, policies=[locality])
49 LOG.debug("Created '%s' server group called %s (id: %s)." % 49 LOG.debug("Created '%(locality)s' server group called %(group_name)s "
50 (locality, server_group_name, server_group.id)) 50 "(id: %(group_id)s).",
51 {'locality': locality, 'group_name': server_group_name,
52 'group_id': server_group.id})
51 53
52 return server_group 54 return server_group
53 55
@@ -59,10 +61,12 @@ class ServerGroup(object):
59 if force or len(server_group.members) <= 1: 61 if force or len(server_group.members) <= 1:
60 client = create_nova_client(context) 62 client = create_nova_client(context)
61 client.server_groups.delete(server_group.id) 63 client.server_groups.delete(server_group.id)
62 LOG.debug("Deleted server group %s." % server_group.id) 64 LOG.debug("Deleted server group %s.", server_group.id)
63 else: 65 else:
64 LOG.debug("Skipping delete of server group %s (members: %s)." % 66 LOG.debug("Skipping delete of server group %(id)s "
65 (server_group.id, server_group.members)) 67 "(members: %(members)s).",
68 {'id': server_group.id,
69 'members': server_group.members})
66 70
67 @classmethod 71 @classmethod
68 def convert_to_hint(cls, server_group, hints=None): 72 def convert_to_hint(cls, server_group, hints=None):
diff --git a/trove/common/utils.py b/trove/common/utils.py
index 4efe477..9a81be4 100644
--- a/trove/common/utils.py
+++ b/trove/common/utils.py
@@ -246,7 +246,7 @@ def execute_with_timeout(*args, **kwargs):
246 LOG.error( 246 LOG.error(
247 _("Command '%(cmd)s' failed. %(description)s " 247 _("Command '%(cmd)s' failed. %(description)s "
248 "Exit code: %(exit_code)s\nstderr: %(stderr)s\n" 248 "Exit code: %(exit_code)s\nstderr: %(stderr)s\n"
249 "stdout: %(stdout)s") % 249 "stdout: %(stdout)s"),
250 {'cmd': e.cmd, 'description': e.description or '', 250 {'cmd': e.cmd, 'description': e.description or '',
251 'exit_code': e.exit_code, 'stderr': e.stderr, 251 'exit_code': e.exit_code, 'stderr': e.stderr,
252 'stdout': e.stdout}) 252 'stdout': e.stdout})
@@ -301,7 +301,7 @@ def try_recover(func):
301 if recover_func is not None: 301 if recover_func is not None:
302 recover_func(func) 302 recover_func(func)
303 else: 303 else:
304 LOG.debug("No recovery method defined for %(func)s" % { 304 LOG.debug("No recovery method defined for %(func)s", {
305 'func': func.__name__}) 305 'func': func.__name__})
306 raise 306 raise
307 return _decorator 307 return _decorator
diff --git a/trove/common/wsgi.py b/trove/common/wsgi.py
index c087f6c..c63e9bb 100644
--- a/trove/common/wsgi.py
+++ b/trove/common/wsgi.py
@@ -374,14 +374,13 @@ class Controller(object):
374 374
375 @classmethod 375 @classmethod
376 def get_schema(cls, action, body): 376 def get_schema(cls, action, body):
377 LOG.debug("Getting schema for %s:%s" % 377 LOG.debug("Getting schema for %(name)s:%(action)s",
378 (cls.__class__.__name__, action)) 378 {'name': cls.__class__.__name__, 'action': action})
379 if cls.schemas: 379 if cls.schemas:
380 matching_schema = cls.schemas.get(action, {}) 380 matching_schema = cls.schemas.get(action, {})
381 if matching_schema: 381 if matching_schema:
382 LOG.debug( 382 LOG.debug("Found Schema: %s",
383 "Found Schema: %s" % matching_schema.get("name", 383 matching_schema.get("name", matching_schema))
384 matching_schema))
385 return matching_schema 384 return matching_schema
386 385
387 @staticmethod 386 @staticmethod
@@ -557,7 +556,7 @@ class ContextMiddleware(base_wsgi.Middleware):
557 @classmethod 556 @classmethod
558 def factory(cls, global_config, **local_config): 557 def factory(cls, global_config, **local_config):
559 def _factory(app): 558 def _factory(app):
560 LOG.debug("Created context middleware with config: %s" % 559 LOG.debug("Created context middleware with config: %s",
561 local_config) 560 local_config)
562 return cls(app) 561 return cls(app)
563 562
diff --git a/trove/tests/unittests/common/test_utils.py b/trove/tests/unittests/common/test_utils.py
index c469a5f..87b3d31 100644
--- a/trove/tests/unittests/common/test_utils.py
+++ b/trove/tests/unittests/common/test_utils.py
@@ -63,8 +63,10 @@ class TestUtils(trove_testtools.TestCase):
63 '/usr/bin/foo', log_output_on_error=True) 63 '/usr/bin/foo', log_output_on_error=True)
64 64
65 utils.LOG.error.assert_called_with( 65 utils.LOG.error.assert_called_with(
66 u"Command 'test' failed. test-desc Exit code: 42\n" 66 u"Command '%(cmd)s' failed. %(description)s Exit code: "
67 "stderr: err\nstdout: out") 67 u"%(exit_code)s\nstderr: %(stderr)s\nstdout: %(stdout)s",
68 {'description': 'test-desc', 'stderr': 'err', 'exit_code': 42,
69 'stdout': 'out', 'cmd': 'test'})
68 70
69 def test_unpack_singleton(self): 71 def test_unpack_singleton(self):
70 self.assertEqual([1, 2, 3], utils.unpack_singleton([1, 2, 3])) 72 self.assertEqual([1, 2, 3], utils.unpack_singleton([1, 2, 3]))