• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python data_utils.rand_mac_address函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: 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'])
开发者ID:NeetaP,项目名称:tempest,代码行数:28,代码来源:test_ports.py


示例2: 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'])
开发者ID:Dynavisor,项目名称:tempest,代码行数:34,代码来源:test_ports_negative.py


示例3: 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)
开发者ID:overcastcloud,项目名称:tempest-lib,代码行数:8,代码来源:test_data_utils.py


示例4: 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"])
开发者ID:ionutbalutoiu,项目名称:ironic,代码行数:10,代码来源:test_ports.py


示例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}])
开发者ID:Dynavisor,项目名称:tempest,代码行数:11,代码来源:test_ports_negative.py


示例6: 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)
开发者ID:Dynavisor,项目名称:tempest,代码行数:15,代码来源:test_ports_negative.py


示例7: 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())
开发者ID:NeetaP,项目名称:tempest,代码行数:7,代码来源:test_ports.py


示例8: 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)
开发者ID:Dynavisor,项目名称:tempest,代码行数:7,代码来源:test_ports_negative.py


示例9: 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'])
开发者ID:NeetaP,项目名称:tempest,代码行数:25,代码来源:test_ports.py


示例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(lib_exc.BadRequest, self.create_port,
                          node_id=node_id, address=address, uuid=uuid)
开发者ID:Dynavisor,项目名称:tempest,代码行数:7,代码来源:test_ports_negative.py


示例11: test_delete_port

    def test_delete_port(self):
        node_id = self.node["uuid"]
        address = data_utils.rand_mac_address()
        _, port = self.create_port(node_id=node_id, address=address)

        self.delete_port(port["uuid"])

        self.assertRaises(lib_exc.NotFound, self.client.show_port, port["uuid"])
开发者ID:ionutbalutoiu,项目名称:ironic,代码行数:8,代码来源:test_ports.py


示例12: _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 = data_utils.get_ipv6_addr_by_EUI64(subnet['cidr'],
                                                port_mac).format()
     return real_ip, eui_ip
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:8,代码来源:test_dhcp_ipv6.py


示例13: test_create_port

    def test_create_port(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)

        _, body = self.client.show_port(port['uuid'])

        self._assertExpected(port, body)
开发者ID:NeetaP,项目名称:tempest,代码行数:9,代码来源:test_ports.py


示例14: test_create_port_with_extra

    def test_create_port_with_extra(self):
        node_id = self.node["uuid"]
        address = data_utils.rand_mac_address()
        extra = {"str": "value", "int": 123, "float": 0.123, "bool": True, "list": [1, 2, 3], "dict": {"foo": "bar"}}

        _, port = self.create_port(node_id=node_id, address=address, extra=extra)

        _, body = self.client.show_port(port["uuid"])
        self._assertExpected(port, body)
开发者ID:ionutbalutoiu,项目名称:ironic,代码行数:9,代码来源:test_ports.py


示例15: test_create_port_specifying_uuid

    def test_create_port_specifying_uuid(self):
        node_id = self.node["uuid"]
        address = data_utils.rand_mac_address()
        uuid = data_utils.rand_uuid()

        _, port = self.create_port(node_id=node_id, address=address, uuid=uuid)

        _, body = self.client.show_port(uuid)
        self._assertExpected(port, body)
开发者ID:ionutbalutoiu,项目名称:ironic,代码行数:9,代码来源:test_ports.py


示例16: test_update_port_remove_nonexistent_property

    def test_update_port_remove_nonexistent_property(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        self.assertRaises(lib_exc.BadRequest, self.client.update_port, port_id,
                          [{'path': '/nonexistent', 'op': 'remove'}])
开发者ID:Dynavisor,项目名称:tempest,代码行数:9,代码来源:test_ports_negative.py


示例17: test_create_port_with_extra

    def test_create_port_with_extra(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()
        extra = {'str': 'value', 'int': 123, 'float': 0.123,
                 'bool': True, 'list': [1, 2, 3], 'dict': {'foo': 'bar'}}

        _, port = self.create_port(node_id=node_id, address=address,
                                   extra=extra)

        _, body = self.client.show_port(port['uuid'])
        self._assertExpected(port, body)
开发者ID:NeetaP,项目名称:tempest,代码行数:11,代码来源:test_ports.py


示例18: test_update_port_replace_node_id_with_nonexistent

    def test_update_port_replace_node_id_with_nonexistent(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        patch = [{'path': '/node_uuid',
                  'op': 'replace',
                  'value': data_utils.rand_uuid()}]
        self.assertRaises(lib_exc.BadRequest,
                          self.client.update_port, port_id, patch)
开发者ID:Dynavisor,项目名称:tempest,代码行数:12,代码来源:test_ports_negative.py


示例19: test_dhcpv6_two_subnets

 def test_dhcpv6_two_subnets(self):
     """When one IPv6 subnet configured with IPv6 SLAAC or DHCPv6 stateless
     and other IPv6 is with DHCPv6 stateful, port shall receive EUI-64 IP
     addresses from first subnet and DHCPv6 address from second one.
     Order of subnet creating should be unimportant.
     """
     for order in ("slaac_first", "dhcp_first"):
         for ra_mode, add_mode in (
                 ('slaac', 'slaac'),
                 ('dhcpv6-stateless', 'dhcpv6-stateless'),
         ):
             kwargs = {'ipv6_ra_mode': ra_mode,
                       'ipv6_address_mode': add_mode}
             kwargs_dhcp = {'ipv6_address_mode': 'dhcpv6-stateful'}
             if order == "slaac_first":
                 subnet_slaac = self.create_subnet(self.network, **kwargs)
                 subnet_dhcp = self.create_subnet(
                     self.network, **kwargs_dhcp)
             else:
                 subnet_dhcp = self.create_subnet(
                     self.network, **kwargs_dhcp)
                 subnet_slaac = self.create_subnet(self.network, **kwargs)
             port_mac = data_utils.rand_mac_address()
             dhcp_ip = subnet_dhcp["allocation_pools"][0]["start"]
             eui_ip = data_utils.get_ipv6_addr_by_EUI64(
                 subnet_slaac['cidr'],
                 port_mac
             ).format()
             # TODO(sergsh): remove this when 1219795 is fixed
             dhcp_ip = [dhcp_ip, (netaddr.IPAddress(dhcp_ip) + 1).format()]
             port = self.create_port(self.network, mac_address=port_mac)
             real_ips = dict([(k['subnet_id'], k['ip_address'])
                              for k in port['fixed_ips']])
             real_dhcp_ip, real_eui_ip = [real_ips[sub['id']]
                                          for sub in subnet_dhcp,
                                          subnet_slaac]
             self.client.delete_port(port['id'])
             self.ports.pop()
             body = self.client.list_ports()
             ports_id_list = [i['id'] for i in body['ports']]
             self.assertNotIn(port['id'], ports_id_list)
             self._clean_network()
             self.assertEqual(real_eui_ip,
                              eui_ip,
                              'Real IP is {0}, but shall be {1}'.format(
                                  real_eui_ip,
                                  eui_ip))
             self.assertIn(
                 real_dhcp_ip, dhcp_ip,
                 'Real IP is {0}, but shall be one from {1}'.format(
                     real_dhcp_ip,
                     str(dhcp_ip)))
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:52,代码来源:test_dhcp_ipv6.py


示例20: test_update_port_replace_mac_with_malformed

    def test_update_port_replace_mac_with_malformed(self):
        node_id = self.node['uuid']
        address = data_utils.rand_mac_address()

        _, port = self.create_port(node_id=node_id, address=address)
        port_id = port['uuid']

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': 'malformed:mac'}]

        self.assertRaises(lib_exc.BadRequest,
                          self.client.update_port, port_id, patch)
开发者ID:Dynavisor,项目名称:tempest,代码行数:13,代码来源:test_ports_negative.py



注:本文中的tempest_lib.common.utils.data_utils.rand_mac_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python data_utils.rand_name函数代码示例发布时间:2022-05-27
下一篇:
Python data_utils.rand_int_id函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap