diff options
author | Zhao Chao <zhaochao1984@gmail.com> | 2018-01-22 13:55:36 +0800 |
---|---|---|
committer | Manoj Kumar <kumarmn@us.ibm.com> | 2018-01-24 17:21:26 +0000 |
commit | 2fd8c66f64b086104a9b00334f0eab71d4f49a9a (patch) | |
tree | 84834a950a0e850ac83f92fce75943f3ccd69f9f /trove/extensions | |
parent | a70d6b9cbebb8cce380ec387798e3e86fcde075f (diff) | |
download | trove-2fd8c66f64b086104a9b00334f0eab71d4f49a9a.tar.gz |
Remove log translations
According to discussions on the ML, log messages should not be
translated any more. This patch also:
* removes all usage of _LI, _LW, _LE, _LC;
* updates log translation hacking rule.
ML discussions:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html
The original commit messages are kept as following to make a historic
note:
remove unwanted log translations
recent discussions on the ML have led to the decision to eliminate all
translations for messages that are destined for log files but retain
them for messages that are going to be returned as exceptions and
potentially shown to end users via an API. see [1], [2].
This change does that as follows.
1. If a string is being used to generate an exception, it will still
be translated. Still Trove used both _LE and _ for these translations,
there are some cases where _LE has been simply changed to _, and not
removed.
2. If a string is used for a logging message, remove the use of _,
_LE, _LW, _LI.
Also, I have long felt that we have had a creep of checks in the pep8
tests that apparently make the code easier to read. I strongly believe
that these kinds of "easier to read" things make sense if they are
followed across all projects and not just gratuitously added one
project at a time.
I've taken this opportunity to reduce the merge mess caused by this
change, to sync up our ignore flags with a long list of ignores from
Nova. When they made the change for removing log translation, they
could do it in an automated-way like I have because they didn't have
to deal with under and overindented lines for visual edit (E127). Same
for Cinder.
Changes 448443 [3] and 447839 [4] were inadequate because they only
addressed a little part of the problem, namely removing the use of
_LE, _LI, and _LW, and I think this is a change we don't need to
dribble in a few files at a time. The changes are straightforward and
should be taken in a single lump to make it easy to deal with the
merges coming.
[1] http://lists.openstack.org/pipermail/openstack-operators/2017-March/012887.html
[2] http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html
[3] https://review.openstack.org/448443
[4] https://review.openstack.org/447839
Co-Authored-By: Amrith Kumar <amrith@amrith.org>
Co-Authored-By: Valencia Serrao <vserrao@us.ibm.com>
Change-Id: I5f86c982469e625997fc8bd15c6fae0fc77a8c64
Diffstat (limited to 'trove/extensions')
-rw-r--r-- | trove/extensions/account/service.py | 11 | ||||
-rw-r--r-- | trove/extensions/common/service.py | 25 | ||||
-rw-r--r-- | trove/extensions/mgmt/clusters/service.py | 12 | ||||
-rw-r--r-- | trove/extensions/mgmt/configuration/service.py | 6 | ||||
-rw-r--r-- | trove/extensions/mgmt/datastores/service.py | 15 | ||||
-rw-r--r-- | trove/extensions/mgmt/host/instance/service.py | 8 | ||||
-rw-r--r-- | trove/extensions/mgmt/host/models.py | 6 | ||||
-rw-r--r-- | trove/extensions/mgmt/host/service.py | 11 | ||||
-rw-r--r-- | trove/extensions/mgmt/instances/models.py | 6 | ||||
-rw-r--r-- | trove/extensions/mgmt/instances/service.py | 54 | ||||
-rw-r--r-- | trove/extensions/mgmt/quota/service.py | 8 | ||||
-rw-r--r-- | trove/extensions/mgmt/upgrade/service.py | 5 | ||||
-rw-r--r-- | trove/extensions/mgmt/volume/service.py | 5 | ||||
-rw-r--r-- | trove/extensions/mysql/service.py | 58 | ||||
-rw-r--r-- | trove/extensions/redis/service.py | 40 | ||||
-rw-r--r-- | trove/extensions/security_group/models.py | 12 | ||||
-rw-r--r-- | trove/extensions/security_group/service.py | 9 |
17 files changed, 141 insertions, 150 deletions
diff --git a/trove/extensions/account/service.py b/trove/extensions/account/service.py index 025c53cc..525b7d99 100644 --- a/trove/extensions/account/service.py +++ b/trove/extensions/account/service.py @@ -17,7 +17,6 @@ from oslo_log import log as logging import trove.common.apischema as apischema from trove.common.auth import admin_context -from trove.common.i18n import _ from trove.common import wsgi from trove.extensions.account import models from trove.extensions.account import views @@ -32,9 +31,9 @@ class AccountController(wsgi.Controller): @admin_context def show(self, req, tenant_id, id): """Return a account and instances associated with a single account.""" - LOG.info(_("req : '%s'\n\n"), req) - LOG.info(_("Showing account information for '%(account)s' " - "to '%(tenant)s'"), {'account': id, 'tenant': tenant_id}) + LOG.info("req : '%s'\n\n", req) + LOG.info("Showing account information for '%(account)s' " + "to '%(tenant)s'", {'account': id, 'tenant': tenant_id}) context = req.environ[wsgi.CONTEXT_KEY] account = models.Account.load(context, id) @@ -43,7 +42,7 @@ class AccountController(wsgi.Controller): @admin_context def index(self, req, tenant_id): """Return a list of all accounts with non-deleted instances.""" - LOG.info(_("req : '%s'\n\n"), req) - LOG.info(_("Showing all accounts with instances for '%s'"), tenant_id) + LOG.info("req : '%s'\n\n", req) + LOG.info("Showing all accounts with instances for '%s'", tenant_id) accounts_summary = models.AccountsSummary.load() return wsgi.Result(views.AccountsView(accounts_summary).data(), 200) diff --git a/trove/extensions/common/service.py b/trove/extensions/common/service.py index 7023f1f6..4d4629d5 100644 --- a/trove/extensions/common/service.py +++ b/trove/extensions/common/service.py @@ -26,7 +26,6 @@ from trove.cluster.models import DBCluster from trove.common import cfg from trove.common import exception from trove.common.i18n import _ -from trove.common.i18n import _LI from trove.common import policy from trove.common import wsgi from trove.datastore import models as datastore_models @@ -93,8 +92,8 @@ class DefaultRootController(BaseDatastoreRootController): if is_cluster: raise exception.ClusterOperationNotSupported( operation='show_root') - LOG.info(_LI("Getting root enabled for instance '%s'."), instance_id) - LOG.info(_LI("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) @@ -103,8 +102,8 @@ class DefaultRootController(BaseDatastoreRootController): if is_cluster: raise exception.ClusterOperationNotSupported( operation='enable_root') - LOG.info(_LI("Enabling root for instance '%s'."), instance_id) - LOG.info(_LI("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] user_name = context.user password = DefaultRootController._get_password_from_body(body) @@ -116,8 +115,8 @@ class DefaultRootController(BaseDatastoreRootController): if is_cluster: raise exception.ClusterOperationNotSupported( operation='disable_root') - LOG.info(_LI("Disabling root for instance '%s'."), instance_id) - LOG.info(_LI("req : '%s'\n\n"), req) + LOG.info("Disabling root for instance '%s'.", instance_id) + LOG.info("req : '%s'\n\n", req) context = req.environ[wsgi.CONTEXT_KEY] try: found_user = self._find_root_user(context, instance_id) @@ -139,8 +138,8 @@ class ClusterRootController(DefaultRootController): return self.instance_root_index(req, tenant_id, instance_id) def instance_root_index(self, req, tenant_id, instance_id): - LOG.info(_LI("Getting root enabled for instance '%s'."), instance_id) - LOG.info(_LI("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] try: is_root_enabled = models.ClusterRoot.load(context, instance_id) @@ -150,7 +149,7 @@ class ClusterRootController(DefaultRootController): return wsgi.Result(views.RootEnabledView(is_root_enabled).data(), 200) def cluster_root_index(self, req, tenant_id, cluster_id): - LOG.info(_LI("Getting root enabled for cluster '%s'."), cluster_id) + LOG.info("Getting root enabled for cluster '%s'.", cluster_id) single_instance_id, cluster_instances = self._get_cluster_instance_id( tenant_id, cluster_id) return self.instance_root_index(req, tenant_id, single_instance_id) @@ -173,8 +172,8 @@ class ClusterRootController(DefaultRootController): def instance_root_create(self, req, body, instance_id, cluster_instances=None): - LOG.info(_LI("Enabling root for instance '%s'."), instance_id) - LOG.info(_LI("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] user_name = context.user password = ClusterRootController._get_password_from_body(body) @@ -183,7 +182,7 @@ class ClusterRootController(DefaultRootController): return wsgi.Result(views.RootCreatedView(root).data(), 200) def cluster_root_create(self, req, body, tenant_id, cluster_id): - LOG.info(_LI("Enabling root for cluster '%s'."), cluster_id) + LOG.info("Enabling root for cluster '%s'.", cluster_id) single_instance_id, cluster_instances = self._get_cluster_instance_id( tenant_id, cluster_id) return self.instance_root_create(req, body, single_instance_id, diff --git a/trove/extensions/mgmt/clusters/service.py b/trove/extensions/mgmt/clusters/service.py index a955eeef..35b2214f 100644 --- a/trove/extensions/mgmt/clusters/service.py +++ b/trove/extensions/mgmt/clusters/service.py @@ -41,7 +41,7 @@ class MgmtClusterController(ClusterController): def index(self, req, tenant_id): """Return a list of clusters.""" LOG.debug("Showing a list of clusters for tenant '%s'.", tenant_id) - LOG.info(_("req : '%s'\n\n"), req) + LOG.info("req : '%s'\n\n", req) context = req.environ[wsgi.CONTEXT_KEY] deleted = None deleted_q = req.GET.get('deleted', '').lower() @@ -56,10 +56,10 @@ class MgmtClusterController(ClusterController): @admin_context def show(self, req, tenant_id, id): """Return a single cluster.""" - LOG.info(_("Showing cluster for tenant '%(tenant_id)s'.\n" - "req : '%(req)s'\n" - "id : '%(id)s'"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Showing cluster for tenant '%(tenant_id)s'.\n" + "req : '%(req)s'\n" + "id : '%(id)s'", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] cluster = models.MgmtCluster.load(context, id) @@ -72,7 +72,7 @@ class MgmtClusterController(ClusterController): LOG.debug("Committing an action against cluster %(cluster)s for " "tenant '%(tenant)s'.", {'cluster': id, 'tenant': tenant_id}) - LOG.info(_("req : '%s'\n\n"), req) + LOG.info("req : '%s'\n\n", req) if not body: raise exception.BadRequest(_("Invalid request body.")) context = req.environ[wsgi.CONTEXT_KEY] diff --git a/trove/extensions/mgmt/configuration/service.py b/trove/extensions/mgmt/configuration/service.py index c4d84052..85de2c8b 100644 --- a/trove/extensions/mgmt/configuration/service.py +++ b/trove/extensions/mgmt/configuration/service.py @@ -74,7 +74,7 @@ class ConfigurationsParameterController(wsgi.Controller): @admin_context def create(self, req, body, tenant_id, version_id): """Create configuration parameter for datastore version.""" - LOG.info(_("Creating configuration parameter for datastore")) + LOG.info("Creating configuration parameter for datastore") LOG.debug("req : '%s'\n\n", req) LOG.debug("body : '%s'\n\n", body) if not body: @@ -101,7 +101,7 @@ class ConfigurationsParameterController(wsgi.Controller): @admin_context def update(self, req, body, tenant_id, version_id, id): """Updating configuration parameter for datastore version.""" - LOG.info(_("Updating configuration parameter for datastore")) + LOG.info("Updating configuration parameter for datastore") LOG.debug("req : '%s'\n\n", req) LOG.debug("body : '%s'\n\n", body) if not body: @@ -126,7 +126,7 @@ class ConfigurationsParameterController(wsgi.Controller): @admin_context def delete(self, req, tenant_id, version_id, id): """Delete configuration parameter for datastore version.""" - LOG.info(_("Deleting configuration parameter for datastore")) + LOG.info("Deleting configuration parameter for datastore") LOG.debug("req : '%s'\n\n", req) ds_config_params = config_models.DatastoreConfigurationParameters try: diff --git a/trove/extensions/mgmt/datastores/service.py b/trove/extensions/mgmt/datastores/service.py index 23643ae0..0f09dfcd 100644 --- a/trove/extensions/mgmt/datastores/service.py +++ b/trove/extensions/mgmt/datastores/service.py @@ -20,7 +20,6 @@ from trove.common import apischema from trove.common.auth import admin_context from trove.common import exception from trove.common import glance_remote -from trove.common.i18n import _ from trove.common import utils from trove.common import wsgi from trove.datastore import models @@ -48,8 +47,8 @@ class DatastoreVersionController(wsgi.Controller): active = body['version']['active'] default = body['version']['default'] - LOG.info(_("Tenant: '%(tenant)s' is adding the datastore " - "version: '%(version)s' to datastore: '%(datastore)s'"), + LOG.info("Tenant: '%(tenant)s' is adding the datastore " + "version: '%(version)s' to datastore: '%(datastore)s'", {'tenant': tenant_id, 'version': version_name, 'datastore': datastore_name}) @@ -63,7 +62,7 @@ class DatastoreVersionController(wsgi.Controller): datastore = models.Datastore.load(datastore_name) except exception.DatastoreNotFound: # Create the datastore if datastore_name does not exists. - LOG.info(_("Creating datastore %s"), datastore_name) + LOG.info("Creating datastore %s", datastore_name) datastore = models.DBDatastore() datastore.id = utils.generate_uuid() datastore.name = datastore_name @@ -106,8 +105,8 @@ class DatastoreVersionController(wsgi.Controller): context = req.environ[wsgi.CONTEXT_KEY] datastore_version = models.DatastoreVersion.load_by_uuid(id) - LOG.info(_("Tenant: '%(tenant)s' is updating the datastore " - "version: '%(version)s' for datastore: '%(datastore)s'"), + LOG.info("Tenant: '%(tenant)s' is updating the datastore " + "version: '%(version)s' for datastore: '%(datastore)s'", {'tenant': tenant_id, 'version': datastore_version.name, 'datastore': datastore_version.datastore_name}) @@ -144,8 +143,8 @@ class DatastoreVersionController(wsgi.Controller): datastore_version = models.DatastoreVersion.load_by_uuid(id) datastore = models.Datastore.load(datastore_version.datastore_id) - LOG.info(_("Tenant: '%(tenant)s' is removing the datastore " - "version: '%(version)s' for datastore: '%(datastore)s'"), + LOG.info("Tenant: '%(tenant)s' is removing the datastore " + "version: '%(version)s' for datastore: '%(datastore)s'", {'tenant': tenant_id, 'version': datastore_version.name, 'datastore': datastore.name}) diff --git a/trove/extensions/mgmt/host/instance/service.py b/trove/extensions/mgmt/host/instance/service.py index b923dc0b..ff29fffb 100644 --- a/trove/extensions/mgmt/host/instance/service.py +++ b/trove/extensions/mgmt/host/instance/service.py @@ -28,10 +28,10 @@ class HostInstanceController(wsgi.Controller): """Controller for all instances on specific hosts.""" def action(self, req, body, tenant_id, host_id): - LOG.info(_("Committing an ACTION against host %(host_id)s for " - "tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), {"req": req, "host_id": host_id, - "tenant_id": tenant_id}) + LOG.info("Committing an ACTION against host %(host_id)s for " + "tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", {"req": req, "host_id": host_id, + "tenant_id": tenant_id}) if not body: raise exception.BadRequest(_("Invalid request body.")) diff --git a/trove/extensions/mgmt/host/models.py b/trove/extensions/mgmt/host/models.py index 8778c5ac..e26ac4fe 100644 --- a/trove/extensions/mgmt/host/models.py +++ b/trove/extensions/mgmt/host/models.py @@ -72,8 +72,8 @@ class DetailedHost(object): instance['status'] = instance_info.status except exception.TroveError as re: LOG.error(re) - LOG.error(_("Compute Instance ID found with no associated RD " - "instance: %s."), instance['server_id']) + LOG.error("Compute Instance ID found with no associated RD " + "instance: %s.", instance['server_id']) instance['id'] = None def update_all(self, context): @@ -87,7 +87,7 @@ class DetailedHost(object): client.update_guest() except exception.TroveError as re: LOG.error(re) - LOG.error(_("Unable to update instance: %s."), instance['id']) + LOG.error("Unable to update instance: %s.", instance['id']) failed_instances.append(instance['id']) if len(failed_instances) > 0: msg = _("Failed to update instances: %s.") % failed_instances diff --git a/trove/extensions/mgmt/host/service.py b/trove/extensions/mgmt/host/service.py index 15b21278..9e0d0bf2 100644 --- a/trove/extensions/mgmt/host/service.py +++ b/trove/extensions/mgmt/host/service.py @@ -16,7 +16,6 @@ from oslo_log import log as logging from trove.common.auth import admin_context -from trove.common.i18n import _ from trove.common import wsgi from trove.extensions.mgmt.host import models from trove.extensions.mgmt.host import views @@ -31,8 +30,8 @@ class HostController(InstanceController): @admin_context def index(self, req, tenant_id, detailed=False): """Return all hosts.""" - LOG.info(_("req : '%s'\n\n"), req) - LOG.info(_("Indexing a host for tenant '%s'"), tenant_id) + LOG.info("req : '%s'\n\n", req) + LOG.info("Indexing a host for tenant '%s'", tenant_id) context = req.environ[wsgi.CONTEXT_KEY] hosts = models.SimpleHost.load_all(context) return wsgi.Result(views.HostsView(hosts).data(), 200) @@ -40,9 +39,9 @@ class HostController(InstanceController): @admin_context def show(self, req, tenant_id, id): """Return a single host.""" - LOG.info(_("req : '%s'\n\n"), req) - LOG.info(_("Showing a host for tenant '%s'"), tenant_id) - LOG.info(_("id : '%s'\n\n"), id) + LOG.info("req : '%s'\n\n", req) + LOG.info("Showing a host for tenant '%s'", tenant_id) + LOG.info("id : '%s'\n\n", id) context = req.environ[wsgi.CONTEXT_KEY] host = models.DetailedHost.load(context, id) return wsgi.Result(views.HostDetailedView(host).data(), 200) diff --git a/trove/extensions/mgmt/instances/models.py b/trove/extensions/mgmt/instances/models.py index 64da1a1e..605704b5 100644 --- a/trove/extensions/mgmt/instances/models.py +++ b/trove/extensions/mgmt/instances/models.py @@ -36,7 +36,7 @@ def load_mgmt_instances(context, deleted=None, client=None, mgmt_servers = client.rdservers.list() except AttributeError: mgmt_servers = client.servers.list(search_opts={'all_tenants': 1}) - LOG.info(_("Found %d servers in Nova"), + LOG.info("Found %d servers in Nova", len(mgmt_servers if mgmt_servers else [])) args = {} if deleted is not None: @@ -198,7 +198,7 @@ class NotificationTransformer(object): datastore_manager_id = id_map[datastore_manager] else: datastore_manager_id = cfg.UNKNOWN_SERVICE_ID - LOG.error(_("Datastore ID for Manager (%s) is not configured"), + LOG.error("Datastore ID for Manager (%s) is not configured", datastore_manager) return datastore_manager_id @@ -257,7 +257,7 @@ class NovaNotificationTransformer(NotificationTransformer): LOG.debug("Flavor cache hit for %s", flavor_id) return self._flavor_cache[flavor_id] # fetch flavor resource from nova - LOG.info(_("Flavor cache miss for %s"), flavor_id) + LOG.info("Flavor cache miss for %s", flavor_id) flavor = self.nova_client.flavors.get(flavor_id) self._flavor_cache[flavor_id] = flavor.name if flavor else 'unknown' return self._flavor_cache[flavor_id] diff --git a/trove/extensions/mgmt/instances/service.py b/trove/extensions/mgmt/instances/service.py index 9e3fae6e..914dc9a6 100644 --- a/trove/extensions/mgmt/instances/service.py +++ b/trove/extensions/mgmt/instances/service.py @@ -49,9 +49,9 @@ class MgmtInstanceController(InstanceController): @admin_context def index(self, req, tenant_id, detailed=False): """Return all instances.""" - LOG.info(_("Indexing a database instance for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req}) + LOG.info("Indexing a database instance for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] deleted = None deleted_q = req.GET.get('deleted', '').lower() @@ -74,10 +74,10 @@ class MgmtInstanceController(InstanceController): @admin_context def show(self, req, tenant_id, id): """Return a single instance.""" - LOG.info(_("Showing a database instance %(id)s for tenant " - "'%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Showing a database instance %(id)s for tenant " + "'%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] deleted_q = req.GET.get('deleted', '').lower() include_deleted = deleted_q == 'true' @@ -94,10 +94,10 @@ class MgmtInstanceController(InstanceController): @admin_context def action(self, req, body, tenant_id, id): - LOG.info(_("Committing an ACTION against a database " - "instance %(id)s for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Committing an ACTION against a database " + "instance %(id)s for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) if not body: raise exception.BadRequest(_("Invalid request body.")) context = req.environ[wsgi.CONTEXT_KEY] @@ -159,10 +159,10 @@ class MgmtInstanceController(InstanceController): """Return the date and time root was enabled on an instance, if ever. """ - LOG.info(_("Showing root history for a database " - "instance %(id)s for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Showing root history for a database " + "instance %(id)s for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] try: @@ -180,10 +180,10 @@ class MgmtInstanceController(InstanceController): @admin_context def hwinfo(self, req, tenant_id, id): """Return a single instance hardware info.""" - LOG.info(_("Showing hardware info for a database " - "instance %(id)s for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Showing hardware info for a database " + "instance %(id)s for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] instance = models.MgmtInstance.load(context=context, id=id) @@ -194,10 +194,10 @@ class MgmtInstanceController(InstanceController): @admin_context def diagnostics(self, req, tenant_id, id): """Return instance diagnostics for a single instance.""" - LOG.info(_("Showing diagnostic info for a database " - "instance %(id)s for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Showing diagnostic info for a database " + "instance %(id)s for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] instance = models.MgmtInstance.load(context=context, id=id) @@ -208,10 +208,10 @@ class MgmtInstanceController(InstanceController): @admin_context def rpc_ping(self, req, tenant_id, id): """Checks if instance is reachable via rpc.""" - LOG.info(_("Sending RPC PING for a database " - "instance %(id)s for tenant '%(tenant_id)s'\n" - "req : '%(req)s'\n\n"), { - "tenant_id": tenant_id, "req": req, "id": id}) + LOG.info("Sending RPC PING for a database " + "instance %(id)s for tenant '%(tenant_id)s'\n" + "req : '%(req)s'\n\n", { + "tenant_id": tenant_id, "req": req, "id": id}) context = req.environ[wsgi.CONTEXT_KEY] instance = models.MgmtInstance.load(context=context, id=id) diff --git a/trove/extensions/mgmt/quota/service.py b/trove/extensions/mgmt/quota/service.py index b61f4fb2..1879f165 100644 --- a/trove/extensions/mgmt/quota/service.py +++ b/trove/extensions/mgmt/quota/service.py @@ -32,8 +32,8 @@ class QuotaController(wsgi.Controller): @admin_context def show(self, req, tenant_id, id): """Return all quotas for this tenant.""" - LOG.info(_("Indexing quota info for tenant '%(id)s'\n" - "req : '%(req)s'\n\n"), {"id": id, "req": req}) + LOG.info("Indexing quota info for tenant '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": id, "req": req}) usages = quota_engine.get_all_quota_usages_by_tenant(id) limits = quota_engine.get_all_quotas_by_tenant(id) @@ -43,8 +43,8 @@ class QuotaController(wsgi.Controller): @admin_context def update(self, req, body, tenant_id, id): - LOG.info(_("Updating quota limits for tenant '%(id)s'\n" - "req : '%(req)s'\n\n"), {"id": id, "req": req}) + LOG.info("Updating quota limits for tenant '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": id, "req": req}) if not body: raise exception.BadRequest(_("Invalid request body.")) diff --git a/trove/extensions/mgmt/upgrade/service.py b/trove/extensions/mgmt/upgrade/service.py index d4eba194..036d9d3c 100644 --- a/trove/extensions/mgmt/upgrade/service.py +++ b/trove/extensions/mgmt/upgrade/service.py @@ -17,7 +17,6 @@ from oslo_log import log as logging import trove.common.apischema as apischema from trove.common.auth import admin_context -from trove.common.i18n import _ from trove.common import wsgi from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender @@ -33,8 +32,8 @@ class UpgradeController(wsgi.Controller): @admin_context def create(self, req, body, tenant_id, instance_id): - LOG.info(_("Sending upgrade notifications\nreq : '%(req)s'\n" - "Admin tenant_id: %(tenant_id)s"), + LOG.info("Sending upgrade notifications\nreq : '%(req)s'\n" + "Admin tenant_id: %(tenant_id)s", {"tenant_id": tenant_id, "req": req}) context = req.environ.get(wsgi.CONTEXT_KEY) diff --git a/trove/extensions/mgmt/volume/service.py b/trove/extensions/mgmt/volume/service.py index 2761e8e2..a756258b 100644 --- a/trove/extensions/mgmt/volume/service.py +++ b/trove/extensions/mgmt/volume/service.py @@ -18,7 +18,6 @@ from oslo_log import log as logging from trove.common.auth import admin_context from trove.common import cfg -from trove.common.i18n import _ from trove.common import wsgi from trove.extensions.mgmt.volume import models from trove.extensions.mgmt.volume import views @@ -33,8 +32,8 @@ class StorageController(wsgi.Controller): @admin_context def index(self, req, tenant_id): """Return all storage devices.""" - LOG.info(_("req : '%s'\n\n"), req) - LOG.info(_("Indexing storage info for tenant '%s'"), tenant_id) + LOG.info("req : '%s'\n\n", req) + LOG.info("Indexing storage info for tenant '%s'", tenant_id) context = req.environ[wsgi.CONTEXT_KEY] storages = models.StorageDevices.load(context, CONF.os_region_name) return wsgi.Result(views.StoragesView(storages).data(), 200) diff --git a/trove/extensions/mysql/service.py b/trove/extensions/mysql/service.py index b5784a02..306ebd6f 100644 --- a/trove/extensions/mysql/service.py +++ b/trove/extensions/mysql/service.py @@ -57,8 +57,8 @@ class UserController(ExtensionController): def index(self, req, tenant_id, instance_id): """Return all users.""" - LOG.info(_("Listing users for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Listing users for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action(context, 'user:index', instance_id) @@ -70,9 +70,9 @@ class UserController(ExtensionController): def create(self, req, body, tenant_id, instance_id): """Creates a set of users.""" - LOG.info(_("Creating users for instance '%(id)s'\n" - "req : '%(req)s'\n\n" - "body: '%(body)s'\n'n"), + LOG.info("Creating users for instance '%(id)s'\n" + "req : '%(req)s'\n\n" + "body: '%(body)s'\n'n", {"id": instance_id, "req": strutils.mask_password(req), "body": strutils.mask_password(body)}) @@ -93,8 +93,8 @@ class UserController(ExtensionController): return wsgi.Result(None, 202) def delete(self, req, tenant_id, instance_id, id): - LOG.info(_("Delete instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Delete instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action(context, 'user:delete', instance_id) @@ -122,8 +122,8 @@ class UserController(ExtensionController): def show(self, req, tenant_id, instance_id, id): """Return a single user.""" - LOG.info(_("Showing a user for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Showing a user for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action(context, 'user:show', instance_id) @@ -142,8 +142,8 @@ class UserController(ExtensionController): def update(self, req, body, tenant_id, instance_id, id): """Change attributes for one user.""" - LOG.info(_("Updating user attributes for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Updating user attributes for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": strutils.mask_password(req)}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action(context, 'user:update', instance_id) @@ -173,8 +173,8 @@ class UserController(ExtensionController): def update_all(self, req, body, tenant_id, instance_id): """Change the password of one or more users.""" - LOG.info(_("Updating user password for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Updating user password for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": strutils.mask_password(req)}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action(context, 'user:update_all', instance_id) @@ -234,8 +234,8 @@ class UserAccessController(ExtensionController): def index(self, req, tenant_id, instance_id, user_id): """Show permissions for the given user.""" - LOG.info(_("Showing user access for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Showing user access for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] @@ -245,7 +245,7 @@ class UserAccessController(ExtensionController): user_id = correct_id_with_req(user_id, req) user = self._get_user(context, instance_id, user_id) if not user: - LOG.error(_("No such user: %(user)s "), {'user': user}) + LOG.error("No such user: %(user)s ", {'user': user}) raise exception.UserNotFound(uuid=user) username, hostname = unquote_user_host(user_id) access = models.User.access(context, instance_id, username, hostname) @@ -254,8 +254,8 @@ class UserAccessController(ExtensionController): def update(self, req, body, tenant_id, instance_id, user_id): """Grant access for a user to one or more databases.""" - LOG.info(_("Granting user access for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Granting user access for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action( @@ -265,7 +265,7 @@ class UserAccessController(ExtensionController): user_id = correct_id_with_req(user_id, req) user = self._get_user(context, instance_id, user_id) if not user: - LOG.error(_("No such user: %(user)s "), {'user': user}) + LOG.error("No such user: %(user)s ", {'user': user}) raise exception.UserNotFound(uuid=user) username, hostname = unquote_user_host(user_id) databases = [db['name'] for db in body['databases']] @@ -277,8 +277,8 @@ class UserAccessController(ExtensionController): def delete(self, req, tenant_id, instance_id, user_id, id): """Revoke access for a user.""" - LOG.info(_("Revoking user access for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Revoking user access for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action( @@ -288,7 +288,7 @@ class UserAccessController(ExtensionController): user_id = correct_id_with_req(user_id, req) user = self._get_user(context, instance_id, user_id) if not user: - LOG.error(_("No such user: %(user)s "), {'user': user}) + LOG.error("No such user: %(user)s ", {'user': user}) raise exception.UserNotFound(uuid=user) username, hostname = unquote_user_host(user_id) access = models.User.access(context, instance_id, username, hostname) @@ -307,8 +307,8 @@ class SchemaController(ExtensionController): def index(self, req, tenant_id, instance_id): """Return all schemas.""" - LOG.info(_("Listing schemas for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Listing schemas for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] @@ -322,9 +322,9 @@ class SchemaController(ExtensionController): def create(self, req, body, tenant_id, instance_id): """Creates a set of schemas.""" - LOG.info(_("Creating schema for instance '%(id)s'\n" - "req : '%(req)s'\n\n" - "body: '%(body)s'\n'n"), + LOG.info("Creating schema for instance '%(id)s'\n" + "req : '%(req)s'\n\n" + "body: '%(body)s'\n'n", {"id": instance_id, "req": req, "body": body}) @@ -347,8 +347,8 @@ class SchemaController(ExtensionController): return wsgi.Result(None, 202) def delete(self, req, tenant_id, instance_id, id): - LOG.info(_("Deleting schema for instance '%(id)s'\n" - "req : '%(req)s'\n\n"), + LOG.info("Deleting schema for instance '%(id)s'\n" + "req : '%(req)s'\n\n", {"id": instance_id, "req": req}) context = req.environ[wsgi.CONTEXT_KEY] self.authorize_target_action( diff --git a/trove/extensions/redis/service.py b/trove/extensions/redis/service.py index 6788a3de..8bee2d4d 100644 --- a/trove/extensions/redis/service.py +++ b/trove/extensions/redis/service.py @@ -18,8 +18,6 @@ from oslo_log import log as logging from trove.common import cfg from trove.common import exception from trove.common.i18n import _ -from trove.common.i18n import _LE -from trove.common.i18n import _LI from trove.common import wsgi from trove.extensions.common.service import DefaultRootController from trove.extensions.redis.models import RedisRoot @@ -52,9 +50,9 @@ class RedisRootController(DefaultRootController): def _instance_root_create(self, req, instance_id, password, slave_instances=None): - LOG.info(_LI("Enabling authentication for instance '%s'."), + LOG.info("Enabling authentication for instance '%s'.", instance_id) - LOG.info(_LI("req : '%s'\n\n"), req) + LOG.info("req : '%s'\n\n", req) context = req.environ[wsgi.CONTEXT_KEY] user_name = context.user @@ -70,15 +68,15 @@ class RedisRootController(DefaultRootController): except exception.TroveError: self._rollback_once(req, instance_id, original_auth_password) raise exception.TroveError( - _LE("Failed to do root-enable for instance " - "'%(instance_id)s'.") % {'instance_id': instance_id} + _("Failed to do root-enable for instance " + "'%(instance_id)s'.") % {'instance_id': instance_id} ) failed_slaves = [] for slave_id in slave_instances: try: - LOG.info(_LI("Enabling authentication for slave instance " - "'%s'."), slave_id) + LOG.info("Enabling authentication for slave instance " + "'%s'.", slave_id) RedisRoot.create(context, slave_id, user_name, password) except exception.TroveError: failed_slaves.append(slave_id) @@ -87,9 +85,9 @@ class RedisRootController(DefaultRootController): RedisRootCreatedView(root, failed_slaves).data(), 200) def _instance_root_delete(self, req, instance_id, slave_instances=None): - LOG.info(_LI("Disabling authentication for instance '%s'."), + LOG.info("Disabling authentication for instance '%s'.", instance_id) - LOG.info(_LI("req : '%s'\n\n"), req) + LOG.info("req : '%s'\n\n", req) context = req.environ[wsgi.CONTEXT_KEY] original_auth_password = self._get_original_auth_password( @@ -101,15 +99,15 @@ class RedisRootController(DefaultRootController): except exception.TroveError: self._rollback_once(req, instance_id, original_auth_password) raise exception.TroveError( - _LE("Failed to do root-disable for instance " - "'%(instance_id)s'.") % {'instance_id': instance_id} + _("Failed to do root-disable for instance " + "'%(instance_id)s'.") % {'instance_id': instance_id} ) failed_slaves = [] for slave_id in slave_instances: try: - LOG.info(_LI("Disabling authentication for slave instance " - "'%s'."), slave_id) + LOG.info("Disabling authentication for slave instance " + "'%s'.", slave_id) RedisRoot.delete(context, slave_id) except exception.TroveError: failed_slaves.append(slave_id) @@ -124,8 +122,8 @@ class RedisRootController(DefaultRootController): @staticmethod def _rollback_once(req, instance_id, original_auth_password): - LOG.info(_LI("Rolling back enable/disable authentication " - "for instance '%s'."), instance_id) + LOG.info("Rolling back enable/disable authentication " + "for instance '%s'.", instance_id) context = req.environ[wsgi.CONTEXT_KEY] user_name = context.user try: @@ -138,7 +136,7 @@ class RedisRootController(DefaultRootController): RedisRoot.create(context, instance_id, user_name, original_auth_password) except exception.TroveError: - LOG.exception(_("Rolling back failed for instance '%s'"), + LOG.exception("Rolling back failed for instance '%s'", instance_id) @staticmethod @@ -149,8 +147,8 @@ class RedisRootController(DefaultRootController): @staticmethod def _get_slaves(tenant_id, instance_or_cluster_id, deleted=False): - LOG.info(_LI("Getting non-deleted slaves of instance '%s', " - "if any."), instance_or_cluster_id) + LOG.info("Getting non-deleted slaves of instance '%s', " + "if any.", instance_or_cluster_id) args = {'slave_of_id': instance_or_cluster_id, 'tenant_id': tenant_id, 'deleted': deleted} db_infos = DBInstance.find_all(**args) @@ -168,8 +166,8 @@ class RedisRootController(DefaultRootController): password = RedisRoot.get_auth_password(context, instance_id) except exception.TroveError: raise exception.TroveError( - _LE("Failed to get original auth password of instance " - "'%(instance_id)s'.") % {'instance_id': instance_id} + _("Failed to get original auth password of instance " + "'%(instance_id)s'.") % {'instance_id': instance_id} ) return password diff --git a/trove/extensions/security_group/models.py b/trove/extensions/security_group/models.py index 5e191437..ac8c327c 100644 --- a/trove/extensions/security_group/models.py +++ b/trove/extensions/security_group/models.py @@ -66,7 +66,7 @@ class SecurityGroup(DatabaseModelBase): tenant_id=context.tenant) except exception.SecurityGroupCreationError: - LOG.exception(_("Failed to create remote security group.")) + LOG.exception("Failed to create remote security group.") raise @classmethod @@ -112,7 +112,7 @@ class SecurityGroup(DatabaseModelBase): super(SecurityGroup, self).delete() except exception.TroveError: - LOG.exception(_('Failed to delete security group.')) + LOG.exception('Failed to delete security group.') raise exception.TroveError("Failed to delete Security Group") @classmethod @@ -128,8 +128,8 @@ class SecurityGroup(DatabaseModelBase): association.delete() except (exception.ModelNotFoundError, exception.TroveError): - LOG.info(_('Security Group with id: %(id)s ' - 'already had been deleted'), + LOG.info('Security Group with id: %(id)s ' + 'already had been deleted', {'id': instance_id}) @@ -165,7 +165,7 @@ class SecurityGroupRule(DatabaseModelBase): group_id=sec_group['id']) except exception.SecurityGroupRuleCreationError: - LOG.exception(_("Failed to create remote security group rule.")) + LOG.exception("Failed to create remote security group rule.") raise def get_security_group(self, tenant_id): @@ -179,7 +179,7 @@ class SecurityGroupRule(DatabaseModelBase): RemoteSecurityGroup.delete_rule(self.id, context, region_name) super(SecurityGroupRule, self).delete() except exception.TroveError: - LOG.exception(_('Failed to delete remote security group rule.')) + LOG.exception('Failed to delete remote security group rule.') raise exception.SecurityGroupRuleDeletionError( "Failed to delete Remote Security Group Rule") diff --git a/trove/extensions/security_group/service.py b/trove/extensions/security_group/service.py index 99073dc4..05100f12 100644 --- a/trove/extensions/security_group/service.py +++ b/trove/extensions/security_group/service.py @@ -18,7 +18,6 @@ from oslo_log import log as logging from trove.common import cfg from trove.common import exception -from trove.common.i18n import _ from trove.common import wsgi from trove.datastore.models import DatastoreVersion from trove.extensions.security_group import models @@ -74,8 +73,8 @@ class SecurityGroupRuleController(wsgi.Controller): sec_group = sec_group_rule.get_security_group(tenant_id) if sec_group is None: - LOG.error(_("Attempting to delete Group Rule that does not " - "exist or does not belong to tenant %s"), tenant_id) + LOG.error("Attempting to delete Group Rule that does not " + "exist or does not belong to tenant %s", tenant_id) raise exception.Forbidden("Unauthorized") sec_group_rule.delete(context, CONF.os_region_name) @@ -130,8 +129,8 @@ class SecurityGroupRuleController(wsgi.Controller): body['security_group_rule']['group_id'] body['security_group_rule']['cidr'] except KeyError as e: - LOG.error(_("Create Security Group Rules Required field(s) " - "- %s"), e) + LOG.error("Create Security Group Rules Required field(s) " + "- %s", e) raise exception.SecurityGroupRuleCreationError( "Required element/key - %s was not specified" % e) |