Replaces uuid.uuid4 with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids.We should use that function when generating uuids for consistency. Change-Id: I9e1d336a9d99109eb935007e47493afde9a364ae Closes-Bug: #1082248
This commit is contained in:
parent
fa1bacdf4e
commit
9c724026bd
@ -24,10 +24,10 @@ except ImportError:
|
|||||||
import httplib
|
import httplib
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import uuid
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
import webob
|
import webob
|
||||||
import webob.dec
|
import webob.dec
|
||||||
@ -535,7 +535,7 @@ class SimpleDataModel(object):
|
|||||||
"""
|
"""
|
||||||
cstr = self._context_str(context)
|
cstr = self._context_str(context)
|
||||||
if id_ is None:
|
if id_ is None:
|
||||||
id_ = str(uuid.uuid4())
|
id_ = uuidutils.generate_uuid()
|
||||||
if id_ in self.items.setdefault(cstr, {}):
|
if id_ in self.items.setdefault(cstr, {}):
|
||||||
raise KeyError("Cannot create item with ID '%s': "
|
raise KeyError("Cannot create item with ID '%s': "
|
||||||
"ID already exists" % id_)
|
"ID already exists" % id_)
|
||||||
|
@ -20,13 +20,12 @@ import argparse
|
|||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import functools
|
import functools
|
||||||
import uuid
|
|
||||||
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from congress.datalog import analysis
|
from congress.datalog import analysis
|
||||||
from congress.datalog import base
|
from congress.datalog import base
|
||||||
@ -917,7 +916,7 @@ class Rule(object):
|
|||||||
self.body = body
|
self.body = body
|
||||||
self.location = location
|
self.location = location
|
||||||
self._hash = None
|
self._hash = None
|
||||||
self.id = id or uuid.uuid4()
|
self.id = id or uuidutils.generate_uuid()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.comment = comment
|
self.comment = comment
|
||||||
self.original_str = original_str
|
self.original_str = original_str
|
||||||
|
@ -17,9 +17,8 @@ from __future__ import print_function
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
|
|
||||||
from congress.datalog import compile
|
from congress.datalog import compile
|
||||||
@ -521,6 +520,7 @@ def skolemize(formulas):
|
|||||||
|
|
||||||
binding = {}
|
binding = {}
|
||||||
for var in variables:
|
for var in variables:
|
||||||
binding[var] = compile.Term.create_from_python(str(uuid.uuid4()))
|
binding[var] = compile.Term.create_from_python(
|
||||||
|
uuidutils.generate_uuid())
|
||||||
|
|
||||||
return [formula.plug(binding) for formula in formulas]
|
return [formula.plug(binding) for formula in formulas]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import six
|
import six
|
||||||
import uuid
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
eventlet.monkey_patch() # for using oslo.messaging w/ eventlet executor
|
eventlet.monkey_patch() # for using oslo.messaging w/ eventlet executor
|
||||||
@ -123,7 +123,8 @@ class DseNode(object):
|
|||||||
self.node_rpc_endpoints.append(DseNodeEndpoints(self))
|
self.node_rpc_endpoints.append(DseNodeEndpoints(self))
|
||||||
self._running = False
|
self._running = False
|
||||||
self._services = []
|
self._services = []
|
||||||
self.instance = uuid.uuid4() # uuid to help recognize node_id clash
|
# uuid to help recognize node_id clash
|
||||||
|
self.instance = uuidutils.generate_uuid()
|
||||||
# TODO(dse2): add detection and logging/rectifying for node_id clash?
|
# TODO(dse2): add detection and logging/rectifying for node_id clash?
|
||||||
self.context = self._message_context()
|
self.context = self._message_context()
|
||||||
self.transport = messaging.get_transport(
|
self.transport = messaging.get_transport(
|
||||||
|
@ -17,7 +17,7 @@ from __future__ import print_function
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import uuid
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from congress.api import webservice
|
from congress.api import webservice
|
||||||
from congress.tests.api import base as api_base
|
from congress.tests.api import base as api_base
|
||||||
@ -63,7 +63,7 @@ class TestStatusModel(base.SqlTestCase):
|
|||||||
self.assertEqual(expected_status, status)
|
self.assertEqual(expected_status, status)
|
||||||
|
|
||||||
def test_invalid_policy_id_status(self):
|
def test_invalid_policy_id_status(self):
|
||||||
invalid_id = uuid.uuid4()
|
invalid_id = uuidutils.generate_uuid()
|
||||||
context = {'policy_id': invalid_id}
|
context = {'policy_id': invalid_id}
|
||||||
self.assertRaises(webservice.DataModelException,
|
self.assertRaises(webservice.DataModelException,
|
||||||
self.status_model.get_item, None, {},
|
self.status_model.get_item, None, {},
|
||||||
@ -98,7 +98,7 @@ class TestStatusModel(base.SqlTestCase):
|
|||||||
def test_rule_status_invalid_rule_policy_id(self):
|
def test_rule_status_invalid_rule_policy_id(self):
|
||||||
result = self.policy_model.add_item({'name': 'test_policy'}, {})
|
result = self.policy_model.add_item({'name': 'test_policy'}, {})
|
||||||
policy_id = result[0]
|
policy_id = result[0]
|
||||||
invalid_rule = uuid.uuid4()
|
invalid_rule = uuidutils.generate_uuid()
|
||||||
|
|
||||||
context = {'policy_id': policy_id, 'rule_id': invalid_rule}
|
context = {'policy_id': policy_id, 'rule_id': invalid_rule}
|
||||||
self.assertRaises(webservice.DataModelException,
|
self.assertRaises(webservice.DataModelException,
|
||||||
@ -106,8 +106,8 @@ class TestStatusModel(base.SqlTestCase):
|
|||||||
context=context)
|
context=context)
|
||||||
|
|
||||||
def test_rule_status_invalid_policy_id(self):
|
def test_rule_status_invalid_policy_id(self):
|
||||||
invalid_policy = uuid.uuid4()
|
invalid_policy = uuidutils.generate_uuid()
|
||||||
invalid_rule = uuid.uuid4()
|
invalid_rule = uuidutils.generate_uuid()
|
||||||
|
|
||||||
context = {'policy_id': invalid_policy, 'rule_id': invalid_rule}
|
context = {'policy_id': invalid_policy, 'rule_id': invalid_rule}
|
||||||
self.assertRaises(webservice.DataModelException,
|
self.assertRaises(webservice.DataModelException,
|
||||||
|
@ -23,18 +23,19 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import httplib
|
import httplib
|
||||||
import json
|
import json
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
from congress.api import webservice
|
from congress.api import webservice
|
||||||
from congress.tests import base
|
from congress.tests import base
|
||||||
|
|
||||||
|
|
||||||
class TestSimpleDataModel(base.TestCase):
|
class TestSimpleDataModel(base.TestCase):
|
||||||
# if random ID matches, go to Vegas or file a uuid library bug
|
# if random ID matches, go to Vegas or file a uuid library bug
|
||||||
UNADDED_ID = str(uuid.uuid4())
|
UNADDED_ID = uuidutils.generate_uuid()
|
||||||
CONTEXTS = [None, {'a': 'ctxt1'}, {'b': 'ctxt2', 'c': 'ctxt3'}]
|
CONTEXTS = [None, {'a': 'ctxt1'}, {'b': 'ctxt2', 'c': 'ctxt3'}]
|
||||||
|
|
||||||
def test_get_items(self):
|
def test_get_items(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user