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

Python utils.generate_pools函数代码示例

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

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



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

示例1: _mock_subnet

    def _mock_subnet(self, subnet_pool, requested_pools, cidr, gateway):
        ip_version = 4
        subnetpool_id = subnet_pool['id]'] if subnet_pool else None
        # if pools is passed, then allocation_pools should be a request format
        # which is IPRange type, but if not passed, then subnet format is
        # subnet dict.
        if requested_pools is None:
            requested_pools = ipam_utils.generate_pools(cidr, gateway)
            allocation_pools = [
                {'start': str(netaddr.IPAddress(p.first, ip_version)),
                 'end': str(netaddr.IPAddress(p.last, ip_version))}
                for p in requested_pools]
        else:
            allocation_pools = requested_pools

        return {
            'id': 'subnet-id',
            'cidr': cidr,
            'tenant_id': 'tenant-id',
            'gateway_ip': gateway,
            'name': 'subnet-name',
            'network_id': 'network-id',
            'subnetpool_id': subnetpool_id,
            'allocation_pools': allocation_pools,
            'ip_version': ip_version,
            'enable_dhcp': True}
开发者ID:openstack,项目名称:networking-infoblox,代码行数:26,代码来源:test_driver.py


示例2: create_from_subnet_request

    def create_from_subnet_request(cls, subnet_request, ctx):
        ipam_subnet_id = uuidutils.generate_uuid()
        subnet_manager = ipam_db_api.IpamSubnetManager(
            ipam_subnet_id,
            None)
        # Create subnet resource
        session = ctx.session
        subnet_manager.create(session)
        # If allocation pools are not specified, define them around
        # the subnet's gateway IP
        if not subnet_request.allocation_pools:
            pools = ipam_utils.generate_pools(subnet_request.subnet_cidr,
                                              subnet_request.gateway_ip)
        else:
            pools = subnet_request.allocation_pools
        # Create IPAM allocation pools and availability ranges
        cls.create_allocation_pools(subnet_manager, session, pools)

        return cls(ipam_subnet_id,
                   ctx,
                   cidr=subnet_request.subnet_cidr,
                   allocation_pools=pools,
                   gateway_ip=subnet_request.gateway_ip,
                   tenant_id=subnet_request.tenant_id,
                   subnet_id=subnet_request.subnet_id,
                   subnet_id_not_set=True)
开发者ID:EnterSrl,项目名称:neutron,代码行数:26,代码来源:driver.py


示例3: _create_ib_ip_range

 def _create_ib_ip_range(self, rollback_list):
     subnet = self.ib_cxt.subnet
     cidr = subnet.get('cidr')
     ip_version = subnet.get('ip_version')
     gateway_ip = subnet.get('gateway_ip')
     allocation_pools = subnet.get('allocation_pools')
     if not allocation_pools:
         allocation_pools = ipam_utils.generate_pools(cidr, gateway_ip)
     self._allocate_pools(rollback_list, allocation_pools, cidr,
                          ip_version, True)
开发者ID:yuewko,项目名称:networking-infoblox,代码行数:10,代码来源:ipam.py


示例4: _prepare_allocation_pools

    def _prepare_allocation_pools(self, allocation_pools, cidr, gateway_ip):
        """Returns allocation pools represented as list of IPRanges"""
        if not attributes.is_attr_set(allocation_pools):
            return ipam_utils.generate_pools(cidr, gateway_ip)

        ip_range_pools = self.pools_to_ip_range(allocation_pools)
        self._validate_allocation_pools(ip_range_pools, cidr)
        if gateway_ip:
            self.validate_gw_out_of_pools(gateway_ip, ip_range_pools)
        return ip_range_pools
开发者ID:paninetworks,项目名称:neutron,代码行数:10,代码来源:ipam_backend_mixin.py


示例5: _prepare_allocation_pools

    def _prepare_allocation_pools(self, allocation_pools, cidr, gateway_ip):
        """Returns allocation pools represented as list of IPRanges"""
        if not attributes.is_attr_set(allocation_pools):
            return ipam_utils.generate_pools(cidr, gateway_ip)

        self._validate_allocation_pools(allocation_pools, cidr)
        if gateway_ip:
            self.validate_gw_out_of_pools(gateway_ip, allocation_pools)
        return [netaddr.IPRange(p['start'], p['end'])
                for p in allocation_pools]
开发者ID:Raghunanda,项目名称:neutron,代码行数:10,代码来源:ipam_backend_mixin.py


示例6: _allocate_pools_for_subnet

    def _allocate_pools_for_subnet(self, context, subnet):
        """Create IP allocation pools for a given subnet

        Pools are defined by the 'allocation_pools' attribute,
        a list of dict objects with 'start' and 'end' keys for
        defining the pool range.
        """
        pools = ipam_utils.generate_pools(subnet['cidr'], subnet['gateway_ip'])
        return [{'start': str(netaddr.IPAddress(pool.first)),
                 'end': str(netaddr.IPAddress(pool.last))}
                for pool in pools]
开发者ID:kkxue,项目名称:neutron,代码行数:11,代码来源:ipam_backend_mixin.py


示例7: _allocate_any_subnet

    def _allocate_any_subnet(self, request):
        with self._context.session.begin(subtransactions=True):
            self._lock_subnetpool()
            self._check_subnetpool_tenant_quota(request.tenant_id, request.prefixlen)
            prefix_pool = self._get_available_prefix_list()
            for prefix in prefix_pool:
                if request.prefixlen >= prefix.prefixlen:
                    subnet = next(prefix.subnet(request.prefixlen))
                    gateway_ip = request.gateway_ip
                    if not gateway_ip:
                        gateway_ip = subnet.network + 1
                    pools = ipam_utils.generate_pools(subnet.cidr, gateway_ip)

                    return IpamSubnet(
                        request.tenant_id, request.subnet_id, subnet.cidr, gateway_ip=gateway_ip, allocation_pools=pools
                    )
            msg = _("Insufficient prefix space to allocate subnet size /%s")
            raise n_exc.SubnetAllocationError(reason=msg % str(request.prefixlen))
开发者ID:cisco-openstack,项目名称:neutron,代码行数:18,代码来源:subnet_alloc.py


示例8: generate_pools

 def generate_pools(self, cidr, gateway_ip):
     return ipam_utils.generate_pools(cidr, gateway_ip)
开发者ID:annp,项目名称:neutron,代码行数:2,代码来源:ipam_backend_mixin.py


示例9: test_generate_pools_v6_empty

 def test_generate_pools_v6_empty(self):
     # We want to be sure the range will begin and end with an IPv6
     # address, even if an ambiguous ::/64 cidr is given.
     cidr = '::/64'
     expected = [netaddr.IPRange('::1', '::FFFF:FFFF:FFFF:FFFF')]
     self.assertEqual(expected, utils.generate_pools(cidr, None))
开发者ID:21atlas,项目名称:neutron,代码行数:6,代码来源:test_utils.py


示例10: test_generate_pools_v6_nogateway

 def test_generate_pools_v6_nogateway(self):
     # other than the difference in the last address, the rest of the
     # logic is the same as v4 so we only need one test
     cidr = 'F111::0/64'
     expected = [netaddr.IPRange('F111::1', 'F111::FFFF:FFFF:FFFF:FFFF')]
     self.assertEqual(expected, utils.generate_pools(cidr, None))
开发者ID:21atlas,项目名称:neutron,代码行数:6,代码来源:test_utils.py


示例11: test_generate_pools_v4_gateway_middle

 def test_generate_pools_v4_gateway_middle(self):
     cidr = '192.168.0.0/24'
     gateway = '192.168.0.128'
     expected = [netaddr.IPRange('192.168.0.1', '192.168.0.127'),
                 netaddr.IPRange('192.168.0.129', '192.168.0.254')]
     self.assertEqual(expected, utils.generate_pools(cidr, gateway))
开发者ID:21atlas,项目名称:neutron,代码行数:6,代码来源:test_utils.py


示例12: test_generate_pools_v4_31

 def test_generate_pools_v4_31(self):
     cidr = '192.168.0.0/31'
     expected = []
     self.assertEqual(expected, utils.generate_pools(cidr, None))
开发者ID:21atlas,项目名称:neutron,代码行数:4,代码来源:test_utils.py


示例13: test_generate_pools_v4_32

 def test_generate_pools_v4_32(self):
     # 32 is special because it should have 1 usable address
     cidr = '192.168.0.0/32'
     expected = [netaddr.IPRange('192.168.0.0', '192.168.0.0')]
     self.assertEqual(expected, utils.generate_pools(cidr, None))
开发者ID:21atlas,项目名称:neutron,代码行数:5,代码来源:test_utils.py


示例14: test_generate_pools_v4_nogateway

 def test_generate_pools_v4_nogateway(self):
     cidr = '192.168.0.0/24'
     expected = [netaddr.IPRange('192.168.0.1', '192.168.0.254')]
     self.assertEqual(expected, utils.generate_pools(cidr, None))
开发者ID:21atlas,项目名称:neutron,代码行数:4,代码来源:test_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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