summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongyue Luo <zhongyue.nah@intel.com>2013-11-22 08:37:21 +0800
committerZhongyue Luo <zhongyue.nah@intel.com>2013-11-22 08:37:21 +0800
commit83d5d2767410b60b21765215979ccdf471dc8bdc (patch)
tree7a543b4a96126f4e4ac45af5d0279f16b925883d
parent808c051095e72b8a04c22cfc60d24ea43bb0ff43 (diff)
downloadoslo-middleware-83d5d2767410b60b21765215979ccdf471dc8bdc.tar.gz
Remove uuidutils imports in oslo modules
The only use of uuidutils in oslo-incubator is generate_uuid which could be replaced with uuid.uuid4(). Droping the dependency would help deprecating/removing uuidutils in the future. Partial-bug: #1253497 Change-Id: Ie0bc94e0b4aea6563f138c0f09c54c323ba23279
-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)