diff --git a/manila/api/auth.py b/manila/api/auth.py index cdde03aadc..2e3f1c2766 100644 --- a/manila/api/auth.py +++ b/manila/api/auth.py @@ -17,22 +17,21 @@ from oslo_log import log from manila.api.middleware import auth -from manila.i18n import _LW LOG = log.getLogger(__name__) class ManilaKeystoneContext(auth.ManilaKeystoneContext): def __init__(self, application): - LOG.warning(_LW('manila.api.auth:ManilaKeystoneContext is deprecated. ' - 'Please use ' - 'manila.api.middleware.auth:ManilaKeystoneContext ' - 'instead.')) + LOG.warning('manila.api.auth:ManilaKeystoneContext is deprecated. ' + 'Please use ' + 'manila.api.middleware.auth:ManilaKeystoneContext ' + 'instead.') super(ManilaKeystoneContext, self).__init__(application) def pipeline_factory(loader, global_conf, **local_conf): - LOG.warning(_LW('manila.api.auth:pipeline_factory is deprecated. ' - 'Please use manila.api.middleware.auth:pipeline_factory ' - 'instead.')) + LOG.warning('manila.api.auth:pipeline_factory is deprecated. ' + 'Please use manila.api.middleware.auth:pipeline_factory ' + 'instead.') auth.pipeline_factory(loader, global_conf, **local_conf) diff --git a/manila/api/extensions.py b/manila/api/extensions.py index 6eabf090f2..3804b61852 100644 --- a/manila/api/extensions.py +++ b/manila/api/extensions.py @@ -25,7 +25,6 @@ import webob.exc import manila.api.openstack from manila.api.openstack import wsgi from manila import exception -from manila.i18n import _LE, _LI, _LW import manila.policy CONF = cfg.CONF @@ -122,7 +121,7 @@ class ExtensionManager(object): """ def __init__(self): - LOG.info(_LI('Initializing extension manager.')) + LOG.info('Initializing extension manager.') self.cls_list = CONF.osapi_share_extension @@ -138,7 +137,7 @@ class ExtensionManager(object): return alias = ext.alias - LOG.info(_LI('Loaded extension: %s'), alias) + LOG.info('Loaded extension: %s', alias) if alias in self.extensions: raise exception.Error("Found duplicate extension: %s" % alias) @@ -182,7 +181,7 @@ class ExtensionManager(object): ' '.join(extension.__doc__.strip().split())) LOG.debug('Ext updated: %s', extension.updated) except AttributeError: - LOG.exception(_LE("Exception loading extension.")) + LOG.exception("Exception loading extension.") return False return True @@ -216,11 +215,11 @@ class ExtensionManager(object): 'standard_extensions') new_contrib_path = 'manila.api.contrib.standard_extensions' if old_contrib_path in extensions: - LOG.warning(_LW('osapi_share_extension is set to deprecated path: ' - '%s.'), + LOG.warning('osapi_share_extension is set to deprecated path: ' + '%s.', old_contrib_path) - LOG.warning(_LW('Please set your flag or manila.conf settings for ' - 'osapi_share_extension to: %s.'), new_contrib_path) + LOG.warning('Please set your flag or manila.conf settings for ' + 'osapi_share_extension to: %s.', new_contrib_path) extensions = [e.replace(old_contrib_path, new_contrib_path) for e in extensions] @@ -228,8 +227,8 @@ class ExtensionManager(object): try: self.load_extension(ext_factory) except Exception as exc: - LOG.warning(_LW('Failed to load extension %(ext_factory)s: ' - '%(exc)s.'), + LOG.warning('Failed to load extension %(ext_factory)s: ' + '%(exc)s.', {"ext_factory": ext_factory, "exc": exc}) @@ -297,8 +296,8 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None): try: ext_mgr.load_extension(classpath) except Exception as exc: - logger.warning(_LW('Failed to load extension %(classpath)s: ' - '%(exc)s.'), + logger.warning('Failed to load extension %(classpath)s: ' + '%(exc)s.', {"classpath": classpath, "exc": exc}) # Now, let's consider any subdirectories we may have... @@ -322,8 +321,8 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None): try: ext(ext_mgr) except Exception as exc: - logger.warning(_LW('Failed to load extension ' - '%(ext_name)s: %(exc)s.'), + logger.warning('Failed to load extension ' + '%(ext_name)s: %(exc)s.', {"ext_name": ext_name, "exc": exc}) # Update the list of directories we'll explore... diff --git a/manila/api/middleware/fault.py b/manila/api/middleware/fault.py index 32c5b95821..5c1434b64f 100644 --- a/manila/api/middleware/fault.py +++ b/manila/api/middleware/fault.py @@ -20,7 +20,6 @@ import webob.dec import webob.exc from manila.api.openstack import wsgi -from manila.i18n import _LE, _LI from manila import utils from manila import wsgi as base_wsgi @@ -41,7 +40,7 @@ class FaultWrapper(base_wsgi.Middleware): status, webob.exc.HTTPInternalServerError)() def _error(self, inner, req): - LOG.exception(_LE("Caught error: %s"), inner) + LOG.exception("Caught error: %s", inner) safe = getattr(inner, 'safe', False) headers = getattr(inner, 'headers', None) @@ -50,7 +49,7 @@ class FaultWrapper(base_wsgi.Middleware): status = 500 msg_dict = dict(url=req.url, status=status) - LOG.info(_LI("%(url)s returned with HTTP %(status)d"), msg_dict) + LOG.info("%(url)s returned with HTTP %(status)d", msg_dict) outer = self.status_to_type(status) if headers: outer.headers = headers diff --git a/manila/api/openstack/__init__.py b/manila/api/openstack/__init__.py index 39ccc7091c..3897d4c5c2 100644 --- a/manila/api/openstack/__init__.py +++ b/manila/api/openstack/__init__.py @@ -22,7 +22,7 @@ from oslo_log import log import routes from manila.api.openstack import wsgi -from manila.i18n import _, _LW +from manila.i18n import _ from manila import wsgi as base_wsgi LOG = log.getLogger(__name__) @@ -102,8 +102,8 @@ class APIRouter(base_wsgi.Router): controller = extension.controller if collection not in self.resources: - LOG.warning(_LW('Extension %(ext_name)s: Cannot extend ' - 'resource %(collection)s: No such resource'), + LOG.warning('Extension %(ext_name)s: Cannot extend ' + 'resource %(collection)s: No such resource', {'ext_name': ext_name, 'collection': collection}) continue @@ -121,9 +121,9 @@ class APIRouter(base_wsgi.Router): class FaultWrapper(base_wsgi.Middleware): def __init__(self, application): - LOG.warning(_LW('manila.api.openstack:FaultWrapper is deprecated. ' - 'Please use ' - 'manila.api.middleware.fault:FaultWrapper instead.')) + LOG.warning('manila.api.openstack:FaultWrapper is deprecated. ' + 'Please use ' + 'manila.api.middleware.fault:FaultWrapper instead.') # Avoid circular imports from here. from manila.api.middleware import fault super(FaultWrapper, self).__init__(fault.FaultWrapper(application)) diff --git a/manila/api/openstack/urlmap.py b/manila/api/openstack/urlmap.py index 426fc662ef..8c29b1dc69 100644 --- a/manila/api/openstack/urlmap.py +++ b/manila/api/openstack/urlmap.py @@ -17,13 +17,12 @@ from oslo_log import log from manila.api import urlmap -from manila.i18n import _LW LOG = log.getLogger(__name__) def urlmap_factory(loader, global_conf, **local_conf): - LOG.warning(_LW('manila.api.openstack.urlmap:urlmap_factory ' - 'is deprecated. ' - 'Please use manila.api.urlmap:urlmap_factory instead.')) + LOG.warning('manila.api.openstack.urlmap:urlmap_factory ' + 'is deprecated. ' + 'Please use manila.api.urlmap:urlmap_factory instead.') urlmap.urlmap_factory(loader, global_conf, **local_conf) diff --git a/manila/api/openstack/wsgi.py b/manila/api/openstack/wsgi.py index 4a4ce005bc..e1b1bc32d7 100644 --- a/manila/api/openstack/wsgi.py +++ b/manila/api/openstack/wsgi.py @@ -29,7 +29,7 @@ from manila.api.openstack import api_version_request as api_version from manila.api.openstack import versioned_method from manila.common import constants from manila import exception -from manila.i18n import _, _LE, _LI +from manila.i18n import _ from manila import policy from manila import wsgi @@ -524,14 +524,14 @@ class ResourceExceptionHandler(object): code=ex_value.code, explanation=six.text_type(ex_value))) elif isinstance(ex_value, TypeError): exc_info = (ex_type, ex_value, ex_traceback) - LOG.error(_LE('Exception handling resource: %s'), + LOG.error('Exception handling resource: %s', ex_value, exc_info=exc_info) raise Fault(webob.exc.HTTPBadRequest()) elif isinstance(ex_value, Fault): - LOG.info(_LI("Fault thrown: %s"), ex_value) + LOG.info("Fault thrown: %s", ex_value) raise ex_value elif isinstance(ex_value, webob.exc.HTTPException): - LOG.info(_LI("HTTP exception thrown: %s"), ex_value) + LOG.info("HTTP exception thrown: %s", ex_value) raise Fault(ex_value) # We didn't handle the exception @@ -732,8 +732,8 @@ class Resource(wsgi.Application): def __call__(self, request): """WSGI method that controls (de)serialization and method dispatch.""" - LOG.info(_LI("%(method)s %(url)s") % {"method": request.method, - "url": request.url}) + LOG.info("%(method)s %(url)s" % {"method": request.method, + "url": request.url}) if self.support_api_request_version: # Set the version of the API requested based on the header try: diff --git a/manila/api/v1/security_service.py b/manila/api/v1/security_service.py index ea65ae6af0..3e41788fb9 100644 --- a/manila/api/v1/security_service.py +++ b/manila/api/v1/security_service.py @@ -25,7 +25,7 @@ from manila.api.views import security_service as security_service_views from manila.common import constants from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import policy @@ -54,7 +54,7 @@ class SecurityServiceController(wsgi.Controller): """Delete a security service.""" context = req.environ['manila.context'] - LOG.info(_LI("Delete security service with id: %s"), + LOG.info("Delete security service with id: %s", id, context=context) try: diff --git a/manila/api/v1/share_snapshots.py b/manila/api/v1/share_snapshots.py index abcda09889..35bb1982dd 100644 --- a/manila/api/v1/share_snapshots.py +++ b/manila/api/v1/share_snapshots.py @@ -24,7 +24,7 @@ from manila.api.openstack import wsgi from manila.api.views import share_snapshots as snapshot_views from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import share LOG = log.getLogger(__name__) @@ -61,7 +61,7 @@ class ShareSnapshotMixin(object): """Delete a snapshot.""" context = req.environ['manila.context'] - LOG.info(_LI("Delete snapshot with id: %s"), id, context=context) + LOG.info("Delete snapshot with id: %s", id, context=context) try: snapshot = self.share_api.get_snapshot(context, id) @@ -169,7 +169,7 @@ class ShareSnapshotMixin(object): LOG.error(msg) raise exc.HTTPUnprocessableEntity(explanation=msg) - LOG.info(_LI("Create snapshot from share %s"), + LOG.info("Create snapshot from share %s", share_id, context=context) # NOTE(rushiagr): v2 API allows name instead of display_name diff --git a/manila/api/v1/share_unmanage.py b/manila/api/v1/share_unmanage.py index d511deaff1..1b0622b3f3 100644 --- a/manila/api/v1/share_unmanage.py +++ b/manila/api/v1/share_unmanage.py @@ -20,7 +20,7 @@ from webob import exc from manila.api.openstack import wsgi from manila.common import constants from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import share LOG = log.getLogger(__name__) @@ -33,7 +33,7 @@ class ShareUnmanageMixin(object): """Unmanage a share.""" context = req.environ['manila.context'] - LOG.info(_LI("Unmanage share with id: %s"), id, context=context) + LOG.info("Unmanage share with id: %s", id, context=context) try: share = self.share_api.get(context, id) diff --git a/manila/api/v1/shares.py b/manila/api/v1/shares.py index cf4e7a3c7f..d9d4c39283 100644 --- a/manila/api/v1/shares.py +++ b/manila/api/v1/shares.py @@ -31,7 +31,7 @@ from manila.api.views import shares as share_views from manila.common import constants from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import share from manila.share import share_types @@ -68,7 +68,7 @@ class ShareMixin(object): """Delete a share.""" context = req.environ['manila.context'] - LOG.info(_LI("Delete share with id: %s"), id, context=context) + LOG.info("Delete share with id: %s", id, context=context) try: share = self.share_api.get(context, id) @@ -219,7 +219,7 @@ class ShareMixin(object): size = share['size'] share_proto = share['share_proto'].upper() - msg = (_LI("Create %(share_proto)s share of %(size)s GB") % + msg = ("Create %(share_proto)s share of %(size)s GB" % {'share_proto': share_proto, 'size': size}) LOG.info(msg, context=context) diff --git a/manila/api/v2/share_group_snapshots.py b/manila/api/v2/share_group_snapshots.py index 629c92bc7a..7eeb323322 100644 --- a/manila/api/v2/share_group_snapshots.py +++ b/manila/api/v2/share_group_snapshots.py @@ -24,7 +24,7 @@ from manila.api.openstack import wsgi import manila.api.views.share_group_snapshots as share_group_snapshots_views from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ import manila.share_group.api as share_group_api LOG = log.getLogger(__name__) @@ -62,7 +62,7 @@ class ShareGroupSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin): def delete(self, req, id): """Delete a share group snapshot.""" context = req.environ['manila.context'] - LOG.info(_LI("Delete share group snapshot with id: %s"), + LOG.info("Delete share group snapshot with id: %s", id, context=context) sg_snapshot = self._get_share_group_snapshot(context, id) try: diff --git a/manila/api/v2/share_groups.py b/manila/api/v2/share_groups.py index 3a926eff9b..ee80997116 100644 --- a/manila/api/v2/share_groups.py +++ b/manila/api/v2/share_groups.py @@ -24,7 +24,7 @@ from manila.api.openstack import wsgi from manila.api.views import share_groups as share_group_views from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila.share import share_types from manila.share_group import api as share_group_api from manila.share_group import share_group_types @@ -64,7 +64,7 @@ class ShareGroupController(wsgi.Controller, wsgi.AdminActionsMixin): """Delete a share group.""" context = req.environ['manila.context'] - LOG.info(_LI("Delete share group with id: %s"), id, context=context) + LOG.info("Delete share group with id: %s", id, context=context) share_group = self._get_share_group(context, id) try: self.share_group_api.delete(context, share_group) diff --git a/manila/api/v2/share_networks.py b/manila/api/v2/share_networks.py index 78a0e6ea96..b734bad3fe 100644 --- a/manila/api/v2/share_networks.py +++ b/manila/api/v2/share_networks.py @@ -27,7 +27,7 @@ from manila.api.openstack import wsgi from manila.api.views import share_networks as share_networks_views from manila.db import api as db_api from manila import exception -from manila.i18n import _, _LE, _LW +from manila.i18n import _ from manila import policy from manila import quota from manila.share import rpcapi as share_rpcapi @@ -97,8 +97,8 @@ class ShareNetworkController(wsgi.Controller): context, project_id=share_network['project_id'], share_networks=-1, user_id=share_network['user_id']) except Exception: - LOG.exception(_LE("Failed to update usages deleting " - "share-network.")) + LOG.exception("Failed to update usages deleting " + "share-network.") else: QUOTAS.commit(context, reservations, project_id=share_network['project_id'], @@ -250,13 +250,13 @@ class ShareNetworkController(wsgi.Controller): return (usages[name]['reserved'] + usages[name]['in_use']) if 'share_networks' in overs: - LOG.warning(_LW("Quota exceeded for %(s_pid)s, " - "tried to create " - "share-network (%(d_consumed)d of %(d_quota)d " - "already consumed)."), { - 's_pid': context.project_id, - 'd_consumed': _consumed('share_networks'), - 'd_quota': quotas['share_networks']}) + LOG.warning("Quota exceeded for %(s_pid)s, " + "tried to create " + "share-network (%(d_consumed)d of %(d_quota)d " + "already consumed).", { + 's_pid': context.project_id, + 'd_consumed': _consumed('share_networks'), + 'd_quota': quotas['share_networks']}) raise exception.ShareNetworksLimitExceeded( allowed=quotas['share_networks']) else: diff --git a/manila/api/v2/share_snapshots.py b/manila/api/v2/share_snapshots.py index 257469020c..c3474c8d43 100644 --- a/manila/api/v2/share_snapshots.py +++ b/manila/api/v2/share_snapshots.py @@ -27,7 +27,7 @@ from manila.api.v1 import share_snapshots from manila.api.views import share_snapshots as snapshot_views from manila.common import constants from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import share LOG = log.getLogger(__name__) @@ -49,7 +49,7 @@ class ShareSnapshotsController(share_snapshots.ShareSnapshotMixin, """Unmanage a share snapshot.""" context = req.environ['manila.context'] - LOG.info(_LI("Unmanage share snapshot with id: %s."), id) + LOG.info("Unmanage share snapshot with id: %s.", id) try: snapshot = self.share_api.get_snapshot(context, id) diff --git a/manila/api/v2/shares.py b/manila/api/v2/shares.py index d0ced5c5c1..aca1b46cb2 100644 --- a/manila/api/v2/shares.py +++ b/manila/api/v2/shares.py @@ -29,7 +29,7 @@ from manila.api.views import shares as share_views from manila.common import constants from manila import db from manila import exception -from manila.i18n import _, _LI +from manila.i18n import _ from manila import share from manila import utils @@ -144,7 +144,7 @@ class ShareController(shares.ShareMixin, raise exc.HTTPConflict(explanation=msg % msg_args) msg_args = {'share_id': share_id, 'snap_id': snapshot_id} - msg = _LI('Reverting share %(share_id)s to snapshot %(snap_id)s.') + msg = 'Reverting share %(share_id)s to snapshot %(snap_id)s.' LOG.info(msg, msg_args) self.share_api.revert_to_snapshot(context, share, snapshot)