本文整理汇总了Python中tempest.common.utils.data_utils.rand_mac_address函数的典型用法代码示例。如果您正苦于以下问题:Python rand_mac_address函数的具体用法?Python rand_mac_address怎么用?Python rand_mac_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rand_mac_address函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_port_mixed_ops_integrity
def test_update_port_mixed_ops_integrity(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2'}
_, port = self.create_port(node_id=node_id, address=address,
extra=extra)
port_id = port['uuid']
new_address = data_utils.rand_mac_address()
new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}
patch = [{'path': '/address',
'op': 'replace',
'value': new_address},
{'path': '/extra/key1',
'op': 'replace',
'value': new_extra['key1']},
{'path': '/extra/key2',
'op': 'remove'},
{'path': '/extra/key3',
'op': 'add',
'value': new_extra['key3']},
{'path': '/nonexistent',
'op': 'replace',
'value': 'value'}]
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
patch)
# patch should not be applied
_, body = self.client.show_port(port_id)
self.assertEqual(address, body['address'])
self.assertEqual(extra, body['extra'])
示例2: test_update_port_mixed_ops
def test_update_port_mixed_ops(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2'}
_, port = self.create_port(node_id=node_id, address=address,
extra=extra)
new_address = data_utils.rand_mac_address()
new_extra = {'key1': 'new-value1', 'key3': 'new-value3'}
patch = [{'path': '/address',
'op': 'replace',
'value': new_address},
{'path': '/extra/key1',
'op': 'replace',
'value': new_extra['key1']},
{'path': '/extra/key2',
'op': 'remove'},
{'path': '/extra/key3',
'op': 'add',
'value': new_extra['key3']}]
self.client.update_port(port['uuid'], patch)
_, body = self.client.show_port(port['uuid'])
self.assertEqual(new_address, body['address'])
self.assertEqual(new_extra, body['extra'])
示例3: test_update_port_replace
def test_update_port_replace(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
port_id = self.create_port(node_id=node_id, address=address,
extra=extra)['port']['uuid']
new_address = data_utils.rand_mac_address()
new_extra = {'key1': 'new-value1', 'key2': 'new-value2',
'key3': 'new-value3'}
patch = [{'path': '/address',
'op': 'replace',
'value': new_address},
{'path': '/extra/key1',
'op': 'replace',
'value': new_extra['key1']},
{'path': '/extra/key2',
'op': 'replace',
'value': new_extra['key2']},
{'path': '/extra/key3',
'op': 'replace',
'value': new_extra['key3']}]
self.client.update_port(port_id, patch)
resp, body = self.client.show_port(port_id)
self.assertEqual(200, resp.status)
self.assertEqual(new_address, body['address'])
self.assertEqual(new_extra, body['extra'])
示例4: test_rand_mac_address
def test_rand_mac_address(self):
actual = data_utils.rand_mac_address()
self.assertIsInstance(actual, str)
self.assertRegexpMatches(actual, "^([0-9a-f][0-9a-f]:){5}"
"[0-9a-f][0-9a-f]$")
actual2 = data_utils.rand_mac_address()
self.assertNotEqual(actual, actual2)
示例5: test_list_ports_details_with_address
def test_list_ports_details_with_address(self):
node_id = self.node["uuid"]
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
for i in range(0, 5):
self.create_port(node_id=node_id, address=data_utils.rand_mac_address())
_, body = self.client.list_ports_detail(address=address)
self.assertEqual(1, len(body["ports"]))
self.assertEqual(address, body["ports"][0]["address"])
示例6: test_update_port_malformed_port_uuid
def test_update_port_malformed_port_uuid(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
new_address = data_utils.rand_mac_address()
self.assertRaises(exc.BadRequest, self.client.update_port,
uuid='malformed:uuid',
patch=[{'path': '/address', 'op': 'replace',
'value': new_address}])
示例7: test_list_ports_details_with_address
def test_list_ports_details_with_address(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
for i in range(0, 5):
self.create_port(node_id=node_id,
address=data_utils.rand_mac_address())
resp, body = self.client.list_ports_detail(address=address)
self.assertEqual(200, resp.status)
self.assertEqual(1, len(body['ports']))
self.assertEqual(address, body['ports'][0]['address'])
示例8: test_update_port_replace_mac_with_duplicated
def test_update_port_replace_mac_with_duplicated(self):
node_id = self.node['uuid']
address1 = data_utils.rand_mac_address()
address2 = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address1)
port_id = self.create_port(node_id=node_id,
address=address2)['port']['uuid']
patch = [{'path': '/address',
'op': 'replace',
'value': address1}]
self.assertRaises(exc.Conflict,
self.client.update_port, port_id, patch)
示例9: setUp
def setUp(self):
super(TestPorts, self).setUp()
_, self.chassis = self.create_chassis()
_, self.node = self.create_node(self.chassis['uuid'])
_, self.port = self.create_port(self.node['uuid'],
data_utils.rand_mac_address())
示例10: test_create_port_malformed_port_uuid
def test_create_port_malformed_port_uuid(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
uuid = 'malformed:uuid'
self.assertRaises(exc.BadRequest, self.create_port, node_id=node_id,
address=address, uuid=uuid)
示例11: test_create_port_duplicated_mac
def test_create_port_duplicated_mac(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
self.create_port(node_id=node_id, address=address)
self.assertRaises(exc.Conflict,
self.create_port, node_id=node_id,
address=address)
示例12: test_dhcpv6_stateless_two_subnets
def test_dhcpv6_stateless_two_subnets(self):
"""When 2 subnets configured with dnsmasq SLAAC and DHCP stateless
and there is radvd, port shall receive IP addresses calculated
from its MAC and mask of subnet from both subnets.
"""
for ra_mode, add_mode in (
('slaac', 'slaac'),
('dhcpv6-stateless', 'dhcpv6-stateless'),
):
kwargs = {'ipv6_ra_mode': ra_mode,
'ipv6_address_mode': add_mode}
subnet1 = self.create_subnet(self.network, **kwargs)
subnet2 = self.create_subnet(self.network, **kwargs)
port_mac = data_utils.rand_mac_address()
port = self.create_port(self.network, mac_address=port_mac)
real_ips = [i['ip_address'] for i in port['fixed_ips']]
eui_ips = [
data_utils.get_ipv6_addr_by_EUI64(i['cidr'],
port_mac).format()
for i in (subnet1, subnet2)
]
self._clean_network()
self.assertSequenceEqual(sorted(real_ips), sorted(eui_ips),
('Real port IPs %s,%s are not equal to'
' SLAAC IPs: %s,%s') % tuple(real_ips +
eui_ips))
示例13: test_update_port_remove
def test_update_port_remove(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
extra = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
_, port = self.create_port(node_id=node_id, address=address,
extra=extra)
# Removing one item from the collection
self.client.update_port(port['uuid'],
[{'path': '/extra/key2',
'op': 'remove'}])
extra.pop('key2')
_, body = self.client.show_port(port['uuid'])
self.assertEqual(extra, body['extra'])
# Removing the collection
self.client.update_port(port['uuid'], [{'path': '/extra',
'op': 'remove'}])
_, body = self.client.show_port(port['uuid'])
self.assertEqual({}, body['extra'])
# Assert nothing else was changed
self.assertEqual(node_id, body['node_uuid'])
self.assertEqual(address, body['address'])
示例14: test_create_port_malformed_extra
def test_create_port_malformed_extra(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
extra = {'key': 0.123}
self.assertRaises(exc.BadRequest,
self.create_port, node_id=node_id,
address=address, extra=extra)
示例15: test_update_port_remove_mandatory_field_port_uuid
def test_update_port_remove_mandatory_field_port_uuid(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
port_id = self.create_port(node_id=node_id, address=address)['port'][
'uuid']
self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
[{'path': '/uuid', 'op': 'remove'}])