Use generate_uuid from openstack common.
Change-Id: Ie1b55df2301b5ca276571117386a0625e039adc2
This commit is contained in:
parent
4ce79abbe4
commit
a26f3613ba
|
@ -239,10 +239,6 @@ def bool_from_string(subject):
|
|||
return False
|
||||
|
||||
|
||||
def generate_uuid():
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
def safe_mkdirs(path):
|
||||
try:
|
||||
os.makedirs(path)
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import glance.common.utils
|
||||
from glance.openstack.common import local
|
||||
from glance.openstack.common import uuidutils
|
||||
|
||||
|
||||
class RequestContext(object):
|
||||
|
@ -36,7 +36,7 @@ class RequestContext(object):
|
|||
self.read_only = read_only
|
||||
self._show_deleted = show_deleted
|
||||
self.owner_is_tenant = owner_is_tenant
|
||||
self.request_id = glance.common.utils.generate_uuid()
|
||||
self.request_id = uuidutils.generate_uuid()
|
||||
self.service_catalog = service_catalog
|
||||
|
||||
if not hasattr(local.store, 'context'):
|
||||
|
|
|
@ -17,9 +17,9 @@ import copy
|
|||
import functools
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
import glance.openstack.common.log as logging
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -71,7 +71,7 @@ def _image_property_format(image_id, name, value):
|
|||
|
||||
def _image_member_format(image_id, tenant_id, can_share):
|
||||
return {
|
||||
'id': utils.generate_uuid(),
|
||||
'id': uuidutils.generate_uuid(),
|
||||
'image_id': image_id,
|
||||
'member': tenant_id,
|
||||
'can_share': can_share,
|
||||
|
@ -298,7 +298,7 @@ def image_member_delete(context, member_id):
|
|||
@log_call
|
||||
def image_create(context, image_values):
|
||||
global DATA
|
||||
image_id = image_values.get('id', utils.generate_uuid())
|
||||
image_id = image_values.get('id', uuidutils.generate_uuid())
|
||||
|
||||
if image_id in DATA['images']:
|
||||
raise exception.Duplicate()
|
||||
|
|
|
@ -27,9 +27,9 @@ from sqlalchemy import ForeignKey, DateTime, Boolean, Text
|
|||
from sqlalchemy.orm import relationship, backref, object_mapper
|
||||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
from glance.common import utils
|
||||
import glance.db.sqlalchemy.api
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
|
||||
BASE = declarative_base()
|
||||
|
||||
|
@ -101,7 +101,7 @@ class Image(BASE, ModelBase):
|
|||
"""Represents an image in the datastore"""
|
||||
__tablename__ = 'images'
|
||||
|
||||
id = Column(String(36), primary_key=True, default=utils.generate_uuid)
|
||||
id = Column(String(36), primary_key=True, default=uuidutils.generate_uuid)
|
||||
name = Column(String(255))
|
||||
disk_format = Column(String(20))
|
||||
container_format = Column(String(20))
|
||||
|
|
|
@ -21,9 +21,9 @@ import datetime
|
|||
import uuid
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance import context
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
import glance.tests.functional.db as db_tests
|
||||
from glance.tests.unit import base
|
||||
|
||||
|
@ -33,13 +33,13 @@ from glance.tests.unit import base
|
|||
# we get the default (created_at). Some tests below expect the fixtures to be
|
||||
# returned in array-order, so if if the created_at timestamps are the same,
|
||||
# these tests rely on the UUID* values being in order
|
||||
UUID1, UUID2, UUID3 = sorted([utils.generate_uuid() for x in range(3)])
|
||||
UUID1, UUID2, UUID3 = sorted([uuidutils.generate_uuid() for x in range(3)])
|
||||
|
||||
|
||||
def build_image_fixture(**kwargs):
|
||||
default_datetime = timeutils.utcnow()
|
||||
image = {
|
||||
'id': utils.generate_uuid(),
|
||||
'id': uuidutils.generate_uuid(),
|
||||
'name': 'fake image #2',
|
||||
'status': 'active',
|
||||
'disk_format': 'vhd',
|
||||
|
@ -229,8 +229,8 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
self.assertEquals(image['id'], self.fixtures[0]['id'])
|
||||
|
||||
def test_image_get_not_owned(self):
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT2 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
TENANT2 = uuidutils.generate_uuid()
|
||||
ctxt1 = context.RequestContext(is_admin=False, tenant=TENANT1)
|
||||
ctxt2 = context.RequestContext(is_admin=False, tenant=TENANT2)
|
||||
image = self.db_api.image_create(
|
||||
|
@ -239,7 +239,7 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
self.db_api.image_get, ctxt2, image['id'])
|
||||
|
||||
def test_image_get_not_found(self):
|
||||
UUID = utils.generate_uuid()
|
||||
UUID = uuidutils.generate_uuid()
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.db_api.image_get, self.context, UUID)
|
||||
|
||||
|
@ -364,16 +364,16 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
self.assertEquals(0, len(images))
|
||||
|
||||
def test_image_get_all_owned(self):
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
ctxt1 = context.RequestContext(is_admin=False, tenant=TENANT1)
|
||||
UUIDX = utils.generate_uuid()
|
||||
UUIDX = uuidutils.generate_uuid()
|
||||
self.db_api.image_create(ctxt1, {'id': UUIDX,
|
||||
'status': 'queued',
|
||||
'owner': TENANT1})
|
||||
|
||||
TENANT2 = utils.generate_uuid()
|
||||
TENANT2 = uuidutils.generate_uuid()
|
||||
ctxt2 = context.RequestContext(is_admin=False, tenant=TENANT2)
|
||||
UUIDY = utils.generate_uuid()
|
||||
UUIDY = uuidutils.generate_uuid()
|
||||
self.db_api.image_create(ctxt2, {'id': UUIDY,
|
||||
'status': 'queued',
|
||||
'owner': TENANT2})
|
||||
|
@ -385,7 +385,7 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
|
||||
def test_image_paginate(self):
|
||||
"""Paginate through a list of images using limit and marker"""
|
||||
extra_uuids = [utils.generate_uuid() for i in range(2)]
|
||||
extra_uuids = [uuidutils.generate_uuid() for i in range(2)]
|
||||
extra_images = [build_image_fixture(id=_id) for _id in extra_uuids]
|
||||
self.create_images(extra_images)
|
||||
|
||||
|
@ -453,7 +453,7 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
memberships = self.db_api.image_member_find(self.context)
|
||||
self.assertEqual([], memberships)
|
||||
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
self.db_api.image_member_create(self.context,
|
||||
{'member': TENANT1, 'image_id': UUID1})
|
||||
|
||||
|
@ -469,7 +469,7 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_image_member_update(self):
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
member = self.db_api.image_member_create(self.context,
|
||||
{'member': TENANT1,
|
||||
'image_id': UUID1})
|
||||
|
@ -494,8 +494,8 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
self.assertEqual(expected, member)
|
||||
|
||||
def test_image_member_find(self):
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT2 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
TENANT2 = uuidutils.generate_uuid()
|
||||
fixtures = [
|
||||
{'member': TENANT1, 'image_id': UUID1},
|
||||
{'member': TENANT1, 'image_id': UUID2},
|
||||
|
@ -522,13 +522,14 @@ class TestDriver(base.IsolatedUnitTest):
|
|||
image_id=UUID1)
|
||||
_assertMemberListMatch([fixtures[2]], output)
|
||||
|
||||
image_id = uuidutils.generate_uuid()
|
||||
output = self.db_api.image_member_find(self.context,
|
||||
member=TENANT2,
|
||||
image_id=utils.generate_uuid())
|
||||
image_id=image_id)
|
||||
_assertMemberListMatch([], output)
|
||||
|
||||
def test_image_member_delete(self):
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
fixture = {'member': TENANT1, 'image_id': UUID1, 'can_share': True}
|
||||
member = self.db_api.image_member_create(self.context, fixture)
|
||||
self.assertEqual(1, len(self.db_api.image_member_find(self.context)))
|
||||
|
@ -547,9 +548,9 @@ class TestVisibility(base.IsolatedUnitTest):
|
|||
self.create_images(self.fixtures)
|
||||
|
||||
def setup_tenants(self):
|
||||
self.admin_tenant = utils.generate_uuid()
|
||||
self.tenant1 = utils.generate_uuid()
|
||||
self.tenant2 = utils.generate_uuid()
|
||||
self.admin_tenant = uuidutils.generate_uuid()
|
||||
self.tenant1 = uuidutils.generate_uuid()
|
||||
self.tenant2 = uuidutils.generate_uuid()
|
||||
|
||||
def setup_contexts(self):
|
||||
self.admin_context = context.RequestContext(
|
||||
|
|
|
@ -20,8 +20,8 @@ import StringIO
|
|||
import nose.plugins.skip
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import cfg
|
||||
from glance.openstack.common import uuidutils
|
||||
import glance.store.location
|
||||
|
||||
#NOTE(bcwaldon): importing this to get the default_store option
|
||||
|
@ -59,7 +59,7 @@ class BaseTestCase(object):
|
|||
"""Add, get and delete an image"""
|
||||
store = self.get_store()
|
||||
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
image_data = StringIO.StringIO('XXX')
|
||||
image_checksum = 'bc9189406be84ec297464a514221406d'
|
||||
try:
|
||||
|
@ -88,7 +88,7 @@ class BaseTestCase(object):
|
|||
|
||||
def test_get_remote_image(self):
|
||||
"""Get an image that was created externally to Glance"""
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
image_uri = self.stash_image(image_id, 'XXX')
|
||||
store = self.get_store()
|
||||
location = glance.store.location.Location(
|
||||
|
|
|
@ -33,8 +33,8 @@ import urllib
|
|||
|
||||
import nose.plugins.skip
|
||||
|
||||
from glance.common import utils
|
||||
import glance.openstack.common.cfg
|
||||
from glance.openstack.common import uuidutils
|
||||
import glance.store.swift
|
||||
import glance.tests.functional.store as store_tests
|
||||
|
||||
|
@ -201,7 +201,7 @@ class TestSwiftStore(store_tests.BaseTestCase, unittest.TestCase):
|
|||
swift_store_large_object_chunk_size=2, # 2 MB
|
||||
)
|
||||
store = self.get_store()
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
image_size = 5242880 # 5 MB
|
||||
image_data = StringIO.StringIO('X' * image_size)
|
||||
image_checksum = 'eb7f8c3716b9f059cee7617a4ba9d0d3'
|
||||
|
@ -302,7 +302,7 @@ class TestSwiftStore(store_tests.BaseTestCase, unittest.TestCase):
|
|||
auth_tok=auth_token)
|
||||
store = self.get_store(context=context)
|
||||
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
image_data = StringIO.StringIO('XXX')
|
||||
uri, _, _ = store.add(image_id, image_data, 3)
|
||||
|
||||
|
@ -312,8 +312,8 @@ class TestSwiftStore(store_tests.BaseTestCase, unittest.TestCase):
|
|||
uri=uri,
|
||||
image_id=image_id)
|
||||
|
||||
read_tenant = utils.generate_uuid()
|
||||
write_tenant = utils.generate_uuid()
|
||||
read_tenant = uudiutils.generate_uuid()
|
||||
write_tenant = uuidutils.generate_uuid()
|
||||
store.set_acls(location,
|
||||
public=False,
|
||||
read_tenants=[read_tenant],
|
||||
|
|
|
@ -36,7 +36,7 @@ import json
|
|||
import httplib2
|
||||
|
||||
from glance.common import crypt
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.tests.functional.store_utils import (setup_s3,
|
||||
teardown_s3,
|
||||
get_s3_uri,
|
||||
|
@ -124,7 +124,7 @@ class TestS3(test_api.TestApi):
|
|||
s3_store_location = crypt.urlsafe_decrypt(key, loc)
|
||||
|
||||
# 4. POST /images using location generated by Image1
|
||||
image_id2 = utils.generate_uuid()
|
||||
image_id2 = uuidutils.generate_uuid()
|
||||
image_data = "*" * FIVE_KB
|
||||
headers = minimal_headers('Image2')
|
||||
headers['X-Image-Meta-Id'] = image_id2
|
||||
|
|
|
@ -37,8 +37,8 @@ import json
|
|||
import os
|
||||
import tempfile
|
||||
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.tests import functional
|
||||
from glance.tests.utils import skip_if_disabled, minimal_headers
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ class TestSSL(functional.FunctionalTest):
|
|||
# 1. DELETE /images/1
|
||||
# Verify 404 returned
|
||||
path = "https://%s:%d/v1/images/%s" % ("127.0.0.1", self.api_port,
|
||||
utils.generate_uuid())
|
||||
uuidutils.generate_uuid())
|
||||
https = httplib2.Http(disable_ssl_certificate_validation=True)
|
||||
response, content = https.request(path, 'DELETE')
|
||||
self.assertEqual(response.status, 404)
|
||||
|
|
|
@ -19,14 +19,14 @@ import json
|
|||
|
||||
import requests
|
||||
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.tests import functional
|
||||
|
||||
|
||||
TENANT1 = utils.generate_uuid()
|
||||
TENANT2 = utils.generate_uuid()
|
||||
TENANT3 = utils.generate_uuid()
|
||||
TENANT4 = utils.generate_uuid()
|
||||
TENANT1 = uuidutils.generate_uuid()
|
||||
TENANT2 = uuidutils.generate_uuid()
|
||||
TENANT3 = uuidutils.generate_uuid()
|
||||
TENANT4 = uuidutils.generate_uuid()
|
||||
|
||||
|
||||
class TestImages(functional.FunctionalTest):
|
||||
|
|
|
@ -19,16 +19,16 @@ import datetime
|
|||
|
||||
from glance.common import config
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance import context
|
||||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.registry import client as rclient
|
||||
from glance.tests.unit import base
|
||||
|
||||
|
||||
_gen_uuid = utils.generate_uuid
|
||||
_gen_uuid = uuidutils.generate_uuid
|
||||
|
||||
UUID1 = _gen_uuid()
|
||||
UUID2 = _gen_uuid()
|
||||
|
|
|
@ -22,7 +22,7 @@ import hashlib
|
|||
import StringIO
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.store.filesystem import Store, ChunkedFile
|
||||
from glance.store.location import get_location_from_uri
|
||||
from glance.tests.unit import base
|
||||
|
@ -45,7 +45,7 @@ class TestStore(base.IsolatedUnitTest):
|
|||
def test_get(self):
|
||||
"""Test a "normal" retrieval of an image in chunks"""
|
||||
# First add an image...
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
file_contents = "chunk00000remainder"
|
||||
location = "file://%s/%s" % (self.test_dir, image_id)
|
||||
image_file = StringIO.StringIO(file_contents)
|
||||
|
@ -83,7 +83,7 @@ class TestStore(base.IsolatedUnitTest):
|
|||
def test_add(self):
|
||||
"""Test that we can add an image via the filesystem backend"""
|
||||
ChunkedFile.CHUNKSIZE = 1024
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
expected_file_size = 1024 * 5 # 5K
|
||||
expected_file_contents = "*" * expected_file_size
|
||||
expected_checksum = hashlib.md5(expected_file_contents).hexdigest()
|
||||
|
@ -118,7 +118,7 @@ class TestStore(base.IsolatedUnitTest):
|
|||
raises an appropriate exception
|
||||
"""
|
||||
ChunkedFile.CHUNKSIZE = 1024
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
file_size = 1024 * 5 # 5K
|
||||
file_contents = "*" * file_size
|
||||
location = "file://%s/%s" % (self.test_dir, image_id)
|
||||
|
@ -134,7 +134,7 @@ class TestStore(base.IsolatedUnitTest):
|
|||
|
||||
def _do_test_add_failure(self, errno, exception):
|
||||
ChunkedFile.CHUNKSIZE = 1024
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
file_size = 1024 * 5 # 5K
|
||||
file_contents = "*" * file_size
|
||||
location = "file://%s/%s" % (self.test_dir, image_id)
|
||||
|
@ -183,7 +183,7 @@ class TestStore(base.IsolatedUnitTest):
|
|||
Test we can delete an existing image in the filesystem store
|
||||
"""
|
||||
# First add an image
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
file_size = 1024 * 5 # 5K
|
||||
file_contents = "*" * file_size
|
||||
location = "file://%s/%s" % (self.test_dir, image_id)
|
||||
|
|
|
@ -24,8 +24,8 @@ import boto.s3.connection
|
|||
import stubout
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import cfg
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.store.location import get_location_from_uri
|
||||
import glance.store.s3
|
||||
from glance.store.s3 import Store, get_s3_location
|
||||
|
@ -34,7 +34,7 @@ from glance.tests.unit import base
|
|||
from glance.tests import utils as test_utils
|
||||
|
||||
|
||||
FAKE_UUID = utils.generate_uuid()
|
||||
FAKE_UUID = uuidutils.generate_uuid()
|
||||
|
||||
FIVE_KB = (5 * 1024)
|
||||
S3_CONF = {'verbose': True,
|
||||
|
@ -234,7 +234,7 @@ class TestStore(base.StoreClearingUnitTest):
|
|||
|
||||
def test_add(self):
|
||||
"""Test that we can add an image via the s3 backend"""
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
expected_s3_size = FIVE_KB
|
||||
expected_s3_contents = "*" * expected_s3_size
|
||||
expected_checksum = hashlib.md5(expected_s3_contents).hexdigest()
|
||||
|
@ -280,7 +280,7 @@ class TestStore(base.StoreClearingUnitTest):
|
|||
'localhost',
|
||||
'localhost:8080/v1']
|
||||
for variation in variations:
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
expected_s3_size = FIVE_KB
|
||||
expected_s3_contents = "*" * expected_s3_size
|
||||
expected_checksum = hashlib.md5(expected_s3_contents).hexdigest()
|
||||
|
|
|
@ -27,8 +27,8 @@ import stubout
|
|||
import swiftclient
|
||||
|
||||
from glance.common import exception
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import cfg
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.store import BackendException
|
||||
from glance.store.location import get_location_from_uri
|
||||
import glance.store.swift
|
||||
|
@ -36,7 +36,7 @@ from glance.tests.unit import base
|
|||
|
||||
CONF = cfg.CONF
|
||||
|
||||
FAKE_UUID = utils.generate_uuid
|
||||
FAKE_UUID = uuidutils.generate_uuid
|
||||
|
||||
Store = glance.store.swift.Store
|
||||
FIVE_KB = (5 * 1024)
|
||||
|
@ -267,7 +267,7 @@ class SwiftTests(object):
|
|||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = "*" * expected_swift_size
|
||||
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
loc = 'swift+https://%s:key@localhost:8080/glance/%s'
|
||||
expected_location = loc % (self.swift_store_user,
|
||||
expected_image_id)
|
||||
|
@ -320,7 +320,7 @@ class SwiftTests(object):
|
|||
}
|
||||
|
||||
for variation, expected_location in variations.items():
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
expected_location = expected_location % (
|
||||
self.swift_store_user, image_id)
|
||||
expected_swift_size = FIVE_KB
|
||||
|
@ -370,7 +370,7 @@ class SwiftTests(object):
|
|||
# simply used self.assertRaises here
|
||||
exception_caught = False
|
||||
try:
|
||||
self.store.add(utils.generate_uuid(), image_swift, 0)
|
||||
self.store.add(uuidutils.generate_uuid(), image_swift, 0)
|
||||
except BackendException, e:
|
||||
exception_caught = True
|
||||
self.assertTrue("container noexist does not exist "
|
||||
|
@ -386,7 +386,7 @@ class SwiftTests(object):
|
|||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = "*" * expected_swift_size
|
||||
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
loc = 'swift+https://%s:key@localhost:8080/noexist/%s'
|
||||
expected_location = loc % (self.swift_store_user,
|
||||
expected_image_id)
|
||||
|
@ -425,7 +425,7 @@ class SwiftTests(object):
|
|||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = "*" * expected_swift_size
|
||||
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
loc = 'swift+https://%s:key@localhost:8080/glance/%s'
|
||||
expected_location = loc % (self.swift_store_user,
|
||||
expected_image_id)
|
||||
|
@ -478,7 +478,7 @@ class SwiftTests(object):
|
|||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = "*" * expected_swift_size
|
||||
expected_checksum = hashlib.md5(expected_swift_contents).hexdigest()
|
||||
expected_image_id = utils.generate_uuid()
|
||||
expected_image_id = uuidutils.generate_uuid()
|
||||
loc = 'swift+https://%s:key@localhost:8080/glance/%s'
|
||||
expected_location = loc % (self.swift_store_user,
|
||||
expected_image_id)
|
||||
|
|
|
@ -26,21 +26,6 @@ from glance.tests import utils as test_utils
|
|||
class TestUtils(test_utils.BaseTestCase):
|
||||
"""Test routines in glance.utils"""
|
||||
|
||||
def test_generate_uuid_format(self):
|
||||
"""Check the format of a uuid"""
|
||||
uuid = utils.generate_uuid()
|
||||
self.assertTrue(isinstance(uuid, basestring))
|
||||
self.assertTrue(len(uuid), 36)
|
||||
# make sure there are 4 dashes
|
||||
self.assertTrue(len(uuid.replace('-', '')), 36)
|
||||
|
||||
def test_generate_uuid_unique(self):
|
||||
"""Ensure generate_uuid will return unique values"""
|
||||
uuids = [utils.generate_uuid() for i in range(5)]
|
||||
# casting to set will drop duplicate values
|
||||
unique = set(uuids)
|
||||
self.assertEqual(len(uuids), len(list(unique)))
|
||||
|
||||
def test_cooperative_reader(self):
|
||||
"""Ensure cooperative reader class accesses all bytes of file"""
|
||||
BYTES = 1024
|
||||
|
|
|
@ -32,12 +32,12 @@ import glance.api.common
|
|||
from glance.api.v1 import images
|
||||
from glance.api.v1 import router
|
||||
import glance.common.config
|
||||
from glance.common import utils
|
||||
import glance.context
|
||||
from glance.db.sqlalchemy import api as db_api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
from glance.openstack.common import cfg
|
||||
from glance.openstack.common import timeutils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.registry.api import v1 as rserver
|
||||
import glance.store.filesystem
|
||||
from glance.tests.unit import base
|
||||
|
@ -46,7 +46,7 @@ from glance.tests import utils as test_utils
|
|||
|
||||
CONF = cfg.CONF
|
||||
|
||||
_gen_uuid = utils.generate_uuid
|
||||
_gen_uuid = uuidutils.generate_uuid
|
||||
|
||||
UUID1 = _gen_uuid()
|
||||
UUID2 = _gen_uuid()
|
||||
|
|
|
@ -18,7 +18,7 @@ import StringIO
|
|||
import webob
|
||||
|
||||
import glance.api.v2.image_data
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import uuidutils
|
||||
from glance.tests.unit import base
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
import glance.tests.utils as test_utils
|
||||
|
@ -51,7 +51,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
def test_download_non_existent_image(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.download,
|
||||
request, utils.generate_uuid())
|
||||
request, uuidutils.generate_uuid())
|
||||
|
||||
def test_upload_download(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
@ -71,7 +71,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
def test_upload_non_existent_image(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.upload,
|
||||
request, utils.generate_uuid(), 'YYYY', 4)
|
||||
request, uuidutils.generate_uuid(), 'YYYY', 4)
|
||||
|
||||
def test_upload_data_exists(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
|
|
|
@ -19,8 +19,8 @@ import json
|
|||
import webob
|
||||
|
||||
import glance.api.v2.images
|
||||
from glance.common import utils
|
||||
from glance.openstack.common import cfg
|
||||
from glance.openstack.common import uuidutils
|
||||
import glance.schema
|
||||
from glance.tests.unit import base
|
||||
import glance.tests.unit.utils as unit_test_utils
|
||||
|
@ -211,7 +211,9 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
self.assertEqual(0, len(images))
|
||||
|
||||
def test_index_with_non_default_is_public_filter(self):
|
||||
image = _fixture(utils.generate_uuid(), is_public=False, owner=TENANT3)
|
||||
image = _fixture(uuidutils.generate_uuid(),
|
||||
is_public=False,
|
||||
owner=TENANT3)
|
||||
self.db.image_create(None, image)
|
||||
path = '/images?visibility=private'
|
||||
request = unit_test_utils.get_fake_request(path, is_admin=True)
|
||||
|
@ -288,7 +290,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
self.assertEquals(UUID1, actual[2])
|
||||
|
||||
def test_index_with_marker_not_found(self):
|
||||
fake_uuid = utils.generate_uuid()
|
||||
fake_uuid = uuidutils.generate_uuid()
|
||||
path = '/images'
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
|
@ -317,7 +319,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
|
||||
# get the image properties into the odd state
|
||||
image = {
|
||||
'id': utils.generate_uuid(),
|
||||
'id': uuidutils.generate_uuid(),
|
||||
'status': 'active',
|
||||
'properties': {'poo': 'bear'},
|
||||
}
|
||||
|
@ -332,7 +334,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
|
||||
def test_show_non_existent(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
image_id = utils.generate_uuid()
|
||||
image_id = uuidutils.generate_uuid()
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, request, image_id)
|
||||
|
||||
|
@ -401,7 +403,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
def test_update_image_doesnt_exist(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.update,
|
||||
request, utils.generate_uuid(), changes=[])
|
||||
request, uuidutils.generate_uuid(), changes=[])
|
||||
|
||||
def test_update_deleted_image_admin(self):
|
||||
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||
|
@ -640,7 +642,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
def test_delete_non_existent(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
request, utils.generate_uuid())
|
||||
request, uuidutils.generate_uuid())
|
||||
|
||||
def test_delete_already_deleted_image_admin(self):
|
||||
request = unit_test_utils.get_fake_request(is_admin=True)
|
||||
|
@ -649,7 +651,7 @@ class TestImagesController(test_utils.BaseTestCase):
|
|||
self.controller.delete, request, UUID1)
|
||||
|
||||
def test_index_with_invalid_marker(self):
|
||||
fake_uuid = utils.generate_uuid()
|
||||
fake_uuid = uuidutils.generate_uuid()
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.index, request, marker=fake_uuid)
|
||||
|
@ -996,7 +998,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
self.deserializer.update, request)
|
||||
|
||||
def test_index(self):
|
||||
marker = utils.generate_uuid()
|
||||
marker = uuidutils.generate_uuid()
|
||||
path = '/images?limit=1&marker=%s' % marker
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
expected = {'limit': 1,
|
||||
|
@ -1024,7 +1026,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
|
||||
def test_index_with_many_filter(self):
|
||||
name = 'My Little Image'
|
||||
instance_id = utils.generate_uuid()
|
||||
instance_id = uuidutils.generate_uuid()
|
||||
path = '/images?name=%(name)s&id=%(instance_id)s' % locals()
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
|
@ -1064,7 +1066,7 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||
self.deserializer.index, request)
|
||||
|
||||
def test_index_marker(self):
|
||||
marker = utils.generate_uuid()
|
||||
marker = uuidutils.generate_uuid()
|
||||
path = '/images?marker=%s' % marker
|
||||
request = unit_test_utils.get_fake_request(path)
|
||||
output = self.deserializer.index(request)
|
||||
|
|
Loading…
Reference in New Issue