本文整理汇总了Python中tempest.lib.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_rand_mac_address
def test_rand_mac_address(self):
actual = data_utils.rand_mac_address()
self.assertIsInstance(actual, str)
self.assertRegex(actual, "^([0-9a-f][0-9a-f]:){5}" "[0-9a-f][0-9a-f]$")
actual2 = data_utils.rand_mac_address()
self.assertNotEqual(actual, actual2)
示例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': 0.123, 'key3': {'cat': 'meow'}}
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_ports_in_portgroup_with_physical_network
def test_update_ports_in_portgroup_with_physical_network(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
_, portgroup = self.create_portgroup(node_id, address=address)
_, port1 = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
address = data_utils.rand_mac_address()
_, port2 = self.create_port(node_id=node_id, address=address,
physical_network='physnet1')
patch = [{'path': '/portgroup_uuid',
'op': 'replace',
'value': portgroup['uuid']}]
self.client.update_port(port2['uuid'], patch)
_, body = self.client.show_port(port1['uuid'])
self.assertEqual('physnet1', body['physical_network'])
self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])
_, body = self.client.show_port(port2['uuid'])
self.assertEqual('physnet1', body['physical_network'])
self.assertEqual(portgroup['uuid'], body['portgroup_uuid'])
示例4: 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(lib_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'])
示例5: 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(lib_exc.BadRequest, self.client.update_port,
uuid='malformed:uuid',
patch=[{'path': '/address', 'op': 'replace',
'value': new_address}])
示例6: 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'])
示例7: 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()
_, port1 = self.create_port(node_id=node_id, address=address1)
_, port2 = self.create_port(node_id=node_id, address=address2)
port_id = port2['uuid']
patch = [{'path': '/address',
'op': 'replace',
'value': address1}]
self.assertRaises(lib_exc.Conflict,
self.client.update_port, port_id, patch)
示例8: 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(lib_exc.BadRequest, self.create_port,
node_id=node_id, address=address, uuid=uuid)
示例9: 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(lib_exc.Conflict,
self.create_port, node_id=node_id,
address=address)
示例10: test_vif_on_port
def test_vif_on_port(self):
"""Test attachment and detachment of VIFs on the node with port.
Test steps:
1) Create chassis and node in setUp.
2) Create port for the node.
3) Attach VIF to the node.
4) Check VIF info in VIFs list and port internal_info.
5) Detach VIF from the node.
6) Check that no more VIF info in VIFs list and port internal_info.
"""
self.useFixture(
api_microversion_fixture.APIMicroversionFixture('1.28'))
_, self.port = self.create_port(self.node['uuid'],
data_utils.rand_mac_address())
self.client.vif_attach(self.node['uuid'], 'test-vif')
_, body = self.client.vif_list(self.node['uuid'])
self.assertEqual({'vifs': [{'id': 'test-vif'}]}, body)
_, port = self.client.show_port(self.port['uuid'])
self.assertEqual('test-vif',
port['internal_info']['tenant_vif_port_id'])
self.client.vif_detach(self.node['uuid'], 'test-vif')
_, body = self.client.vif_list(self.node['uuid'])
self.assertEqual({'vifs': []}, body)
_, port = self.client.show_port(self.port['uuid'])
self.assertNotIn('tenant_vif_port_id', port['internal_info'])
示例11: 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'])
示例12: 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())
示例13: test_create_port_with_physical_network_old_api
def test_create_port_with_physical_network_old_api(self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
self.assertRaises((lib_exc.BadRequest, lib_exc.UnexpectedResponseCode),
self.create_port,
node_id=node_id, address=address,
physical_network='physnet1')
示例14: test_create_ports_in_portgroup_with_inconsistent_physical_network
def test_create_ports_in_portgroup_with_inconsistent_physical_network(
self):
node_id = self.node['uuid']
address = data_utils.rand_mac_address()
_, portgroup = self.create_portgroup(node_id, address=address)
_, _ = self.create_port(node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet1')
address = data_utils.rand_mac_address()
self.assertRaises(lib_exc.Conflict,
self.create_port,
node_id=node_id, address=address,
portgroup_uuid=portgroup['uuid'],
physical_network='physnet2')
示例15: _get_ips_from_subnet
def _get_ips_from_subnet(self, **kwargs):
subnet = self.create_subnet(self.network, **kwargs)
port_mac = data_utils.rand_mac_address()
port = self.create_port(self.network, mac_address=port_mac)
real_ip = next(iter(port['fixed_ips']), None)['ip_address']
eui_ip = str(netutils.get_ipv6_addr_by_EUI64(
subnet['cidr'], port_mac))
return real_ip, eui_ip