Replaces uuid.uuid4 with uuidutils.generate_uuid()
oslo_utils.uuidutils has a wrapper for generating uuids. We should only use that function when generating uuids for consistency. Change-Id: I566f930afe2a287b0aaa3b12500138befc683f11 Closes-Bug: #1082248
This commit is contained in:
parent
52bdf321c4
commit
2f40bdab36
@ -12,11 +12,11 @@
|
||||
|
||||
import ast
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
from oslo_db.exception import DBDuplicateEntry
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from six import iteritems
|
||||
|
||||
import sqlalchemy as sa
|
||||
@ -175,7 +175,7 @@ class NSPluginDb(network_service.NSPluginBase, db_base.CommonDbMixin):
|
||||
|
||||
try:
|
||||
with context.session.begin(subtransactions=True):
|
||||
nsd_id = str(uuid.uuid4())
|
||||
nsd_id = uuidutils.generate_uuid()
|
||||
nsd_db = NSD(
|
||||
id=nsd_id,
|
||||
tenant_id=tenant_id,
|
||||
@ -187,7 +187,7 @@ class NSPluginDb(network_service.NSPluginBase, db_base.CommonDbMixin):
|
||||
context.session.add(nsd_db)
|
||||
for (key, value) in nsd.get('attributes', {}).items():
|
||||
attribute_db = NSDAttribute(
|
||||
id=str(uuid.uuid4()),
|
||||
id=uuidutils.generate_uuid(),
|
||||
nsd_id=nsd_id,
|
||||
key=key,
|
||||
value=value)
|
||||
@ -254,7 +254,7 @@ class NSPluginDb(network_service.NSPluginBase, db_base.CommonDbMixin):
|
||||
nsd_id = ns['nsd_id']
|
||||
vim_id = ns['vim_id']
|
||||
name = ns.get('name')
|
||||
ns_id = str(uuid.uuid4())
|
||||
ns_id = uuidutils.generate_uuid()
|
||||
try:
|
||||
with context.session.begin(subtransactions=True):
|
||||
nsd_db = self._get_resource(context, NSD,
|
||||
|
@ -13,9 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import random
|
||||
import sqlalchemy as sa
|
||||
import uuid
|
||||
|
||||
from oslo_log import log as logging
|
||||
from six import iteritems
|
||||
@ -195,8 +195,8 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
|
||||
def create_vnffg(self, context, vnffg):
|
||||
vnffg_dict = self._create_vnffg_pre(context, vnffg)
|
||||
sfc_instance = str(uuid.uuid4())
|
||||
fc_instance = str(uuid.uuid4())
|
||||
sfc_instance = uuidutils.generate_uuid()
|
||||
fc_instance = uuidutils.generate_uuid()
|
||||
self._create_vnffg_post(context, sfc_instance,
|
||||
fc_instance, vnffg_dict)
|
||||
self._create_vnffg_status(context, vnffg_dict)
|
||||
@ -226,7 +226,7 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
template_source = template.get('template_source')
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
template_id = str(uuid.uuid4())
|
||||
template_id = uuidutils.generate_uuid()
|
||||
template_db = VnffgTemplate(
|
||||
id=template_id,
|
||||
tenant_id=tenant_id,
|
||||
@ -332,7 +332,7 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
LOG.debug('vnffg %s', vnffg)
|
||||
tenant_id = self._get_tenant_id_for_create(context, vnffg)
|
||||
name = vnffg.get('name')
|
||||
vnffg_id = vnffg.get('id') or str(uuid.uuid4())
|
||||
vnffg_id = vnffg.get('id') or uuidutils.generate_uuid()
|
||||
template_id = vnffg['vnffgd_id']
|
||||
symmetrical = vnffg['symmetrical']
|
||||
|
||||
@ -370,9 +370,9 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
status=constants.PENDING_CREATE)
|
||||
context.session.add(vnffg_db)
|
||||
|
||||
nfp_id = str(uuid.uuid4())
|
||||
sfc_id = str(uuid.uuid4())
|
||||
classifier_id = str(uuid.uuid4())
|
||||
nfp_id = uuidutils.generate_uuid()
|
||||
sfc_id = uuidutils.generate_uuid()
|
||||
classifier_id = uuidutils.generate_uuid()
|
||||
|
||||
nfp_db = VnffgNfp(id=nfp_id, vnffg_id=vnffg_id,
|
||||
tenant_id=tenant_id,
|
||||
@ -408,7 +408,7 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
LOG.debug('acl_match %s', match)
|
||||
|
||||
match_db_table = ACLMatchCriteria(
|
||||
id=str(uuid.uuid4()),
|
||||
id=uuidutils.generate_uuid(),
|
||||
vnffgc_id=classifier_id,
|
||||
**match)
|
||||
|
||||
@ -671,7 +671,7 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
|
||||
"""
|
||||
# this should be overridden with driver call to find ID given name
|
||||
# for resource
|
||||
return str(uuid.uuid4())
|
||||
return uuidutils.generate_uuid()
|
||||
|
||||
# called internally, not by REST API
|
||||
# instance_id = None means error on creation
|
||||
|
@ -17,8 +17,7 @@ import codecs
|
||||
from datetime import datetime
|
||||
import mock
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from mock import patch
|
||||
|
||||
@ -57,7 +56,7 @@ class FakeDriverManager(mock.Mock):
|
||||
def invoke(self, *args, **kwargs):
|
||||
if any(x in ['create', 'create_chain', 'create_flow_classifier'] for
|
||||
x in args):
|
||||
return str(uuid.uuid4())
|
||||
return uuidutils.generate_uuid()
|
||||
elif 'execute_workflow' in args:
|
||||
mock_execution = mock.Mock()
|
||||
mock_execution.id.return_value = \
|
||||
@ -724,7 +723,7 @@ class TestNfvoPlugin(db_base.SqlTestCase):
|
||||
session.add(nsd_template)
|
||||
for (key, value) in attributes.items():
|
||||
attribute_db = ns_db.NSDAttribute(
|
||||
id=str(uuid.uuid4()),
|
||||
id=uuidutils.generate_uuid(),
|
||||
nsd_id='eb094833-995e-49f0-a047-dfb56aaf7c4e',
|
||||
key=key,
|
||||
value=value)
|
||||
@ -761,7 +760,7 @@ class TestNfvoPlugin(db_base.SqlTestCase):
|
||||
session.add(nsd_template)
|
||||
for (key, value) in attributes.items():
|
||||
attribute_db = ns_db.NSDAttribute(
|
||||
id=str(uuid.uuid4()),
|
||||
id=uuidutils.generate_uuid(),
|
||||
nsd_id='be18005d-5656-4d81-b499-6af4d4d8437f',
|
||||
key=key,
|
||||
value=value)
|
||||
|
Loading…
Reference in New Issue
Block a user