Merge "Replace uuid.uuid4() with uuidutils.generate_uuid()"
This commit is contained in:
@@ -10,10 +10,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from keystoneauth1 import plugin as ksa_plugin
|
from keystoneauth1 import plugin as ksa_plugin
|
||||||
from keystoneauth1 import session
|
from keystoneauth1 import session
|
||||||
|
from oslo_utils import uuidutils
|
||||||
from tempest.lib import base
|
from tempest.lib import base
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
@@ -95,11 +95,11 @@ class LibraryTestCase(object):
|
|||||||
self.assertIsInstance(nets['networks'], list)
|
self.assertIsInstance(nets['networks'], list)
|
||||||
|
|
||||||
def test_post_put_delete_network(self):
|
def test_post_put_delete_network(self):
|
||||||
name = str(uuid.uuid4())
|
name = uuidutils.generate_uuid()
|
||||||
net = self.client.create_network({'network': {'name': name}})
|
net = self.client.create_network({'network': {'name': name}})
|
||||||
net_id = net['network']['id']
|
net_id = net['network']['id']
|
||||||
self.assertEqual(name, net['network']['name'])
|
self.assertEqual(name, net['network']['name'])
|
||||||
name2 = str(uuid.uuid4())
|
name2 = uuidutils.generate_uuid()
|
||||||
net = self.client.update_network(net_id, {'network': {'name': name2}})
|
net = self.client.update_network(net_id, {'network': {'name': name2}})
|
||||||
self.assertEqual(name2, net['network']['name'])
|
self.assertEqual(name2, net['network']['name'])
|
||||||
self.client.delete_network(net_id)
|
self.client.delete_network(net_id)
|
||||||
|
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
|
|
||||||
class FakeFWaaS(object):
|
class FakeFWaaS(object):
|
||||||
@@ -67,16 +67,20 @@ class FirewallGroup(FakeFWaaS):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FirewallGroup, self).__init__()
|
super(FirewallGroup, self).__init__()
|
||||||
self.ordered = collections.OrderedDict((
|
self.ordered = collections.OrderedDict((
|
||||||
('id', 'firewall-group-id-' + uuid.uuid4().hex),
|
('id', 'firewall-group-id-' +
|
||||||
('name', 'my-group-' + uuid.uuid4().hex),
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
|
('name', 'my-group-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('ingress_firewall_policy_id', None),
|
('ingress_firewall_policy_id', None),
|
||||||
('egress_firewall_policy_id', None),
|
('egress_firewall_policy_id', None),
|
||||||
('description', 'my-desc-' + uuid.uuid4().hex),
|
('description', 'my-desc-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('status', 'INACTIVE'),
|
('status', 'INACTIVE'),
|
||||||
('ports', []),
|
('ports', []),
|
||||||
('admin_state_up', True),
|
('admin_state_up', True),
|
||||||
('public', False),
|
('public', False),
|
||||||
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
|
('tenant_id', 'tenant-id-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
@@ -86,13 +90,17 @@ class FirewallPolicy(FakeFWaaS):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FirewallPolicy, self).__init__()
|
super(FirewallPolicy, self).__init__()
|
||||||
self.ordered = collections.OrderedDict((
|
self.ordered = collections.OrderedDict((
|
||||||
('id', 'firewall-policy-' + uuid.uuid4().hex),
|
('id', 'firewall-policy-' +
|
||||||
('name', 'my-policy-' + uuid.uuid4().hex),
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
|
('name', 'my-policy-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('firewall_rules', []),
|
('firewall_rules', []),
|
||||||
('description', 'my-desc-' + uuid.uuid4().hex),
|
('description', 'my-desc-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('audited', True),
|
('audited', True),
|
||||||
('public', False),
|
('public', False),
|
||||||
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
|
('tenant_id', 'tenant-id-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
@@ -102,10 +110,13 @@ class FirewallRule(FakeFWaaS):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FirewallRule, self).__init__()
|
super(FirewallRule, self).__init__()
|
||||||
self.ordered = collections.OrderedDict((
|
self.ordered = collections.OrderedDict((
|
||||||
('id', 'firewall-rule-id-' + uuid.uuid4().hex),
|
('id', 'firewall-rule-id-' +
|
||||||
('name', 'my-rule-' + uuid.uuid4().hex),
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
|
('name', 'my-rule-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('enabled', False),
|
('enabled', False),
|
||||||
('description', 'my-desc-' + uuid.uuid4().hex),
|
('description', 'my-desc-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
('ip_version', 4),
|
('ip_version', 4),
|
||||||
('action', 'deny'),
|
('action', 'deny'),
|
||||||
('protocol', None),
|
('protocol', None),
|
||||||
@@ -114,5 +125,6 @@ class FirewallRule(FakeFWaaS):
|
|||||||
('destination_ip_address', '192.168.2.2'),
|
('destination_ip_address', '192.168.2.2'),
|
||||||
('destination_port', '2:22222'),
|
('destination_port', '2:22222'),
|
||||||
('public', False),
|
('public', False),
|
||||||
('tenant_id', 'tenant-id-' + uuid.uuid4().hex),
|
('tenant_id', 'tenant-id-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False)),
|
||||||
))
|
))
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import uuid
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
|
|
||||||
class FakeTrunk(object):
|
class FakeTrunk(object):
|
||||||
@@ -32,14 +32,16 @@ class FakeTrunk(object):
|
|||||||
|
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
trunk_attrs = {
|
trunk_attrs = {
|
||||||
'id': 'trunk-id-' + uuid.uuid4().hex,
|
'id': 'trunk-id-' + uuidutils.generate_uuid(dashed=False),
|
||||||
'name': 'trunk-name-' + uuid.uuid4().hex,
|
'name': 'trunk-name-' + uuidutils.generate_uuid(dashed=False),
|
||||||
'description': '',
|
'description': '',
|
||||||
'port_id': 'port-' + uuid.uuid4().hex,
|
'port_id': 'port-' + uuidutils.generate_uuid(dashed=False),
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'project_id': 'project-id-' + uuid.uuid4().hex,
|
'project_id': 'project-id-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False),
|
||||||
'status': 'ACTIVE',
|
'status': 'ACTIVE',
|
||||||
'sub_ports': [{'port_id': 'subport-' + uuid.uuid4().hex,
|
'sub_ports': [{'port_id': 'subport-' +
|
||||||
|
uuidutils.generate_uuid(dashed=False),
|
||||||
'segmentation_type': 'vlan',
|
'segmentation_type': 'vlan',
|
||||||
'segmentation_id': 100}],
|
'segmentation_id': 100}],
|
||||||
}
|
}
|
||||||
|
@@ -15,9 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
|
||||||
|
|
||||||
from mox3 import mox
|
from mox3 import mox
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from neutronclient.common import exceptions
|
from neutronclient.common import exceptions
|
||||||
@@ -534,9 +534,9 @@ class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
|
|||||||
protocol=None, port_range_min=None, port_range_max=None,
|
protocol=None, port_range_min=None, port_range_max=None,
|
||||||
remote_ip_prefix=None, remote_group_id=None,
|
remote_ip_prefix=None, remote_group_id=None,
|
||||||
filters=None):
|
filters=None):
|
||||||
rule = {'id': rule_id or str(uuid.uuid4()),
|
rule = {'id': rule_id or uuidutils.generate_uuid(),
|
||||||
'tenant_id': tenant_id or str(uuid.uuid4()),
|
'tenant_id': tenant_id or uuidutils.generate_uuid(),
|
||||||
'security_group_id': sg_id or str(uuid.uuid4()),
|
'security_group_id': sg_id or uuidutils.generate_uuid(),
|
||||||
'direction': direction or 'ingress',
|
'direction': direction or 'ingress',
|
||||||
'ethertype': ethertype or 'IPv4',
|
'ethertype': ethertype or 'IPv4',
|
||||||
'protocol': protocol,
|
'protocol': protocol,
|
||||||
|
@@ -14,8 +14,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import uuid
|
|
||||||
|
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import osprofiler.profiler
|
import osprofiler.profiler
|
||||||
import osprofiler.web
|
import osprofiler.web
|
||||||
from requests_mock.contrib import fixture as mock_fixture
|
from requests_mock.contrib import fixture as mock_fixture
|
||||||
@@ -128,7 +128,7 @@ class TestHTTPClientWithReqId(TestHTTPClientMixin, testtools.TestCase):
|
|||||||
"""Tests for when global_request_id is set."""
|
"""Tests for when global_request_id is set."""
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.req_id = "req-%s" % uuid.uuid4()
|
self.req_id = "req-%s" % uuidutils.generate_uuid()
|
||||||
return client.HTTPClient(token=AUTH_TOKEN, endpoint_url=END_URL,
|
return client.HTTPClient(token=AUTH_TOKEN, endpoint_url=END_URL,
|
||||||
global_request_id=self.req_id)
|
global_request_id=self.req_id)
|
||||||
|
|
||||||
|
@@ -14,9 +14,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from mox3 import mox
|
from mox3 import mox
|
||||||
|
from oslo_utils import uuidutils
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from neutronclient.common import exceptions
|
from neutronclient.common import exceptions
|
||||||
@@ -38,7 +38,7 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
self.addCleanup(self.mox.UnsetStubs)
|
self.addCleanup(self.mox.UnsetStubs)
|
||||||
|
|
||||||
def test_get_id_from_id(self):
|
def test_get_id_from_id(self):
|
||||||
_id = str(uuid.uuid4())
|
_id = uuidutils.generate_uuid()
|
||||||
reses = {'networks': [{'id': _id, }, ], }
|
reses = {'networks': [{'id': _id, }, ], }
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||||
@@ -57,7 +57,7 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
self.assertEqual(_id, returned_id)
|
self.assertEqual(_id, returned_id)
|
||||||
|
|
||||||
def test_get_id_from_id_then_name_empty(self):
|
def test_get_id_from_id_then_name_empty(self):
|
||||||
_id = str(uuid.uuid4())
|
_id = uuidutils.generate_uuid()
|
||||||
reses = {'networks': [{'id': _id, }, ], }
|
reses = {'networks': [{'id': _id, }, ], }
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
resstr1 = self.client.serialize({'networks': []})
|
resstr1 = self.client.serialize({'networks': []})
|
||||||
@@ -86,7 +86,7 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_id_from_name(self):
|
def test_get_id_from_name(self):
|
||||||
name = 'myname'
|
name = 'myname'
|
||||||
_id = str(uuid.uuid4())
|
_id = uuidutils.generate_uuid()
|
||||||
reses = {'networks': [{'id': _id, }, ], }
|
reses = {'networks': [{'id': _id, }, ], }
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||||
@@ -106,8 +106,8 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_id_from_name_multiple(self):
|
def test_get_id_from_name_multiple(self):
|
||||||
name = 'myname'
|
name = 'myname'
|
||||||
reses = {'networks': [{'id': str(uuid.uuid4())},
|
reses = {'networks': [{'id': uuidutils.generate_uuid()},
|
||||||
{'id': str(uuid.uuid4())}]}
|
{'id': uuidutils.generate_uuid()}]}
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||||
path = getattr(self.client, "networks_path")
|
path = getattr(self.client, "networks_path")
|
||||||
@@ -148,8 +148,8 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_id_from_name_multiple_with_project(self):
|
def test_get_id_from_name_multiple_with_project(self):
|
||||||
name = 'web_server'
|
name = 'web_server'
|
||||||
project = str(uuid.uuid4())
|
project = uuidutils.generate_uuid()
|
||||||
expect_id = str(uuid.uuid4())
|
expect_id = uuidutils.generate_uuid()
|
||||||
reses = {'security_groups':
|
reses = {'security_groups':
|
||||||
[{'id': expect_id, 'tenant_id': project}]}
|
[{'id': expect_id, 'tenant_id': project}]}
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
@@ -172,7 +172,7 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
|
|
||||||
def test_get_id_from_name_multiple_with_project_not_found(self):
|
def test_get_id_from_name_multiple_with_project_not_found(self):
|
||||||
name = 'web_server'
|
name = 'web_server'
|
||||||
project = str(uuid.uuid4())
|
project = uuidutils.generate_uuid()
|
||||||
resstr_notfound = self.client.serialize({'security_groups': []})
|
resstr_notfound = self.client.serialize({'security_groups': []})
|
||||||
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
self.mox.StubOutWithMock(self.client.httpclient, "request")
|
||||||
path = getattr(self.client, "security_groups_path")
|
path = getattr(self.client, "security_groups_path")
|
||||||
@@ -192,7 +192,7 @@ class CLITestNameorID(testtools.TestCase):
|
|||||||
self.assertEqual(404, exc.status_code)
|
self.assertEqual(404, exc.status_code)
|
||||||
|
|
||||||
def _test_get_resource_by_id(self, id_only=False):
|
def _test_get_resource_by_id(self, id_only=False):
|
||||||
_id = str(uuid.uuid4())
|
_id = uuidutils.generate_uuid()
|
||||||
net = {'id': _id, 'name': 'test'}
|
net = {'id': _id, 'name': 'test'}
|
||||||
reses = {'networks': [net], }
|
reses = {'networks': [net], }
|
||||||
resstr = self.client.serialize(reses)
|
resstr = self.client.serialize(reses)
|
||||||
|
Reference in New Issue
Block a user