Merge "Remove gen_uuid()"

This commit is contained in:
Jenkins 2012-11-15 18:03:18 +00:00 committed by Gerrit Code Review
commit 402a169635
11 changed files with 29 additions and 32 deletions

View File

@ -58,6 +58,7 @@ import gettext
import optparse
import os
import sys
import uuid
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import sessionmaker
@ -502,7 +503,7 @@ class StorageManagerCommands(object):
# TODO(renukaapte) Add backend_introduce.
ctxt = context.get_admin_context()
params = dict(map(self._splitfun, args))
sr_uuid = utils.gen_uuid()
sr_uuid = uuid.uuid4()
if flavor_label is None:
print "error: backend needs to be associated with flavor"

View File

@ -20,19 +20,19 @@
"""RequestContext: context for requests that persist through all of cinder."""
import copy
import uuid
from cinder.openstack.common import local
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder import policy
from cinder import utils
LOG = logging.getLogger(__name__)
def generate_request_id():
return 'req-' + str(utils.gen_uuid())
return 'req-' + str(uuid.uuid4())
class RequestContext(object):

View File

@ -21,6 +21,7 @@
import datetime
import functools
import uuid
import warnings
from sqlalchemy.exc import IntegrityError
@ -41,7 +42,6 @@ from cinder import flags
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
from cinder.openstack.common import uuidutils
from cinder import utils
FLAGS = flags.FLAGS
@ -736,7 +736,7 @@ def quota_reserve(context, resources, quotas, deltas, expire,
reservations = []
for resource, delta in deltas.items():
reservation = reservation_create(elevated,
str(utils.gen_uuid()),
str(uuid.uuid4()),
usages[resource],
context.project_id,
resource, delta, expire,
@ -915,7 +915,7 @@ def volume_create(context, values):
models.VolumeMetadata)
volume_ref = models.Volume()
if not values.get('id'):
values['id'] = str(utils.gen_uuid())
values['id'] = str(uuid.uuid4())
volume_ref.update(values)
session = get_session()
@ -1133,7 +1133,7 @@ def volume_metadata_update(context, volume_id, metadata, delete):
def snapshot_create(context, values):
snapshot_ref = models.Snapshot()
if not values.get('id'):
values['id'] = str(utils.gen_uuid())
values['id'] = str(uuid.uuid4())
snapshot_ref.update(values)
session = get_session()

View File

@ -16,6 +16,7 @@
# under the License.
import datetime
import uuid
import routes
import webob
@ -33,7 +34,6 @@ from cinder.api.openstack import wsgi as os_wsgi
from cinder import context
from cinder import exception as exc
from cinder.openstack.common import timeutils
from cinder import utils
from cinder import wsgi
@ -172,7 +172,7 @@ class FakeRateLimiter(object):
def get_fake_uuid(token=0):
if not token in FAKE_UUIDS:
FAKE_UUIDS[token] = str(utils.gen_uuid())
FAKE_UUIDS[token] = str(uuid.uuid4())
return FAKE_UUIDS[token]

View File

@ -1,3 +1,5 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -13,6 +15,7 @@
# under the License.
import datetime
import uuid
import webob
from cinder.api.openstack.volume.contrib import volume_actions
@ -22,7 +25,6 @@ from cinder.openstack.common import jsonutils
from cinder.openstack.common.rpc import common as rpc_common
from cinder import test
from cinder.tests.api.openstack import fakes
from cinder import utils
from cinder import volume
from cinder.volume import api as volume_api
@ -47,7 +49,7 @@ class VolumeActionsTest(test.TestCase):
def setUp(self):
super(VolumeActionsTest, self).setUp()
self.stubs.Set(volume.API, 'get', fake_volume_api)
self.UUID = utils.gen_uuid()
self.UUID = uuid.uuid4()
for _method in self._methods:
self.stubs.Set(volume.API, _method, fake_volume_api)

View File

@ -1,3 +1,5 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,6 +16,7 @@
import datetime
import json
import uuid
from lxml import etree
import webob
@ -21,7 +24,6 @@ import webob
from cinder import context
from cinder import test
from cinder.tests.api.openstack import fakes
from cinder import utils
from cinder import volume
@ -60,7 +62,7 @@ class VolumeHostAttributeTest(test.TestCase):
super(VolumeHostAttributeTest, self).setUp()
self.stubs.Set(volume.API, 'get', fake_volume_get)
self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
self.UUID = utils.gen_uuid()
self.UUID = uuid.uuid4()
def test_get_volume_allowed(self):
ctx = context.RequestContext('admin', 'fake', True)

View File

@ -1,3 +1,5 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,6 +16,7 @@
import datetime
import json
import uuid
from lxml import etree
import webob
@ -21,9 +24,9 @@ import webob
from cinder import context
from cinder import test
from cinder.tests.api.openstack import fakes
from cinder import utils
from cinder import volume
PROJECT_ID = '88fd1da4-f464-4a87-9ce5-26f2f40743b9'
@ -62,7 +65,7 @@ class VolumeTenantAttributeTest(test.TestCase):
super(VolumeTenantAttributeTest, self).setUp()
self.stubs.Set(volume.API, 'get', fake_volume_get)
self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
self.UUID = utils.gen_uuid()
self.UUID = uuid.uuid4()
def test_get_volume_allowed(self):
ctx = context.RequestContext('admin', 'fake', True)

View File

@ -20,12 +20,12 @@
import copy
import datetime
import uuid
from cinder import exception
from cinder import flags
import cinder.image.glance
from cinder.openstack.common import log as logging
from cinder import utils
LOG = logging.getLogger(__name__)
@ -178,7 +178,7 @@ class _FakeImageService(object):
:raises: Duplicate if the image already exist.
"""
image_id = str(metadata.get('id', utils.gen_uuid()))
image_id = str(metadata.get('id', uuid.uuid4()))
metadata['id'] = image_id
if image_id in self.images:
raise exception.Duplicate()

View File

@ -21,12 +21,12 @@ Provides common functionality for integrated unit tests
import random
import string
import uuid
from cinder.openstack.common import log as logging
from cinder import service
from cinder import test # For the flags
from cinder.tests.integrated.api import client
from cinder import utils
LOG = logging.getLogger(__name__)
@ -102,7 +102,7 @@ class _IntegratedTestBase(test.TestCase):
return generate_new_element(server_names, 'server')
def get_invalid_image(self):
return str(utils.gen_uuid())
return str(uuid.uuid4())
def _build_minimal_create_server_request(self):
server = {}

View File

@ -22,6 +22,7 @@ import os.path
import paramiko
import StringIO
import tempfile
import uuid
import mox
@ -29,7 +30,6 @@ import cinder
from cinder import exception
from cinder import flags
from cinder.openstack.common import timeutils
from cinder.openstack.common import uuidutils
from cinder import test
from cinder import utils
@ -437,11 +437,6 @@ class GenericUtilsTestCase(test.TestCase):
self.assertEquals(h1, h2)
class GenUUIDTestCase(test.TestCase):
def test_gen_valid_uuid(self):
self.assertTrue(uuidutils.is_uuid_like(str(utils.gen_uuid())))
class MonkeyPatchTestCase(test.TestCase):
"""Unit test for utils.monkey_patch()."""
def setUp(self):
@ -654,7 +649,7 @@ class AuditPeriodTest(test.TestCase):
class FakeSSHClient(object):
def __init__(self):
self.id = utils.gen_uuid()
self.id = uuid.uuid4()
self.transport = FakeTransport()
def set_missing_host_key_policy(self, policy):

View File

@ -1,5 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
@ -41,7 +40,6 @@ import sys
import tempfile
import time
import types
import uuid
import warnings
from xml.sax import saxutils
@ -754,10 +752,6 @@ def check_isinstance(obj, cls):
return cls() # Ugly PyLint hack
def gen_uuid():
return uuid.uuid4()
def bool_from_str(val):
"""Convert a string representation of a bool into a bool value"""