Replaces uuid.uuid4 with uuidutils.generate_uuid()
Openstack oslo_utils has a generate_uuid function for generating uuids. We should use that function when generating uuids for consistency. Change-Id: Id089bcbd67f1cc185ad6672b6447e62dda05c0dd
This commit is contained in:
parent
9261b85dbf
commit
7617411a98
|
@ -13,16 +13,14 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid as uuid_lib
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute import cloudpipe as cloudpipe_v21
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
|
||||
|
||||
project_id = str(uuid_lib.uuid4().hex)
|
||||
project_id = uuidutils.generate_uuid(dashed=False)
|
||||
|
||||
|
||||
class CloudpipeTestV21(test.NoDBTestCase):
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
import copy
|
||||
import string
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from nova.compute import flavors
|
||||
|
@ -87,11 +87,12 @@ class ComputeValidateDeviceTestCase(test.NoDBTestCase):
|
|||
# check if test name includes "xen"
|
||||
if 'xen' in self.id():
|
||||
self.flags(compute_driver='xenapi.XenAPIDriver')
|
||||
self.instance = objects.Instance(uuid=uuid.uuid4().hex,
|
||||
root_device_name=None,
|
||||
default_ephemeral_device=None)
|
||||
self.instance = objects.Instance(
|
||||
uuid=uuidutils.generate_uuid(dashed=False),
|
||||
root_device_name=None, default_ephemeral_device=None)
|
||||
else:
|
||||
self.instance = objects.Instance(uuid=uuid.uuid4().hex,
|
||||
self.instance = objects.Instance(
|
||||
uuid=uuidutils.generate_uuid(dashed=False),
|
||||
root_device_name='/dev/vda',
|
||||
default_ephemeral_device='/dev/vdb')
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
import copy
|
||||
import datetime
|
||||
import uuid as stdlib_uuid
|
||||
|
||||
import iso8601
|
||||
import mock
|
||||
|
@ -9136,7 +9135,7 @@ class ArchiveTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||
|
||||
self.uuidstrs = []
|
||||
for _ in range(6):
|
||||
self.uuidstrs.append(stdlib_uuid.uuid4().hex)
|
||||
self.uuidstrs.append(uuidutils.generate_uuid(dashed=False))
|
||||
|
||||
def _assert_shadow_tables_empty_except(self, *exceptions):
|
||||
"""Ensure shadow tables are empty
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from oslo_db.sqlalchemy.compat import utils as compat_utils
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import utils as oslodbutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy import Integer, String
|
||||
from sqlalchemy import MetaData, Table, Column
|
||||
from sqlalchemy.exc import NoSuchTableError
|
||||
|
@ -61,7 +60,7 @@ class TestMigrationUtilsSQLite(test_base.DbTestCase):
|
|||
table_name = "__test_deletefromselect_table__"
|
||||
uuidstrs = []
|
||||
for unused in range(10):
|
||||
uuidstrs.append(uuid.uuid4().hex)
|
||||
uuidstrs.append(uuidutils.generate_uuid(dashed=False))
|
||||
|
||||
conn = self.engine.connect()
|
||||
test_table = Table(table_name, self.meta,
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
import copy
|
||||
import itertools
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from nova.compute import flavors
|
||||
from nova import context
|
||||
|
@ -256,7 +256,7 @@ class ApiTestCase(test.TestCase):
|
|||
fake_flavor = flavors.get_default_flavor()
|
||||
fake_flavor['rxtx_factor'] = 1.21
|
||||
fake_instance = objects.Instance(
|
||||
uuid=uuid.uuid4().hex,
|
||||
uuid=uuidutils.generate_uuid(dashed=False),
|
||||
project_id='fake_project_id',
|
||||
instance_type_id=fake_flavor['id'],
|
||||
flavor=fake_flavor,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import collections
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
from keystoneauth1.fixture import V2Token
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
|
@ -31,6 +30,7 @@ from oslo_config import fixture as config_fixture
|
|||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import requests_mock
|
||||
import six
|
||||
from six.moves import range
|
||||
|
@ -5753,7 +5753,7 @@ class TestNeutronClientForAdminScenarios(test.NoDBTestCase):
|
|||
@requests_mock.mock()
|
||||
def _test_get_client_for_admin(self, req_mock,
|
||||
use_id=False, admin_context=False):
|
||||
token_value = uuid.uuid4().hex
|
||||
token_value = uuidutils.generate_uuid(dashed=False)
|
||||
auth_url = 'http://anyhost/auth'
|
||||
token_resp = V2Token(token_id=token_value)
|
||||
req_mock.post(auth_url + '/tokens', json=token_resp)
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
# under the License.
|
||||
|
||||
import re
|
||||
import uuid
|
||||
from xml.dom import minidom
|
||||
|
||||
from eventlet import greenthread
|
||||
from lxml import etree
|
||||
import mock
|
||||
from oslo_concurrency.fixture import lockutils as lock_fixture
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from nova import exception
|
||||
from nova.network import linux_net
|
||||
|
@ -65,7 +65,7 @@ class NWFilterFakes(object):
|
|||
name = tree.get('name')
|
||||
u = tree.find('uuid')
|
||||
if u is None:
|
||||
u = uuid.uuid4().hex
|
||||
u = uuidutils.generate_uuid(dashed=False)
|
||||
else:
|
||||
u = u.text
|
||||
if name not in self.filters:
|
||||
|
|
|
@ -57,6 +57,7 @@ from oslo_utils import importutils
|
|||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
|
@ -1598,7 +1599,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
image_format,
|
||||
snapshot['name'])
|
||||
|
||||
snapshot_name = uuid.uuid4().hex
|
||||
snapshot_name = uuidutils.generate_uuid(dashed=False)
|
||||
|
||||
state = guest.get_power_state(self._host)
|
||||
|
||||
|
@ -7347,7 +7348,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
return True
|
||||
shared_storage = (dest == self.get_host_ip_addr())
|
||||
if not shared_storage:
|
||||
tmp_file = uuid.uuid4().hex + '.tmp'
|
||||
tmp_file = uuidutils.generate_uuid(dashed=False) + '.tmp'
|
||||
tmp_path = os.path.join(inst_base, tmp_file)
|
||||
|
||||
try:
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
from eventlet import greenthread
|
||||
from lxml import etree
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
import nova.conf
|
||||
import nova.virt.firewall as base_firewall
|
||||
|
@ -235,7 +234,7 @@ class NWFilterFirewall(base_firewall.FirewallDriver):
|
|||
except Exception as e:
|
||||
LOG.debug(u"Cannot find UUID for filter '%(name)s': '%(e)s'",
|
||||
{'name': name, 'e': e})
|
||||
u = uuid.uuid4().hex
|
||||
u = uuidutils.generate_uuid(dashed=False)
|
||||
|
||||
LOG.debug("UUID for filter '%s' is '%s'", name, u)
|
||||
return u
|
||||
|
|
Loading…
Reference in New Issue