From 1fc852b08c19369d4b4bbae970f5e7ee6e9df335 Mon Sep 17 00:00:00 2001 From: Amrith Kumar Date: Tue, 1 Jul 2014 13:22:37 -0400 Subject: [PATCH] Logging audit for trove/db module Adjust log messages to conform to logging standards. Cleanup some messages that were unclear. Change-Id: I0a67acd6aa7bef8cb9adb32cf0f821ba24a4cb92 Partial-Bug: #1324206 --- trove/db/models.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/trove/db/models.py b/trove/db/models.py index 23753286c8..f559e7bb1c 100644 --- a/trove/db/models.py +++ b/trove/db/models.py @@ -95,15 +95,19 @@ class DatabaseModelBase(models.ModelBase): model = cls.get_by(**conditions) if model is None: - raise exception.ModelNotFoundError(_("%s Not Found") % - cls.__name__) + raise exception.ModelNotFoundError(_("%(s_name)s Not Found") % + {"s_name": cls.__name__}) if ((context and not context.is_admin and hasattr(model, 'tenant_id') and model.tenant_id != context.tenant)): - LOG.error("Tenant %s tried to access %s, owned by %s." - % (context.tenant, cls.__name__, model.tenant_id)) - raise exception.ModelNotFoundError(_("%s Not Found") % - cls.__name__) + 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__})) return model