Codebase list python-castellan / 04874c2
Remove log translations Log messages are no longer being translated. This removes all use of the _LE, _LI, and _LW translation markers to simplify logging and to avoid confusion with new contributions. See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html Change-Id: I410ac1eaa0a3c9bfa68ec1634e74aae369dde1cf bhavani.cr authored 6 years ago bhavani committed 6 years ago
3 changed file(s) with 22 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
2020 from castellan.common.credentials import password
2121 from castellan.common.credentials import token
2222 from castellan.common import exception
23 from castellan.i18n import _LE
2423
2524 from oslo_config import cfg
2625 from oslo_log import log as logging
163162 reauthenticate=conf.key_manager.reauthenticate)
164163
165164 else:
166 LOG.error(_LE("Invalid auth_type specified."))
165 LOG.error("Invalid auth_type specified.")
167166 raise exception.AuthTypeInvalidError(
168167 type=conf.key_manager.auth_type)
169168
2424
2525 # The primary translation function using the well-known name "_"
2626 _ = _translators.primary
27
28 # Translators for log levels.
29 #
30 # The abbreviated names are meant to reflect the usual use of a short
31 # name like '_'. The "L" is for "log" and the other letter comes from
32 # the level.
33 _LI = _translators.log_info
34 _LW = _translators.log_warning
35 _LE = _translators.log_error
36 _LC = _translators.log_critical
3636 from castellan.common.objects import public_key as pub_key
3737 from castellan.common.objects import symmetric_key as sym_key
3838 from castellan.common.objects import x_509
39 from castellan.i18n import _
3940 from castellan.key_manager import key_manager
40 from castellan.i18n import _, _LE, _LI
41
4142
4243 from barbicanclient import client as barbican_client
4344 from barbicanclient import exceptions as barbican_exceptions
103104
104105 # Confirm context is provided, if not raise forbidden
105106 if not context:
106 msg = _LE("User is not authorized to use key manager.")
107 msg = _("User is not authorized to use key manager.")
107108 LOG.error(msg)
108109 raise exception.Forbidden(msg)
109110
122123 self._current_context = context
123124
124125 except Exception as e:
125 LOG.error(_LE("Error creating Barbican client: %s"), e)
126 LOG.error("Error creating Barbican client: %s", e)
126127 raise exception.KeyManagerError(reason=e)
127128
128129 self._base_url = self._create_base_url(auth,
170171 token=context.auth_token,
171172 project_id=context.tenant)
172173 else:
173 msg = _LE("context must be of type KeystonePassword, "
174 "KeystoneToken, or RequestContext.")
174 msg = _("context must be of type KeystonePassword, "
175 "KeystoneToken, or RequestContext.")
175176 LOG.error(msg)
176177 raise exception.Forbidden(reason=msg)
177178
191192 discovery = auth.get_discovery(sess, url=endpoint)
192193 raw_data = discovery.raw_version_data()
193194 if len(raw_data) == 0:
194 msg = _LE(
195 msg = _(
195196 "Could not find discovery information for %s") % endpoint
196197 LOG.error(msg)
197198 raise exception.KeyManagerError(reason=msg)
229230 except (barbican_exceptions.HTTPAuthError,
230231 barbican_exceptions.HTTPClientError,
231232 barbican_exceptions.HTTPServerError) as e:
232 LOG.error(_LE("Error creating key: %s"), e)
233 LOG.error("Error creating key: %s", e)
233234 raise exception.KeyManagerError(reason=e)
234235
235236 def create_key_pair(self, context, algorithm, length,
267268 except (barbican_exceptions.HTTPAuthError,
268269 barbican_exceptions.HTTPClientError,
269270 barbican_exceptions.HTTPServerError) as e:
270 LOG.error(_LE("Error creating key pair: %s"), e)
271 LOG.error("Error creating key pair: %s", e)
271272 raise exception.KeyManagerError(reason=e)
272273
273274 def _get_barbican_object(self, barbican_client, managed_object):
346347 except (barbican_exceptions.HTTPAuthError,
347348 barbican_exceptions.HTTPClientError,
348349 barbican_exceptions.HTTPServerError) as e:
349 LOG.error(_LE("Error storing object: %s"), e)
350 LOG.error("Error storing object: %s", e)
350351 raise exception.KeyManagerError(reason=e)
351352
352353 def _create_secret_ref(self, object_id):
380381 kwargs = {"status": error_status,
381382 "code": order.error_status_code,
382383 "reason": order.error_reason}
383 msg = _LE("Order is in %(status)s status - status code: "
384 "%(code)s, status reason: %(reason)s") % kwargs
384 msg = _("Order is in %(status)s status - status code: "
385 "%(code)s, status reason: %(reason)s") % kwargs
385386 LOG.error(msg)
386387 raise exception.KeyManagerError(reason=msg)
387388 if order.status != active_status:
390391 'status': order.status,
391392 'active': active_status,
392393 'delay': retry_delay}
393 msg = _LI("Retry attempt #%(attempt)i out of %(total)i: "
394 "Order status is '%(status)s'. Waiting for "
395 "'%(active)s', will retry in %(delay)s "
396 "seconds")
394 msg = _("Retry attempt #%(attempt)i out of %(total)i: "
395 "Order status is '%(status)s'. Waiting for "
396 "'%(active)s', will retry in %(delay)s "
397 "seconds")
397398 LOG.info(msg, kwargs)
398399 time.sleep(retry_delay)
399400 order = barbican_client.orders.get(order_ref)
400401 else:
401402 return order
402 msg = _LE("Exceeded retries: Failed to find '%(active)s' status "
403 "within %(num_retries)i retries") % {
403 msg = _("Exceeded retries: Failed to find '%(active)s' status "
404 "within %(num_retries)i retries") % {
404405 'active': active_status,
405406 'num_retries': number_of_retries}
406407 LOG.error(msg)
514515 barbican_exceptions.HTTPClientError,
515516 barbican_exceptions.HTTPServerError) as e:
516517 with excutils.save_and_reraise_exception():
517 LOG.error(_LE("Error getting secret metadata: %s"), e)
518 LOG.error("Error getting secret metadata: %s", e)
518519
519520 def _is_secret_not_found_error(self, error):
520521 if (isinstance(error, barbican_exceptions.HTTPClientError) and
540541 except (barbican_exceptions.HTTPAuthError,
541542 barbican_exceptions.HTTPClientError,
542543 barbican_exceptions.HTTPServerError) as e:
543 LOG.error(_LE("Error retrieving object: %s"), e)
544 LOG.error("Error retrieving object: %s", e)
544545 if self._is_secret_not_found_error(e):
545546 raise exception.ManagedObjectNotFoundError(
546547 uuid=managed_object_id)
564565 except (barbican_exceptions.HTTPAuthError,
565566 barbican_exceptions.HTTPClientError,
566567 barbican_exceptions.HTTPServerError) as e:
567 LOG.error(_LE("Error deleting object: %s"), e)
568 LOG.error("Error deleting object: %s", e)
568569 if self._is_secret_not_found_error(e):
569570 raise exception.ManagedObjectNotFoundError(
570571 uuid=managed_object_id)