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

Python ipv6_utils.get_ipv6_addr_by_EUI64函数代码示例

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

本文整理汇总了Python中neutron.common.ipv6_utils.get_ipv6_addr_by_EUI64函数的典型用法代码示例。如果您正苦于以下问题:Python get_ipv6_addr_by_EUI64函数的具体用法?Python get_ipv6_addr_by_EUI64怎么用?Python get_ipv6_addr_by_EUI64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_ipv6_addr_by_EUI64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test__allocate_ips_for_port_2_slaac_pd_subnets

    def test__allocate_ips_for_port_2_slaac_pd_subnets(self):
        subnets = [
            {
                'cidr': constants.PROVISIONAL_IPV6_PD_PREFIX,
                'enable_dhcp': True,
                'gateway_ip': '::1',
                'id': 'd1a28edd-bd83-480a-bd40-93d036c89f13',
                'network_id': 'fbb9b578-95eb-4b79-a116-78e5c4927176',
                'ip_version': 6,
                'ipv6_address_mode': None,
                'ipv6_ra_mode': 'slaac'},
            {
                'cidr': constants.PROVISIONAL_IPV6_PD_PREFIX,
                'enable_dhcp': True,
                'gateway_ip': '::1',
                'id': 'dc813d3d-ed66-4184-8570-7325c8195e28',
                'network_id': 'fbb9b578-95eb-4b79-a116-78e5c4927176',
                'ip_version': 6,
                'ipv6_address_mode': None,
                'ipv6_ra_mode': 'slaac'}]
        port = {'port': {
            'network_id': 'fbb9b578-95eb-4b79-a116-78e5c4927176',
            'fixed_ips': n_const.ATTR_NOT_SPECIFIED,
            'mac_address': '12:34:56:78:44:ab',
            'device_owner': 'compute'}}
        expected = []
        for subnet in subnets:
            addr = str(ipv6_utils.get_ipv6_addr_by_EUI64(
                            subnet['cidr'], port['port']['mac_address']))
            expected.append({'ip_address': addr, 'subnet_id': subnet['id']})

        self._test__allocate_ips_for_port(subnets, port, expected)
开发者ID:Lily913,项目名称:neutron,代码行数:32,代码来源:test_ipam_non_pluggable_backend.py


示例2: _select_dhcp_ips_for_network_ids

    def _select_dhcp_ips_for_network_ids(self, context, network_ids):
        if not network_ids:
            return {}
        query = context.session.query(models_v2.Port.mac_address,
                                      models_v2.Port.network_id,
                                      models_v2.IPAllocation.ip_address)
        query = query.join(models_v2.IPAllocation)
        query = query.filter(models_v2.Port.network_id.in_(network_ids))
        owner = q_const.DEVICE_OWNER_DHCP
        query = query.filter(models_v2.Port.device_owner == owner)
        ips = {}

        for network_id in network_ids:
            ips[network_id] = []

        for mac_address, network_id, ip in query:
            if (netaddr.IPAddress(ip).version == 6
                    and not netaddr.IPAddress(ip).is_link_local()):
                ip = str(
                    ipv6.get_ipv6_addr_by_EUI64(q_const.IPV6_LLA_PREFIX,
                                                mac_address))
            if ip not in ips[network_id]:
                ips[network_id].append(ip)

        return ips
开发者ID:jocado,项目名称:neutron,代码行数:25,代码来源:securitygroups_rpc_base.py


示例3: get_random_ip_address

def get_random_ip_address(version=4):
    if version == 4:
        ip_string = "10.%d.%d.%d" % (random.randint(3, 254), random.randint(3, 254), random.randint(3, 254))
        return netaddr.IPAddress(ip_string)
    else:
        ip = ipv6_utils.get_ipv6_addr_by_EUI64("2001:db8::/64", get_random_mac())
        return ip
开发者ID:electrocucaracha,项目名称:neutron,代码行数:7,代码来源:tools.py


示例4: _calculate_ipv6_eui64_addr

 def _calculate_ipv6_eui64_addr(self, context, subnet, mac_addr):
     prefix = subnet["cidr"]
     network_id = subnet["network_id"]
     ip_address = ipv6_utils.get_ipv6_addr_by_EUI64(prefix, mac_addr).format()
     if not self._check_unique_ip(context, network_id, subnet["id"], ip_address):
         raise n_exc.IpAddressInUse(net_id=network_id, ip_address=ip_address)
     return ip_address
开发者ID:walterleonardo,项目名称:neutron,代码行数:7,代码来源:ipam_non_pluggable_backend.py


示例5: _build_ipv4v6_mac_ip_list

 def _build_ipv4v6_mac_ip_list(self, mac, ip_address, mac_ipv4_pairs, mac_ipv6_pairs):
     mac = str(netaddr.EUI(mac, dialect=mac_iptables))
     if netaddr.IPNetwork(ip_address).version == 4:
         mac_ipv4_pairs.append((mac, ip_address))
     else:
         mac_ipv6_pairs.append((mac, ip_address))
         lla = str(ipv6_utils.get_ipv6_addr_by_EUI64(constants.IPv6_LLA_PREFIX, mac))
         mac_ipv6_pairs.append((mac, lla))
开发者ID:electrocucaracha,项目名称:neutron,代码行数:8,代码来源:iptables_firewall.py


示例6: _generate_eui64_address

 def _generate_eui64_address(self, **kwargs):
     if set(kwargs) != set(["prefix", "mac"]):
         raise ipam_exc.AddressCalculationFailure(
             address_type="eui-64", reason=_("must provide exactly 2 arguments - cidr and MAC")
         )
     prefix = kwargs["prefix"]
     mac_address = kwargs["mac"]
     return ipv6_utils.get_ipv6_addr_by_EUI64(prefix, mac_address)
开发者ID:walterleonardo,项目名称:neutron,代码行数:8,代码来源:requests.py


示例7: _generate_eui64_address

 def _generate_eui64_address(self, **kwargs):
     if set(kwargs) != set(['prefix', 'mac']):
         raise ipam_exc.AddressCalculationFailure(
             address_type='eui-64',
             reason=_('must provide exactly 2 arguments - cidr and MAC'))
     prefix = kwargs['prefix']
     mac_address = kwargs['mac']
     return ipv6_utils.get_ipv6_addr_by_EUI64(prefix, mac_address)
开发者ID:dlundquist,项目名称:neutron,代码行数:8,代码来源:requests.py


示例8: test_automatic_address_request_eui64

 def test_automatic_address_request_eui64(self):
     subnet_cidr = '2607:f0d0:1002:51::/64'
     port_mac = 'aa:bb:cc:dd:ee:ff'
     eui_addr = str(ipv6_utils.get_ipv6_addr_by_EUI64(subnet_cidr,
                                                      port_mac))
     request = ipam_req.AutomaticAddressRequest(
         address_type=self.EUI64,
         prefix=subnet_cidr,
         mac=port_mac)
     self.assertEqual(request.address, netaddr.IPAddress(eui_addr))
开发者ID:annp,项目名称:neutron,代码行数:10,代码来源:test_requests.py


示例9: __init__

 def __init__(self, port_dict, ovs_port, vlan_tag):
     self.id = port_dict["device"]
     self.vlan_tag = vlan_tag
     self.mac = ovs_port.vif_mac
     self.lla_address = str(ipv6_utils.get_ipv6_addr_by_EUI64(constants.IPV6_LLA_PREFIX, self.mac))
     self.ofport = ovs_port.ofport
     self.sec_groups = list()
     self.fixed_ips = port_dict.get("fixed_ips", [])
     self.neutron_port_dict = port_dict.copy()
     self.allowed_pairs_v4 = self._get_allowed_pairs(port_dict, version=4)
     self.allowed_pairs_v6 = self._get_allowed_pairs(port_dict, version=6)
开发者ID:klmitch,项目名称:neutron,代码行数:11,代码来源:firewall.py


示例10: _get_lla_gateway_ip_for_subnet

 def _get_lla_gateway_ip_for_subnet(self, context, subnet):
     query = context.session.query(models_v2.Port.mac_address)
     query = query.join(models_v2.IPAllocation)
     query = query.filter(models_v2.IPAllocation.subnet_id == subnet["id"])
     query = query.filter(models_v2.IPAllocation.ip_address == subnet["gateway_ip"])
     query = query.filter(models_v2.Port.device_owner.in_(n_const.ROUTER_INTERFACE_OWNERS))
     try:
         mac_address = query.one()[0]
     except (exc.NoResultFound, exc.MultipleResultsFound):
         LOG.warning(_LW("No valid gateway port on subnet %s is " "found for IPv6 RA"), subnet["id"])
         return
     lla_ip = str(ipv6.get_ipv6_addr_by_EUI64(n_const.IPV6_LLA_PREFIX, mac_address))
     return lla_ip
开发者ID:FedericoRessi,项目名称:neutron,代码行数:13,代码来源:securitygroups_rpc_base.py


示例11: _get_lla_gateway_ip_for_subnet

 def _get_lla_gateway_ip_for_subnet(self, context, subnet):
     query = context.session.query(models_v2.Port)
     query = query.join(models_v2.IPAllocation)
     query = query.filter(models_v2.IPAllocation.subnet_id == subnet["id"])
     query = query.filter(models_v2.IPAllocation.ip_address == subnet["gateway_ip"])
     query = query.filter(models_v2.Port.device_owner == q_const.DEVICE_OWNER_ROUTER_INTF)
     try:
         gateway_port = query.one()
     except (exc.NoResultFound, exc.MultipleResultsFound):
         LOG.warn(_("No valid gateway port on subnet %s is " "found for IPv6 RA"), subnet["id"])
         return
     mac_address = gateway_port["mac_address"]
     lla_ip = str(ipv6.get_ipv6_addr_by_EUI64(q_const.IPV6_LLA_PREFIX, mac_address))
     return lla_ip
开发者ID:nishant80,项目名称:neutron,代码行数:14,代码来源:securitygroups_rpc_base.py


示例12: test_allocate_eui64_ip

    def test_allocate_eui64_ip(self):
        mocks = self._prepare_ipam()
        ip = {'subnet_id': self._gen_subnet_id(),
              'subnet_cidr': '2001:470:abcd::/64',
              'mac': '6c:62:6d:de:cf:49',
              'eui64_address': True}
        eui64_ip = ipv6_utils.get_ipv6_addr_by_EUI64(ip['subnet_cidr'],
                                                     ip['mac'])
        mocks['ipam']._ipam_allocate_ips(mock.ANY, mocks['driver'],
                                         mock.ANY, [ip])

        request = mocks['subnets'].allocate.call_args[0][0]
        self.assertIsInstance(request, ipam_req.AutomaticAddressRequest)
        self.assertEqual(eui64_ip, request.address)
开发者ID:zdohnal,项目名称:neutron,代码行数:14,代码来源:test_ipam_pluggable_backend.py


示例13: test_allocate_eui64_ip

    def test_allocate_eui64_ip(self):
        mocks = self._prepare_ipam()
        ip = {
            "subnet_id": self._gen_subnet_id(),
            "subnet_cidr": "2001:470:abcd::/64",
            "mac": "6c:62:6d:de:cf:49",
            "eui64_address": True,
        }
        eui64_ip = ipv6_utils.get_ipv6_addr_by_EUI64(ip["subnet_cidr"], ip["mac"])
        mocks["ipam"]._ipam_allocate_ips(mock.ANY, mocks["driver"], mock.ANY, [ip])

        request = mocks["subnet"].allocate.call_args[0][0]
        self.assertIsInstance(request, ipam_req.AutomaticAddressRequest)
        self.assertEqual(eui64_ip, request.address)
开发者ID:FedericoRessi,项目名称:neutron,代码行数:14,代码来源:test_ipam_pluggable_backend.py


示例14: _get_lla_gateway_ip_for_subnet

 def _get_lla_gateway_ip_for_subnet(self, context, subnet):
     query = context.session.query(models_v2.Port.mac_address)
     query = query.join(models_v2.IPAllocation)
     query = query.filter(
         models_v2.IPAllocation.subnet_id == subnet['id'])
     query = query.filter(
         models_v2.IPAllocation.ip_address == subnet['gateway_ip'])
     query = query.filter(or_(models_v2.Port.device_owner ==
                          q_const.DEVICE_OWNER_ROUTER_INTF,
                              models_v2.Port.device_owner ==
                          q_const.DEVICE_OWNER_DVR_INTERFACE))
     try:
         mac_address = query.one()[0]
     except (exc.NoResultFound, exc.MultipleResultsFound):
         LOG.warn(_LW('No valid gateway port on subnet %s is '
                      'found for IPv6 RA'), subnet['id'])
         return
     lla_ip = str(ipv6.get_ipv6_addr_by_EUI64(
         q_const.IPV6_LLA_PREFIX,
         mac_address))
     return lla_ip
开发者ID:CiscoSystems,项目名称:neutron,代码行数:21,代码来源:securitygroups_rpc_base.py


示例15: test_generate_IPv6_with_bad_mac

 def test_generate_IPv6_with_bad_mac(self):
     bad_mac = '00:16:3e:33:44:5Z'
     prefix = '2001:db8::'
     self.assertRaises(TypeError, lambda:
                       ipv6_utils.get_ipv6_addr_by_EUI64(prefix, bad_mac))
开发者ID:cisco-openstack,项目名称:neutron,代码行数:5,代码来源:test_ipv6_utils.py


示例16: _get_lla

 def _get_lla(mac):
     lla = ipv6_utils.get_ipv6_addr_by_EUI64(l3_constants.IPV6_LLA_PREFIX,
                                             mac)
     return lla
开发者ID:javaos74,项目名称:neutron,代码行数:4,代码来源:pd.py


示例17: _get_lla

 def _get_lla(mac):
     lla = ipv6_utils.get_ipv6_addr_by_EUI64(n_const.IPv6_LLA_PREFIX,
                                             mac)
     return lla
开发者ID:ISCAS-VDI,项目名称:neutron-base,代码行数:4,代码来源:pd.py


示例18: test_generate_IPv6_with_error_prefix_type

 def test_generate_IPv6_with_error_prefix_type(self):
     mac = '00:16:3e:33:44:55'
     prefix = 123
     self.assertRaises(TypeError, lambda:
                       ipv6_utils.get_ipv6_addr_by_EUI64(prefix, mac))
开发者ID:cisco-openstack,项目名称:neutron,代码行数:5,代码来源:test_ipv6_utils.py


示例19: test_generate_IPv6_with_bad_prefix

 def test_generate_IPv6_with_bad_prefix(self):
     mac = '00:16:3e:33:44:55'
     bad_prefix = 'bb'
     self.assertRaises(TypeError, lambda:
                       ipv6_utils.get_ipv6_addr_by_EUI64(bad_prefix, mac))
开发者ID:cisco-openstack,项目名称:neutron,代码行数:5,代码来源:test_ipv6_utils.py


示例20: test_generate_IPv6_with_IPv4_prefix

 def test_generate_IPv6_with_IPv4_prefix(self):
     ipv4_prefix = '10.0.8'
     mac = '00:16:3e:33:44:55'
     self.assertRaises(TypeError, lambda:
                       ipv6_utils.get_ipv6_addr_by_EUI64(ipv4_prefix, mac))
开发者ID:cisco-openstack,项目名称:neutron,代码行数:5,代码来源:test_ipv6_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python ipv6_utils.is_auto_address_subnet函数代码示例发布时间:2022-05-27
下一篇:
Python config.setup_logging函数代码示例发布时间: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