Log translation hint for Heat.api
Currently, Log translation is motivated by oslo's move to prioritized translation of strings, as documented at https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation - add log translation hints for warning, error and info levels - move from LOG.warning to LOG.warn - remove use of % as a string formatter, use the log functionality instead Partial implements blueprint log-translation-hints Change-Id: Ie17871f42f75085c2ac6a14fb1526df7bc3a9603
This commit is contained in:
parent
35d7465c11
commit
71c635122a
@ -20,6 +20,8 @@ import webob
|
|||||||
from heat.api.aws import exception
|
from heat.api.aws import exception
|
||||||
from heat.api.aws.exception import HeatAPIException
|
from heat.api.aws.exception import HeatAPIException
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
from heat.common.i18n import _LE
|
||||||
|
from heat.common.i18n import _LI
|
||||||
from heat.common import wsgi
|
from heat.common import wsgi
|
||||||
from heat.openstack.common import importutils
|
from heat.openstack.common import importutils
|
||||||
from heat.openstack.common import jsonutils as json
|
from heat.openstack.common import jsonutils as json
|
||||||
@ -136,14 +138,14 @@ class EC2Token(wsgi.Middleware):
|
|||||||
# here so that we can use both authentication methods.
|
# here so that we can use both authentication methods.
|
||||||
# Returning here just means the user didn't supply AWS
|
# Returning here just means the user didn't supply AWS
|
||||||
# authentication and we'll let the app try native keystone next.
|
# authentication and we'll let the app try native keystone next.
|
||||||
LOG.info(_("Checking AWS credentials.."))
|
LOG.info(_LI("Checking AWS credentials.."))
|
||||||
|
|
||||||
signature = self._get_signature(req)
|
signature = self._get_signature(req)
|
||||||
if not signature:
|
if not signature:
|
||||||
if 'X-Auth-User' in req.headers:
|
if 'X-Auth-User' in req.headers:
|
||||||
return self.application
|
return self.application
|
||||||
else:
|
else:
|
||||||
LOG.info(_("No AWS Signature found."))
|
LOG.info(_LI("No AWS Signature found."))
|
||||||
raise exception.HeatIncompleteSignatureError()
|
raise exception.HeatIncompleteSignatureError()
|
||||||
|
|
||||||
access = self._get_access(req)
|
access = self._get_access(req)
|
||||||
@ -151,14 +153,14 @@ class EC2Token(wsgi.Middleware):
|
|||||||
if 'X-Auth-User' in req.headers:
|
if 'X-Auth-User' in req.headers:
|
||||||
return self.application
|
return self.application
|
||||||
else:
|
else:
|
||||||
LOG.info(_("No AWSAccessKeyId/Authorization Credential"))
|
LOG.info(_LI("No AWSAccessKeyId/Authorization Credential"))
|
||||||
raise exception.HeatMissingAuthenticationTokenError()
|
raise exception.HeatMissingAuthenticationTokenError()
|
||||||
|
|
||||||
LOG.info(_("AWS credentials found, checking against keystone."))
|
LOG.info(_LI("AWS credentials found, checking against keystone."))
|
||||||
|
|
||||||
if not auth_uri:
|
if not auth_uri:
|
||||||
LOG.error(_("Ec2Token authorization failed, no auth_uri "
|
LOG.error(_LE("Ec2Token authorization failed, no auth_uri "
|
||||||
"specified in config file"))
|
"specified in config file"))
|
||||||
raise exception.HeatInternalFailureError(_('Service '
|
raise exception.HeatInternalFailureError(_('Service '
|
||||||
'misconfigured'))
|
'misconfigured'))
|
||||||
# Make a copy of args for authentication and signature verification.
|
# Make a copy of args for authentication and signature verification.
|
||||||
@ -182,7 +184,7 @@ class EC2Token(wsgi.Middleware):
|
|||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
keystone_ec2_uri = self._conf_get_keystone_ec2_uri(auth_uri)
|
keystone_ec2_uri = self._conf_get_keystone_ec2_uri(auth_uri)
|
||||||
LOG.info(_('Authenticating with %s') % keystone_ec2_uri)
|
LOG.info(_LI('Authenticating with %s'), keystone_ec2_uri)
|
||||||
response = requests.post(keystone_ec2_uri, data=creds_json,
|
response = requests.post(keystone_ec2_uri, data=creds_json,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
@ -190,9 +192,9 @@ class EC2Token(wsgi.Middleware):
|
|||||||
token_id = result['access']['token']['id']
|
token_id = result['access']['token']['id']
|
||||||
tenant = result['access']['token']['tenant']['name']
|
tenant = result['access']['token']['tenant']['name']
|
||||||
tenant_id = result['access']['token']['tenant']['id']
|
tenant_id = result['access']['token']['tenant']['id']
|
||||||
LOG.info(_("AWS authentication successful."))
|
LOG.info(_LI("AWS authentication successful."))
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
LOG.info(_("AWS authentication failure."))
|
LOG.info(_LI("AWS authentication failure."))
|
||||||
# Try to extract the reason for failure so we can return the
|
# Try to extract the reason for failure so we can return the
|
||||||
# appropriate AWS error via raising an exception
|
# appropriate AWS error via raising an exception
|
||||||
try:
|
try:
|
||||||
|
@ -19,7 +19,7 @@ import itertools
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from heat.api.aws import exception
|
from heat.api.aws import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _LE
|
||||||
from heat.openstack.common import log as logging
|
from heat.openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -102,7 +102,7 @@ def get_param_value(params, key):
|
|||||||
try:
|
try:
|
||||||
return params[key]
|
return params[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.error(_("Request does not contain %s parameter!") % key)
|
LOG.error(_LE("Request does not contain %s parameter!"), key)
|
||||||
raise exception.HeatMissingParameterError(key)
|
raise exception.HeatMissingParameterError(key)
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ from heat.api.aws import exception
|
|||||||
from heat.api.aws import utils as api_utils
|
from heat.api.aws import utils as api_utils
|
||||||
from heat.common import exception as heat_exception
|
from heat.common import exception as heat_exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
from heat.common.i18n import _LI
|
||||||
from heat.common import identifier
|
from heat.common import identifier
|
||||||
from heat.common import policy
|
from heat.common import policy
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
@ -421,7 +422,7 @@ class StackController(object):
|
|||||||
msg = _("The Template must be a JSON or YAML document.")
|
msg = _("The Template must be a JSON or YAML document.")
|
||||||
return exception.HeatInvalidParameterValueError(detail=msg)
|
return exception.HeatInvalidParameterValueError(detail=msg)
|
||||||
|
|
||||||
LOG.info(_('validate_template'))
|
LOG.info(_LI('validate_template'))
|
||||||
|
|
||||||
def format_validate_parameter(key, value):
|
def format_validate_parameter(key, value):
|
||||||
"""
|
"""
|
||||||
|
@ -21,6 +21,8 @@ from heat.api.aws import exception
|
|||||||
from heat.api.aws import utils as api_utils
|
from heat.api.aws import utils as api_utils
|
||||||
from heat.common import exception as heat_exception
|
from heat.common import exception as heat_exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
from heat.common.i18n import _LE
|
||||||
|
from heat.common.i18n import _LW
|
||||||
from heat.common import policy
|
from heat.common import policy
|
||||||
from heat.common import wsgi
|
from heat.common import wsgi
|
||||||
from heat.openstack.common import log as logging
|
from heat.openstack.common import log as logging
|
||||||
@ -214,7 +216,7 @@ class WatchController(object):
|
|||||||
# Filter criteria not met, return None
|
# Filter criteria not met, return None
|
||||||
return
|
return
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.warning(_("Invalid filter key %s, ignoring") % f)
|
LOG.warn(_LW("Invalid filter key %s, ignoring"), f)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@ -269,7 +271,7 @@ class WatchController(object):
|
|||||||
# need to process (each dict) for dimensions
|
# need to process (each dict) for dimensions
|
||||||
metric_data = api_utils.extract_param_list(parms, prefix='MetricData')
|
metric_data = api_utils.extract_param_list(parms, prefix='MetricData')
|
||||||
if not len(metric_data):
|
if not len(metric_data):
|
||||||
LOG.error(_("Request does not contain required MetricData"))
|
LOG.error(_LE("Request does not contain required MetricData"))
|
||||||
return exception.HeatMissingParameterError("MetricData list")
|
return exception.HeatMissingParameterError("MetricData list")
|
||||||
|
|
||||||
watch_name = None
|
watch_name = None
|
||||||
|
@ -21,6 +21,7 @@ from webob import exc
|
|||||||
from heat.api.openstack.v1 import util
|
from heat.api.openstack.v1 import util
|
||||||
from heat.api.openstack.v1.views import stacks_view
|
from heat.api.openstack.v1.views import stacks_view
|
||||||
from heat.common import environment_format
|
from heat.common import environment_format
|
||||||
|
from heat.common.i18n import _LW
|
||||||
from heat.common import identifier
|
from heat.common import identifier
|
||||||
from heat.common import param_utils
|
from heat.common import param_utils
|
||||||
from heat.common import serializers
|
from heat.common import serializers
|
||||||
@ -204,7 +205,7 @@ class StackController(object):
|
|||||||
show_deleted=show_deleted,
|
show_deleted=show_deleted,
|
||||||
show_nested=show_nested)
|
show_nested=show_nested)
|
||||||
except AttributeError as exc:
|
except AttributeError as exc:
|
||||||
LOG.warning(_("Old Engine Version: %s") % exc)
|
LOG.warn(_LW("Old Engine Version: %s") % exc)
|
||||||
|
|
||||||
return stacks_view.collection(req, stacks=stacks, count=count,
|
return stacks_view.collection(req, stacks=stacks, count=count,
|
||||||
tenant_safe=tenant_safe)
|
tenant_safe=tenant_safe)
|
||||||
|
Loading…
Reference in New Issue
Block a user