summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongyue Luo <zhongyue.nah@intel.com>2013-11-13 13:35:30 +0800
committerZhongyue Luo <zhongyue.nah@intel.com>2013-11-13 13:35:30 +0800
commit97f9bd03701770111bd35ccedfe003c6ff7b90f2 (patch)
tree7a543b4a96126f4e4ac45af5d0279f16b925883d
parent47bf29e6eb31e0e7747f0f617cb0f6e901c7b260 (diff)
downloadoslo-middleware-97f9bd03701770111bd35ccedfe003c6ff7b90f2.tar.gz
Removes generate_uuid from uuidutils
As discussed at the summit, generating the UUID string seems trivial enough to not need a function. Each project should define its uuid generation helper function according to its required format. Change-Id: I2689a5d810e1b7663bc6b77385b2913844c70b9e
-rw-r--r--openstack/common/middleware/correlation_id.py5
-rw-r--r--tests/unit/middleware/test_correlation_id.py9
2 files changed, 8 insertions, 6 deletions
diff --git a/openstack/common/middleware/correlation_id.py b/openstack/common/middleware/correlation_id.py
index bffa0d7..d594c51 100644
--- a/openstack/common/middleware/correlation_id.py
+++ b/openstack/common/middleware/correlation_id.py
@@ -17,13 +17,14 @@
"""Middleware that attaches a correlation id to WSGI request"""
+import uuid
+
from openstack.common.middleware import base
-from openstack.common import uuidutils
class CorrelationIdMiddleware(base.Middleware):
def process_request(self, req):
correlation_id = (req.headers.get("X_CORRELATION_ID") or
- uuidutils.generate_uuid())
+ str(uuid.uuid4()))
req.headers['X_CORRELATION_ID'] = correlation_id
diff --git a/tests/unit/middleware/test_correlation_id.py b/tests/unit/middleware/test_correlation_id.py
index f330ada..9a0d128 100644
--- a/tests/unit/middleware/test_correlation_id.py
+++ b/tests/unit/middleware/test_correlation_id.py
@@ -15,12 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
import mock
from openstack.common.fixture import moxstubout
from openstack.common.middleware import correlation_id
from openstack.common import test
-from openstack.common import uuidutils
class CorrelationIdMiddlewareTest(test.BaseTestCase):
@@ -34,9 +35,9 @@ class CorrelationIdMiddlewareTest(test.BaseTestCase):
req = mock.Mock()
req.headers = {}
- mock_generate_uuid = mock.Mock()
- mock_generate_uuid.return_value = "fake_uuid"
- self.stubs.Set(uuidutils, 'generate_uuid', mock_generate_uuid)
+ mock_uuid4 = mock.Mock()
+ mock_uuid4.return_value = "fake_uuid"
+ self.stubs.Set(uuid, 'uuid4', mock_uuid4)
middleware = correlation_id.CorrelationIdMiddleware(app)
middleware(req)