Merge "Replace uuid4() with generate_uuid() from oslo_utils"

This commit is contained in:
Jenkins 2016-11-09 13:20:26 +00:00 committed by Gerrit Code Review
commit eb286afe1e
7 changed files with 20 additions and 25 deletions

View File

@ -15,7 +15,6 @@
import copy import copy
import datetime import datetime
import json import json
import uuid
import mock import mock
import six import six
@ -25,7 +24,7 @@ from mistral.db.v2 import api as db_api
from mistral.db.v2.sqlalchemy import models as db from mistral.db.v2.sqlalchemy import models as db
from mistral import exceptions as exc from mistral import exceptions as exc
from mistral.tests.unit.api import base from mistral.tests.unit.api import base
from oslo_utils import uuidutils
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f' DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f'
@ -62,7 +61,7 @@ ENVIRONMENT_FOR_UPDATE_NO_SCOPE = {
ENVIRONMENT = { ENVIRONMENT = {
'id': str(uuid.uuid4()), 'id': uuidutils.generate_uuid(),
'name': 'test', 'name': 'test',
'description': 'my test settings', 'description': 'my test settings',
'variables': VARIABLES, 'variables': VARIABLES,
@ -72,7 +71,7 @@ ENVIRONMENT = {
} }
ENVIRONMENT_WITH_ILLEGAL_FIELD = { ENVIRONMENT_WITH_ILLEGAL_FIELD = {
'id': str(uuid.uuid4()), 'id': uuidutils.generate_uuid(),
'name': 'test', 'name': 'test',
'description': 'my test settings', 'description': 'my test settings',
'extra_field': 'I can add whatever I want here', 'extra_field': 'I can add whatever I want here',

View File

@ -22,7 +22,6 @@ import json
import mock import mock
from oslo_config import cfg from oslo_config import cfg
import oslo_messaging import oslo_messaging
import uuid
from webtest import app as webtest_app from webtest import app as webtest_app
from mistral.api.controllers.v2 import execution from mistral.api.controllers.v2 import execution
@ -35,6 +34,7 @@ from mistral.tests.unit.api import base
from mistral import utils from mistral import utils
from mistral.utils import rest_utils from mistral.utils import rest_utils
from mistral.workflow import states from mistral.workflow import states
from oslo_utils import uuidutils
# This line is needed for correct initialization of messaging config. # This line is needed for correct initialization of messaging config.
oslo_messaging.get_transport(cfg.CONF) oslo_messaging.get_transport(cfg.CONF)
@ -69,7 +69,7 @@ WF_EX_JSON = {
} }
SUB_WF_EX = models.WorkflowExecution( SUB_WF_EX = models.WorkflowExecution(
id=str(uuid.uuid4()), id=uuidutils.generate_uuid(),
workflow_name='some', workflow_name='some',
workflow_id='123e4567-e89b-12d3-a456-426655441111', workflow_id='123e4567-e89b-12d3-a456-426655441111',
description='foobar', description='foobar',
@ -81,7 +81,7 @@ SUB_WF_EX = models.WorkflowExecution(
params={'env': {'k1': 'abc'}}, params={'env': {'k1': 'abc'}},
created_at=datetime.datetime(1970, 1, 1), created_at=datetime.datetime(1970, 1, 1),
updated_at=datetime.datetime(1970, 1, 1), updated_at=datetime.datetime(1970, 1, 1),
task_execution_id=str(uuid.uuid4()) task_execution_id=uuidutils.generate_uuid()
) )
SUB_WF_EX_JSON = { SUB_WF_EX_JSON = {

View File

@ -13,10 +13,10 @@
# under the License. # under the License.
import copy import copy
import uuid
import mock import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import uuidutils
from mistral.db.v2 import api as db_api from mistral.db.v2 import api as db_api
from mistral.services import security from mistral.services import security
@ -85,7 +85,7 @@ class TestMembersController(base.APITest):
@mock.patch('mistral.context.AuthHook.before') @mock.patch('mistral.context.AuthHook.before')
def test_create_membership_nonexistent_wf(self, auth_mock): def test_create_membership_nonexistent_wf(self, auth_mock):
nonexistent_wf_id = str(uuid.uuid4()) nonexistent_wf_id = uuidutils.generate_uuid()
resp = self.app.post_json( resp = self.app.post_json(
'/v2/workflows/%s/members' % nonexistent_wf_id, '/v2/workflows/%s/members' % nonexistent_wf_id,
@ -165,7 +165,7 @@ class TestMembersController(base.APITest):
@mock.patch('mistral.context.AuthHook.before') @mock.patch('mistral.context.AuthHook.before')
def test_get_memberships_nonexistent_wf(self, auth_mock): def test_get_memberships_nonexistent_wf(self, auth_mock):
nonexistent_wf_id = str(uuid.uuid4()) nonexistent_wf_id = uuidutils.generate_uuid()
resp = self.app.get( resp = self.app.get(
'/v2/workflows/%s/members' % nonexistent_wf_id, '/v2/workflows/%s/members' % nonexistent_wf_id,

View File

@ -14,11 +14,11 @@
# limitations under the License. # limitations under the License.
import datetime import datetime
import uuid
import mock import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_messaging.rpc import client as rpc_client from oslo_messaging.rpc import client as rpc_client
from oslo_utils import uuidutils
from mistral.db.v2 import api as db_api from mistral.db.v2 import api as db_api
from mistral.db.v2.sqlalchemy import models from mistral.db.v2.sqlalchemy import models
@ -64,7 +64,7 @@ workflows:
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f' DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S.%f'
ENVIRONMENT = { ENVIRONMENT = {
'id': str(uuid.uuid4()), 'id': uuidutils.generate_uuid(),
'name': 'test', 'name': 'test',
'description': 'my test settings', 'description': 'my test settings',
'variables': { 'variables': {

View File

@ -13,9 +13,9 @@
# limitations under the License. # limitations under the License.
import mock import mock
import uuid
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import uuidutils
import osprofiler import osprofiler
from mistral import context from mistral import context
@ -59,8 +59,8 @@ class EngineProfilerTest(base.EngineTestCase):
ctx = { ctx = {
'trace_info': { 'trace_info': {
'hmac_key': cfg.CONF.profiler.hmac_keys, 'hmac_key': cfg.CONF.profiler.hmac_keys,
'base_id': str(uuid.uuid4()), 'base_id': uuidutils.generate_uuid(),
'parent_id': str(uuid.uuid4()) 'parent_id': uuidutils.generate_uuid()
} }
} }

View File

@ -27,11 +27,11 @@ import socket
import sys import sys
import tempfile import tempfile
import threading import threading
import uuid
import eventlet import eventlet
from eventlet import corolocal from eventlet import corolocal
from oslo_concurrency import processutils from oslo_concurrency import processutils
from oslo_utils import uuidutils
import pkg_resources as pkg import pkg_resources as pkg
import random import random
@ -44,16 +44,11 @@ _th_loc_storage = threading.local()
def generate_unicode_uuid(): def generate_unicode_uuid():
return six.text_type(str(uuid.uuid4())) return uuidutils.generate_uuid()
def is_valid_uuid(uuid_string): def is_valid_uuid(uuid_string):
try: return uuidutils.is_uuid_like(uuid_string)
val = uuid.UUID(uuid_string, version=4)
except ValueError:
return False
return val.hex == uuid_string.replace('-', '')
def _get_greenlet_local_storage(): def _get_greenlet_local_storage():

View File

@ -13,9 +13,9 @@
# limitations under the License. # limitations under the License.
import base64 import base64
from urlparse import urlparse from urlparse import urlparse
import uuid
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from tempest import test from tempest import test
from mistral_tempest_tests.tests import base from mistral_tempest_tests.tests import base
@ -106,7 +106,8 @@ def _execute_action(client, request, extra_headers={}):
def _get_create_stack_request(): def _get_create_stack_request():
stack_name = 'multi_vim_test_stack_{}'.format(str(uuid.uuid4())[:8]) stack_name = 'multi_vim_test_stack_{}'.format(
uuidutils.generate_uuid()[:8])
return { return {
'name': 'heat.stacks_create', 'name': 'heat.stacks_create',