diff --git a/contrib/rackspace/rackspace/clients.py b/contrib/rackspace/rackspace/clients.py index c165daaa95..caa672dda5 100644 --- a/contrib/rackspace/rackspace/clients.py +++ b/contrib/rackspace/rackspace/clients.py @@ -57,7 +57,7 @@ class RackspaceClientPlugin(client_plugin.ClientPlugin): """Create an authenticated client context.""" self.pyrax = pyrax.create_context("rackspace") self.pyrax.auth_endpoint = self.context.auth_url - LOG.info(_LI("Authenticating username: %s") % + LOG.info(_LI("Authenticating username: %s"), self.context.username) tenant = self.context.tenant_id tenant_name = self.context.tenant diff --git a/contrib/rackspace/rackspace/resources/cloudnetworks.py b/contrib/rackspace/rackspace/resources/cloudnetworks.py index c78478181b..2598028aaa 100644 --- a/contrib/rackspace/rackspace/resources/cloudnetworks.py +++ b/contrib/rackspace/rackspace/resources/cloudnetworks.py @@ -141,7 +141,7 @@ class CloudNetwork(resource.Resource): try: network.delete() except NetworkInUse: - LOG.warn("Network '%s' still in use." % network.id) + LOG.warn(_LW("Network '%s' still in use."), network.id) else: network_info['delete_issued'] = True return False diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index 9cf5086e82..020ae70092 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -292,7 +292,7 @@ class StackController(object): not_tags=not_tags, not_tags_any=not_tags_any) except AttributeError as ex: - LOG.warn(_LW("Old Engine Version: %s") % ex) + LOG.warn(_LW("Old Engine Version: %s"), ex) return stacks_view.collection(req, stacks=stacks, count=count, tenant_safe=tenant_safe) diff --git a/heat/common/auth_password.py b/heat/common/auth_password.py index 334b60c884..480fa61c74 100644 --- a/heat/common/auth_password.py +++ b/heat/common/auth_password.py @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging - from keystoneclient import exceptions as keystone_exceptions from keystoneclient import session from oslo_config import cfg @@ -24,9 +22,6 @@ from webob import exc from heat.common import context -LOG = logging.getLogger(__name__) - - class KeystonePasswordAuthProtocol(object): """ Alternative authentication middleware that uses username and password diff --git a/heat/common/exception.py b/heat/common/exception.py index 41ce15aa0f..36402b5e0e 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -114,7 +114,8 @@ class HeatException(Exception): # log the issue and the kwargs LOG.exception(_LE('Exception in string format operation')) for name, value in six.iteritems(kwargs): - LOG.error("%s: %s" % (name, value)) # noqa + LOG.error(_LE("%(name)s: %(value)s"), + {'name': name, 'value': value}) # noqa if _FATAL_EXCEPTION_FORMAT_ERRORS: raise_(exc_info[0], exc_info[1], exc_info[2]) diff --git a/heat/common/heat_keystoneclient.py b/heat/common/heat_keystoneclient.py index 8683487904..8ff1c80e7d 100644 --- a/heat/common/heat_keystoneclient.py +++ b/heat/common/heat_keystoneclient.py @@ -442,7 +442,7 @@ class KeystoneClientV3(object): return except kc_exception.Forbidden: LOG.warning(_LW('Unable to get details for project %s, ' - 'not deleting') % project_id) + 'not deleting'), project_id) return if project.domain_id != self.stack_domain_id: diff --git a/heat/common/lifecycle_plugin_utils.py b/heat/common/lifecycle_plugin_utils.py index 86528d6639..960fa1a29f 100644 --- a/heat/common/lifecycle_plugin_utils.py +++ b/heat/common/lifecycle_plugin_utils.py @@ -109,12 +109,12 @@ def _do_ops(cinstances, opname, cnxt, stack, current_stack=None, action=None, success_count += 1 except Exception as ex: LOG.exception(_LE( - "%(opname) %(ci)s failed for %(a)s on %(sid)s") % + "%(opname)s %(ci)s failed for %(a)s on %(sid)s"), {'opname': opname, 'ci': type(ci), 'a': action, 'sid': stack.id}) failure = True failure_exception_message = ex.args[0] if ex.args else str(ex) break - LOG.info(_LI("done with class=%(c)s, stackid=%(sid)s, action=%(a)s") % + LOG.info(_LI("done with class=%(c)s, stackid=%(sid)s, action=%(a)s"), {'c': type(ci), 'sid': stack.id, 'a': action}) return (failure, failure_exception_message, success_count) diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 6c5ee1b05e..94691aa2d3 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -308,7 +308,7 @@ class Server(object): self.pool.spawn_n(self._single_run, application, self.sock) return - LOG.info(_LI("Starting %d workers") % conf.workers) + LOG.info(_LI("Starting %d workers"), conf.workers) signal.signal(signal.SIGTERM, kill_children) signal.signal(signal.SIGHUP, hup) while len(self.children) < conf.workers: @@ -319,7 +319,7 @@ class Server(object): try: pid, status = os.wait() if os.WIFEXITED(status) or os.WIFSIGNALED(status): - LOG.error(_LE('Removing dead child %s') % pid) + LOG.error(_LE('Removing dead child %s'), pid) self.children.remove(pid) self.run_child() except OSError as err: @@ -349,10 +349,10 @@ class Server(object): signal.signal(signal.SIGHUP, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) self.run_server() - LOG.info(_LI('Child %d exiting normally') % os.getpid()) + LOG.info(_LI('Child %d exiting normally'), os.getpid()) return else: - LOG.info(_LI('Started child %s') % pid) + LOG.info(_LI('Started child %s'), pid) self.children.append(pid) def run_server(self): @@ -680,7 +680,7 @@ class Resource(object): action_result = self.dispatch(self.controller, action, request, **action_args) except TypeError as err: - LOG.error(_LE('Exception handling resource: %s') % err) + LOG.error(_LE('Exception handling resource: %s'), err) msg = _('The server could not comply with the request since ' 'it is either malformed or otherwise incorrect.') err = webob.exc.HTTPBadRequest(msg) @@ -776,7 +776,7 @@ class Resource(object): def log_exception(err, exc_info): args = {'exc_info': exc_info} if cfg.CONF.verbose or cfg.CONF.debug else {} - LOG.error(_LE("Unexpected error occurred serving API: %s") % err, + LOG.error(_LE("Unexpected error occurred serving API: %s"), err, **args) diff --git a/heat/engine/attributes.py b/heat/engine/attributes.py index fa3b51c69e..41e2c5e872 100644 --- a/heat/engine/attributes.py +++ b/heat/engine/attributes.py @@ -16,6 +16,7 @@ import collections import six from heat.common.i18n import _ +from heat.common.i18n import _LW from heat.engine import constraints as constr from heat.engine import support @@ -171,23 +172,23 @@ class Attributes(collections.Mapping): def _validate_type(self, attrib, value): if attrib.schema.type == attrib.schema.STRING: if not isinstance(value, six.string_types): - LOG.warn(_("Attribute %(name)s is not of type %(att_type)s"), + LOG.warn(_LW("Attribute %(name)s is not of type %(att_type)s"), {'name': attrib.name, 'att_type': attrib.schema.STRING}) elif attrib.schema.type == attrib.schema.LIST: if (not isinstance(value, collections.Sequence) or isinstance(value, six.string_types)): - LOG.warn(_("Attribute %(name)s is not of type %(att_type)s"), + LOG.warn(_LW("Attribute %(name)s is not of type %(att_type)s"), {'name': attrib.name, 'att_type': attrib.schema.LIST}) elif attrib.schema.type == attrib.schema.MAP: if not isinstance(value, collections.Mapping): - LOG.warn(_("Attribute %(name)s is not of type %(att_type)s"), + LOG.warn(_LW("Attribute %(name)s is not of type %(att_type)s"), {'name': attrib.name, 'att_type': attrib.schema.MAP}) elif attrib.schema.type == attrib.schema.INTEGER: if not isinstance(value, int): - LOG.warn(_("Attribute %(name)s is not of type %(att_type)s"), + LOG.warn(_LW("Attribute %(name)s is not of type %(att_type)s"), {'name': attrib.name, 'att_type': attrib.schema.INTEGER}) diff --git a/heat/engine/clients/__init__.py b/heat/engine/clients/__init__.py index 66f4893d5c..9dc9c7b7da 100644 --- a/heat/engine/clients/__init__.py +++ b/heat/engine/clients/__init__.py @@ -18,7 +18,7 @@ import six from stevedore import enabled from heat.common import exception -from heat.common.i18n import _LE +from heat.common.i18n import _ from heat.common.i18n import _LW LOG = logging.getLogger(__name__) @@ -90,8 +90,8 @@ class ClientBackend(object): return importutils.import_object(cfg.CONF.cloud_backend, context) except (ImportError, RuntimeError) as err: - msg = _LE('Invalid cloud_backend setting in heat.conf ' - 'detected - %s') % six.text_type(err) + msg = _('Invalid cloud_backend setting in heat.conf ' + 'detected - %s'), six.text_type(err) LOG.error(msg) raise exception.Invalid(reason=msg) diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 1f41a29b5a..1a8abe59a6 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -554,8 +554,9 @@ class Resource(object): with excutils.save_and_reraise_exception(): LOG.debug('%s', six.text_type(ex)) except Exception as ex: - LOG.info('%(action)s: %(info)s', {"action": action, - "info": six.text_type(self)}, + LOG.info(_LI('%(action)s: %(info)s'), + {"action": action, + "info": six.text_type(self)}, exc_info=True) failure = exception.ResourceFailure(ex, self, action) self.state_set(action, self.FAILED, six.text_type(failure)) diff --git a/heat/engine/resources/stack_resource.py b/heat/engine/resources/stack_resource.py index 069dd397e9..92bf457112 100644 --- a/heat/engine/resources/stack_resource.py +++ b/heat/engine/resources/stack_resource.py @@ -23,6 +23,7 @@ import six from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LE from heat.common.i18n import _LW from heat.common import identifier from heat.common import template_format @@ -435,7 +436,7 @@ class StackResource(resource.Resource): parsed_template.files, args) except Exception as ex: - LOG.exception('update_stack') + LOG.exception(_LE('update_stack')) self.raise_local_exception(ex) return cookie diff --git a/heat/engine/service.py b/heat/engine/service.py index 3217d0dedf..2ba6557078 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -812,7 +812,7 @@ class EngineService(service.Service): msg = _("Cancelling update when stack is %s" ) % str(current_stack.state) raise exception.NotSupported(feature=msg) - LOG.info(_LI('Starting cancel of updating stack %s') % db_stack.name) + LOG.info(_LI('Starting cancel of updating stack %s'), db_stack.name) # stop the running update and take the lock # as we cancel only running update, the acquire_result is # always some engine_id, not None diff --git a/heat/engine/service_software_config.py b/heat/engine/service_software_config.py index 2d499f520e..c31a196ab2 100644 --- a/heat/engine/service_software_config.py +++ b/heat/engine/service_software_config.py @@ -120,7 +120,7 @@ class SoftwareConfigService(service.Service): except Exception as ex: # ignore not-found, in case swift is not consistent yet if swift_plugin.is_not_found(ex): - LOG.info(_LI('Signal object not found: %(c)s %(o)s') % { + LOG.info(_LI('Signal object not found: %(c)s %(o)s'), { 'c': container, 'o': object_name}) return sd raise ex @@ -143,7 +143,7 @@ class SoftwareConfigService(service.Service): # ignore not-found, in case swift is not consistent yet if swift_plugin.is_not_found(ex): LOG.info(_LI( - 'Signal object not found: %(c)s %(o)s') % { + 'Signal object not found: %(c)s %(o)s'), { 'c': container, 'o': object_name}) return sd raise ex diff --git a/heat/engine/stack.py b/heat/engine/stack.py index bcac31ac40..f43c775ee5 100755 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -1500,7 +1500,7 @@ class Stack(collections.Mapping): scheduler.TaskRunner(res.create)() except exception.ResourceFailure as ex: LOG.exception(_LE('Resource %(name)s create failed: ' - '%(ex)s') % {'name': res.name, 'ex': ex}) + '%(ex)s'), {'name': res.name, 'ex': ex}) failed = True else: res.state_set(res.CREATE, res.FAILED, @@ -1585,8 +1585,8 @@ class Stack(collections.Mapping): if traversal_id != self.current_traversal: return - LOG.info('[%s(%s)] update traversal %s complete', - self.name, self.id, traversal_id) + LOG.info(_LI('[%(name)s(%(id)s)] update traversal %(tid)s complete'), + {'name': self.name, 'id': self.id, 'tid': traversal_id}) reason = 'Stack %s completed successfully' % self.action self.state_set(self.action, self.COMPLETE, reason)