当前位置: 首页>>代码示例>>Python>>正文


Python Pool.ipv4_default_prefix_length方法代码示例

本文整理汇总了Python中pynipap.Pool.ipv4_default_prefix_length方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.ipv4_default_prefix_length方法的具体用法?Python Pool.ipv4_default_prefix_length怎么用?Python Pool.ipv4_default_prefix_length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynipap.Pool的用法示例。


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

示例1: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
    def add_pool(self):
        """ Add a pool.
        """

        # extract attributes
        p = Pool()
        if 'name' in request.json:
            p.name = validate_string(request.json, 'name')
        if 'description' in request.json:
            p.description = validate_string(request.json, 'description')
        if 'default_type' in request.json:
            p.default_type = validate_string(request.json, 'default_type')
        # TODO: handle integers
        if 'ipv4_default_prefix_length' in request.json:
            p.ipv4_default_prefix_length = request.json['ipv4_default_prefix_length']
        if 'ipv6_default_prefix_length' in request.json:
            p.ipv6_default_prefix_length = request.json['ipv6_default_prefix_length']
        if 'tags' in request.json:
            p.tags = request.json['tags']
        if 'avps' in request.json:
            p.avps = request.json['avps']

        try:
           p.save()
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:fredsod,项目名称:NIPAP,代码行数:28,代码来源:xhr.py

示例2: test_load_data

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
    def test_load_data(self):
        """
        """
        th = TestHelper()
        p1 = th.add_prefix('192.168.0.0/16', 'reservation', 'test')
        p2 = th.add_prefix('192.168.0.0/20', 'reservation', 'test')
        p3 = th.add_prefix('192.168.0.0/24', 'reservation', 'test')
        p4 = th.add_prefix('192.168.1.0/24', 'reservation', 'test')
        p5 = th.add_prefix('192.168.2.0/24', 'reservation', 'test')
        p6 = th.add_prefix('192.168.32.0/20', 'reservation', 'test')
        p7 = th.add_prefix('192.168.32.0/24', 'reservation', 'test')
        p8 = th.add_prefix('192.168.32.1/32', 'reservation', 'test')

        ps1 = th.add_prefix('2001:db8:1::/48', 'reservation', 'test')
        ps2 = th.add_prefix('2001:db8:1::/64', 'reservation', 'test')
        ps3 = th.add_prefix('2001:db8:2::/48', 'reservation', 'test')

        pool1 = Pool()
        pool1.name = 'upgrade-test'
        pool1.ipv4_default_prefix_length = 31
        pool1.ipv6_default_prefix_length = 112
        pool1.save()
        p2.pool = pool1
        p2.save()
        ps1.pool = pool1
        ps1.save()

        pool2 = Pool()
        pool2.name = 'upgrade-test2'
        pool2.save()

        vrf1 = VRF()
        vrf1.name = 'foo'
        vrf1.rt = '123:123'
        vrf1.save()
开发者ID:slillibri,项目名称:NIPAP,代码行数:37,代码来源:upgrade-before.py

示例3: add

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
    def add(self):
        """ Add a pool.
        """

        if 'schema' not in request.params:
            redirect(url(controller = 'schema', action = 'list'))
        c.schema = Schema.get(int(request.params['schema']))

        # Adding to NIPAP
        if request.method == 'POST':
            p = Pool()
            p.schema = c.schema
            p.name = request.params.get('name')
            p.description = request.params.get('description')
            p.default_type = request.params.get('default_type')

            if request.params['ipv4_default_prefix_length'].strip() != '':
                p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']

            if request.params['ipv6_default_prefix_length'].strip() != '':
                p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']

            p.save()
            redirect(url(controller = 'pool', action = 'list', schema = c.schema.id))

        return render("/pool_add.html")
开发者ID:tobbakko,项目名称:NIPAP,代码行数:28,代码来源:pool.py

示例4: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
 def add_pool(self, name, default_type, ipv4_default_prefix_length, ipv6_default_prefix_length):
     pool = Pool()
     pool.name = name
     pool.default_type = default_type
     pool.ipv4_default_prefix_length = ipv4_default_prefix_length
     pool.ipv6_default_prefix_length = ipv6_default_prefix_length
     pool.save()
     return pool
开发者ID:Cougar,项目名称:NIPAP,代码行数:10,代码来源:nipaptest.py

示例5: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
def add_pool(arg, opts):
    """ Add a pool.
    """

    p = Pool()
    p.schema = get_schema(opts.get('schema'))
    p.name = opts.get('name')
    p.description = opts.get('description')
    p.default_type = opts.get('default-type')
    p.ipv4_default_prefix_length = opts.get('ipv4_default_prefix_length')
    p.ipv6_default_prefix_length = opts.get('ipv6_default_prefix_length')

    try:
        p.save()
    except pynipap.NipapError, e:
        print >> sys.stderr, "Could not add pool to NIPAP: %s" % e.message
        sys.exit(1)
开发者ID:tobbakko,项目名称:NIPAP,代码行数:19,代码来源:nipap_cli.py

示例6: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
    def add_pool(self):
        """ Add a pool.
        """

        # extract attributes
        p = Pool()
        p.name = request.params.get('name')
        p.description = request.params.get('description')
        p.default_type = request.params.get('default_type')
        if 'ipv4_default_prefix_length' in request.params:
            if request.params['ipv4_default_prefix_length'].strip() != '':
                p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
        if 'ipv6_default_prefix_length' in request.params:
            if request.params['ipv6_default_prefix_length'].strip() != '':
                p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']

        try:
           p.save()
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:sohonet,项目名称:NIPAP,代码行数:22,代码来源:xhr.py

示例7: Pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
    pynipap.xmlrpc_uri = nipapd_xmlrpc_uri


    #
    # Create pools
    #
    print "Creating pools... ",
    sql = "SELECT * FROM ip_net_pool"
    curs_pg_old.execute(sql)
    pools = {}
    for r in curs_pg_old:
        p = Pool()
        p.name = r['name']
        p.description = r['description']
        p.default_type = r['default_type']
        p.ipv4_default_prefix_length = r['ipv4_default_prefix_length']
        p.ipv6_default_prefix_length = r['ipv6_default_prefix_length']
        try:
            p.save()
        except NipapError, e:
            print "ERR: %s" % str(e)
        pools[r['id']] = p

        # remove new audit log entries
        sql = "DELETE FROM ip_net_log WHERE pool_id = %s"
        curs_pg_new.execute(sql, ( p.id, ))

        # fetch old audit log entries
        sql = "SELECT * FROM ip_net_log WHERE pool = %s AND prefix IS NULL"
        curs_pg_old2.execute(sql, ( r['id'], ))
        for ar in curs_pg_old2:
开发者ID:Cougar,项目名称:NIPAP,代码行数:33,代码来源:convert.py

示例8: type

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import ipv4_default_prefix_length [as 别名]
        """

        try:
            c.schema = Schema.get(int(request.params.get('schema')))
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

        # extract attributes
        p = Pool()
        p.schema = c.schema
        p.name = request.params.get('name')
        p.description = request.params.get('description')
        p.default_type = request.params.get('default_type')
        if 'ipv4_default_prefix_length' in request.params:
            if request.params['ipv4_default_prefix_length'].strip() != '':
                p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
        if 'ipv6_default_prefix_length' in request.params:
            if request.params['ipv6_default_prefix_length'].strip() != '':
                p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']

        try:
           p.save()
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

        return json.dumps(p, cls=NipapJSONEncoder)



    def edit_pool(self, id):
        """ Edit a pool.
开发者ID:tobbakko,项目名称:NIPAP,代码行数:33,代码来源:xhr.py


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