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

Python data_utils.rand_mac_address函数代码示例

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

本文整理汇总了Python中tempest.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_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'])
开发者ID:CiscoSystems,项目名称:tempest,代码行数:34,代码来源:test_ports_negative.py


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


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


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


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


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


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


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


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


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


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


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


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


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


示例16: _create_subnets_and_port

 def _create_subnets_and_port(self, kwargs1=None, kwargs2=None):
     kwargs1 = kwargs1 or {}
     kwargs2 = kwargs2 or {}
     subnet1 = self.create_subnet(self.network, **kwargs1)
     subnet2 = self.create_subnet(self.network, **kwargs2)
     port_mac = data_utils.rand_mac_address()
     port = self.create_port(self.network, mac_address=port_mac)
     return port, subnet1, subnet2
开发者ID:CiscoSystems,项目名称:tempest,代码行数:8,代码来源:test_ipv6_specific.py


示例17: _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:CiscoSystems,项目名称:tempest,代码行数:8,代码来源:test_dhcp_ipv6.py


示例18: 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(exc.NotFound, self.client.show_port, port['uuid'])
开发者ID:armando-migliaccio,项目名称:tempest-1,代码行数:8,代码来源:test_ports.py


示例19: 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()

        resp, port1 = self.create_port(node_id=node_id, address=address1)
        self.assertEqual('201', resp['status'])

        resp, port2 = self.create_port(node_id=node_id, address=address2)
        self.assertEqual('201', resp['status'])
        port_id = port2['uuid']

        patch = [{'path': '/address',
                  'op': 'replace',
                  'value': address1}]
        self.assertRaises(exc.Conflict,
                          self.client.update_port, port_id, patch)
开发者ID:abel-navarro,项目名称:tempest,代码行数:17,代码来源:test_ports_negative.py


示例20: 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_id = self.create_port(node_id=node_id, address=address)['port'][
            'uuid']
        self.assertRaises(exc.BadRequest, self.client.update_port, port_id,
                          [{'path': '/nonexistent', 'op': 'remove'}])
开发者ID:AminaMseddi,项目名称:tempest,代码行数:8,代码来源:test_ports_negative.py



注:本文中的tempest.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