From 0d8c0c3f9c6a8e7877d2a796ed152626c9d2d036 Mon Sep 17 00:00:00 2001 From: rajat29 Date: Thu, 20 Jul 2017 15:05:38 +0530 Subject: [PATCH] Replace uuid.uuid4() with uuidutils.generate_uuid() Openstack common has a wrapper for generating uuids. We should use that function to generate uuids for consistency. Change-Id: I2c31de4566fd4ca1f4c9a0df4403538b00621859 --- zaqarclient/queues/v1/client.py | 5 ++--- zaqarclient/queues/v2/client.py | 5 ++--- zaqarclient/transport/ws.py | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/zaqarclient/queues/v1/client.py b/zaqarclient/queues/v1/client.py index b81925d3..22b33c21 100644 --- a/zaqarclient/queues/v1/client.py +++ b/zaqarclient/queues/v1/client.py @@ -13,8 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid - +from oslo_utils import uuidutils from zaqarclient.common import decorators from zaqarclient.queues.v1 import core from zaqarclient.queues.v1 import flavor @@ -53,7 +52,7 @@ class Client(object): self.api_version = version self.auth_opts = self.conf.get('auth_opts', {}) self.client_uuid = self.conf.get('client_uuid', - uuid.uuid4().hex) + uuidutils.generate_uuid(dashed=False)) self.session = session def _get_transport(self, request): diff --git a/zaqarclient/queues/v2/client.py b/zaqarclient/queues/v2/client.py index 2371c8e6..e158fc74 100644 --- a/zaqarclient/queues/v2/client.py +++ b/zaqarclient/queues/v2/client.py @@ -13,8 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import uuid - +from oslo_utils import uuidutils from zaqarclient.common import decorators from zaqarclient.queues.v1 import client from zaqarclient.queues.v1 import iterator @@ -48,7 +47,7 @@ class Client(client.Client): self.api_version = version self.auth_opts = self.conf.get('auth_opts', {}) self.client_uuid = self.conf.get('client_uuid', - uuid.uuid4().hex) + uuidutils.generate_uuid(dashed=False)) self.session = session def queue(self, ref, **kwargs): diff --git a/zaqarclient/transport/ws.py b/zaqarclient/transport/ws.py index 8af6e07b..0d85fdbe 100644 --- a/zaqarclient/transport/ws.py +++ b/zaqarclient/transport/ws.py @@ -13,10 +13,10 @@ # under the License. # import json -import uuid from oslo_log import log as logging from oslo_utils import importutils +from oslo_utils import uuidutils from zaqarclient.transport import base from zaqarclient.transport import request @@ -73,7 +73,7 @@ class WebsocketTransport(base.Transport): Required. :type endpoint: string """ - self._websocket_client_id = str(uuid.uuid4()) + self._websocket_client_id = uuidutils.generate_uuid() LOG.debug('Instantiating messaging websocket client: %s', endpoint) self._ws = self._create_connection(endpoint)