Update logging according oslo.i18n recommendations
Removed unused logging import Replaced % on , Source: http://docs.openstack.org/developer/oslo.i18n/guidelines.html Change-Id: I10e8deb332c5228926a8f3193b2d23325b85af9b
This commit is contained in:
parent
fc529025e9
commit
8fb4050fef
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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])
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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})
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -111,7 +111,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
|
||||
@ -134,7 +134,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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user