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