Replaces uuid.uuid4 with uuidutils.generate_uuid()

Change-Id: I27f8babfc8a995f3433cc1f94526b87bd70a4757
This commit is contained in:
iswarya_vakati 2017-07-05 16:43:18 +05:30 committed by iswarya vakati
parent 514aeb9e6d
commit 979233cfb1
6 changed files with 31 additions and 31 deletions

View File

@ -28,7 +28,6 @@ from eventlet.green import socket
import hashlib
import os
import re
import uuid
from OpenSSL import crypto
from oslo_config import cfg
@ -36,6 +35,7 @@ from oslo_log import log as logging
from oslo_utils import encodeutils
from oslo_utils import excutils
from oslo_utils import timeutils
from oslo_utils import uuidutils
from oslo_versionedobjects import fields
import six
@ -236,7 +236,7 @@ def validate_key_cert(key_file, cert_file):
'ce': ce})
try:
data = str(uuid.uuid4())
data = uuidutils.generate_uuid()
# On Python 3, explicitly encode to UTF-8 to call crypto.sign() which
# requires bytes. Otherwise, it raises a deprecation warning (and
# will raise an error later).

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from oslo_db.sqlalchemy import models
from oslo_utils import timeutils
from oslo_utils import uuidutils
from sqlalchemy import BigInteger
from sqlalchemy import Boolean
from sqlalchemy import Column
@ -103,7 +103,7 @@ class Artifact(BASE, ArtifactBase):
__protected_attributes__ = set(["created_at", "updated_at"])
id = Column(String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))
default=lambda: uuidutils.generate_uuid())
name = Column(String(255), nullable=False)
type_name = Column(String(255), nullable=False)
version_prefix = Column(BigInteger().with_variant(Integer, "sqlite"),
@ -182,7 +182,7 @@ class ArtifactTag(BASE, ArtifactBase):
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
default=lambda: uuidutils.generate_uuid())
artifact_id = Column(String(36), ForeignKey('glare_artifacts.id'),
nullable=False)
artifact = relationship(Artifact,
@ -198,7 +198,7 @@ class ArtifactProperty(BASE, ArtifactBase):
Index('ix_glare_artifact_properties_name', 'name'),
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
default=lambda: uuidutils.generate_uuid())
artifact_id = Column(String(36), ForeignKey('glare_artifacts.id'),
nullable=False)
artifact = relationship(Artifact,
@ -220,7 +220,7 @@ class ArtifactBlob(BASE, ArtifactBase):
Index('ix_glare_artifact_blobs_name', 'name'),
{'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8'},)
id = Column(String(36), primary_key=True, nullable=False,
default=lambda: str(uuid.uuid4()))
default=lambda: uuidutils.generate_uuid())
artifact_id = Column(String(36), ForeignKey('glare_artifacts.id'),
nullable=False)
name = Column(String(255), nullable=False)

View File

@ -14,11 +14,11 @@
# under the License.
from copy import deepcopy
import uuid
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import timeutils
from oslo_utils import uuidutils
from oslo_versionedobjects import base
from oslo_versionedobjects import fields
import six
@ -260,7 +260,7 @@ class BaseArtifact(base.VersionedObject):
msg = _("visibility is not allowed in a request "
"for artifact create.")
raise exception.BadRequest(msg)
values['id'] = str(uuid.uuid4())
values['id'] = uuidutils.generate_uuid()
values['owner'] = context.tenant
values['created_at'] = timeutils.utcnow()
values['updated_at'] = values['created_at']

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import jsonschema
from jsonschema import exceptions as json_exceptions
from oslo_utils import uuidutils
from oslo_versionedobjects import fields
import semantic_version
import six
@ -81,7 +81,7 @@ class BlobFieldType(fields.FieldType):
if not isinstance(value, dict):
raise ValueError(_("Blob value must be dict. Got %s type instead")
% type(value))
value.setdefault('id', str(uuid.uuid4()))
value.setdefault('id', uuidutils.generate_uuid())
try:
jsonschema.validate(value, BlobFieldType.BLOB_SCHEMA)
except json_exceptions.ValidationError as e:

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
import requests
from glare.tests import functional
@ -31,21 +31,21 @@ class TestArtifact(functional.FunctionalTest):
users = {
'user1': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'role': 'member'
},
'user2': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'role': 'member'
},
'admin': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'role': 'admin'
},
'anonymous': {

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import uuid
import fixtures
import glance_store as store
@ -22,6 +21,7 @@ import jsonpatch
from oslo_config import cfg
from oslo_config import fixture as cfg_fixture
from oslo_policy import policy as os_policy
from oslo_utils import uuidutils
import testtools
from glare.api.middleware import context
@ -41,21 +41,21 @@ class BaseTestCase(testtools.TestCase):
self.users = {
'user1': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'roles': ['member']
},
'user2': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'roles': ['member']
},
'admin': {
'id': str(uuid.uuid4()),
'tenant_id': str(uuid.uuid4()),
'token': str(uuid.uuid4()),
'id': uuidutils.generate_uuid(),
'tenant_id': uuidutils.generate_uuid(),
'token': uuidutils.generate_uuid(),
'roles': ['admin']
},
'anonymous': {