From: Jay S. Bryant Date: Fri, 19 Dec 2014 23:24:58 +0000 (-0600) Subject: Sync request_utils module from oslo-incubator X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=cc04c2483922fbb3d3f8b0c8daa5d5ae95b67686;p=openstack-build%2Fcinder-build.git Sync request_utils module from oslo-incubator The request_utils module hasn't had a sync done since shortly after the module was added. This patch brings us up to date with the latest oslo-incubator code. This sync is needed to enable removal of the old gettextutils and i18n code. Current HEAD in OSLO: --------------------- commit 36b0e8570b449129d6d474c03b02ceb62edb78df Date: Thu Dec 11 11:27:08 2014 +0100 We shouldn't replace `oslo-incubator` in comments Changes being merged with this patch: --------------------- 5d40e143 - Remove code that moved to oslo.i18n 39625e18 - Set pbr 'warnerrors' option for doc build Change-Id: Ib5b75d6ff38ff6f9571a0fdc30e854e046e66dd7 --- diff --git a/cinder/openstack/common/request_utils.py b/cinder/openstack/common/request_utils.py index 1ba9f8402..3bd3b454a 100644 --- a/cinder/openstack/common/request_utils.py +++ b/cinder/openstack/common/request_utils.py @@ -19,32 +19,32 @@ Utilities for linking request ID's across service calls. import logging -from openstack.common.gettextutils import _ # noqa -from cinder.i18n import _LI +from cinder.openstack.common._i18n import _, _LI + LOG = logging.getLogger(__name__) def link_request_ids(context, source_id, target_id=None, stage=None, target_name=None, notifier=None): - """Links the Request ID from the Source service to - the Request ID returned from the Target service. + """Links the Request ID from the Source service to the Request ID returned + from the Target service. + + Linkages are logged and emitted as INFO notifications. - Linkages are logged and emitted as INFO notifications. + :params context: context object + :params source_id: the Request ID of the source + :params target_id: the Request ID of the target + :params stage: optional event name extension to indicate which part of the + linkage this is. + :params target_name: human readable name of the target system you are + talking to. + :params notifier: notifier object - :params context: context object - :params source_id: the Request ID of the source - :params target_id: the Request ID of the target - :params stage: optional event name extension to - indicate which part of the linkage - this is. - :params target_name: human readable name of the - target system you are talking to. - :params notifier: notifier object + A typical use case is: System A asking System B to perform some action. The + linkages might look like this: - A typical use case is: System A asking System B - to perform some action. The linkages might look - like this: + .. code-block:: python link_request_ids(sys_A.request_ID, stage="start") # send request to System B and get request ID @@ -53,7 +53,10 @@ def link_request_ids(context, source_id, target_id=None, stage=None, link_request_ids(sys_A.request_ID, target_id=sys_B.request.ID, stage="end") - But, it could be as simple as: + But, it could be as simple as: + + .. code-block:: python + link_request_ids(sys_A.request_ID, target_id=sys_B.request.ID) """ @@ -73,12 +76,14 @@ def link_request_ids(context, source_id, target_id=None, stage=None, if target_name or target_id: arrow = " -> " - LOG.info(_LI("Request ID Link: %(event_name)s '%(source_id)s'%(arrow)s" - "%(target_name)s%(target_id)s") % {"event_name": event_name, - "source_id": source_id, - "target_name": rtarget_name, - "arrow": arrow, - "target_id": rtarget_id}) + LOG.info(_LI("Request ID Link: %(event_name)s " + "'%(source_id)s'%(arrow)s" + "%(target_name)s%(target_id)s") % { + "event_name": event_name, + "source_id": source_id, + "target_name": rtarget_name, + "arrow": arrow, + "target_id": rtarget_id}) if notifier: payload = {"source_request_id": source_id,