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


Python Pool.list方法代码示例

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


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

示例1: test_stats3

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def test_stats3(self):
        """ Check total stats are correct when adding and removing child prefixes from pool
        """
        th = TestHelper()

        # add a pool
        pool1 = th.add_pool('test', 'assignment', 31, 112)

        # add some members to the pool
        p1 = th.add_prefix('1.0.0.0/24', 'reservation', 'test', pool_id=pool1.id)
        p2 = th.add_prefix('2001:db8::/48', 'reservation', 'test', pool_id=pool1.id)

        # add child from pool
        pc1 = th.add_prefix_from_pool(pool1, 4, 'foo')
        pc2 = th.add_prefix_from_pool(pool1, 6, 'foo')

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(1, res[0].used_prefixes_v4)
        self.assertEqual(256, res[0].total_addresses_v4)
        self.assertEqual(2, res[0].used_addresses_v4)
        self.assertEqual(254, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(1, res[0].used_prefixes_v6)
        self.assertEqual(1208925819614629174706176, res[0].total_addresses_v6)
        self.assertEqual(65536, res[0].used_addresses_v6)
        self.assertEqual(1208925819614629174640640, res[0].free_addresses_v6)

        # remove child prefixes
        pc1.remove()
        pc2.remove()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(256, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(256, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(1208925819614629174706176, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(1208925819614629174706176, res[0].free_addresses_v6)
开发者ID:Cougar,项目名称:NIPAP,代码行数:51,代码来源:nipaptest.py

示例2: test_stats2

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def test_stats2(self):
        """ Check total stats are correct when updating member prefix
        """
        th = TestHelper()

        # add a pool
        pool1 = th.add_pool('test', 'assignment', 31, 112)

        # add some members to the pool
        p1 = th.add_prefix('1.0.0.0/24', 'reservation', 'test', pool_id=pool1.id)
        p2 = th.add_prefix('2001:db8::/48', 'reservation', 'test', pool_id=pool1.id)

        p1.prefix = '1.0.0.0/25'
        p1.save()
        p2.prefix = '2001:db8::/64'
        p2.save()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(128, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(128, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(18446744073709551616, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(18446744073709551616, res[0].free_addresses_v6)
开发者ID:Cougar,项目名称:NIPAP,代码行数:33,代码来源:nipaptest.py

示例3: list

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def list(self):
        """ Displays a list of pools.
        """

        c.pools = Pool.list()

        return render('/pool_list.html')
开发者ID:hetznerZA,项目名称:NIPAP,代码行数:9,代码来源:pool.py

示例4: modify_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
def modify_pool(arg, opts):
    """ Modify a pool with the options set in opts
    """

    s = get_schema()
    res = Pool.list(s, { 'name': arg })
    if len(res) < 1:
        print >> sys.stderr, "No pool with name %s found." % arg
        sys.exit(1)

    p = res[0]

    if 'name' in opts:
        p.name = opts['name']
    if 'description' in opts:
        p.description = opts['description']
    if 'default-type' in opts:
        p.default_type = opts['default-type']
    if 'ipv4_default_prefix_length' in opts:
        p.ipv4_default_prefix_length = opts['ipv4_default_prefix_length']
    if 'ipv6_default_prefix_length' in opts:
        p.ipv6_default_prefix_length = opts['ipv6_default_prefix_length']

    p.save()

    print "Pool %s saved." % p.name
开发者ID:tobbakko,项目名称:NIPAP,代码行数:28,代码来源:nipap_cli.py

示例5: list_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def list_pool(self):
        """ List pools and return JSON encoded result.
        """

        try:
            schema = Schema.get(int(request.params['schema']))
            pools = Pool.list(schema)
        except NipapError, e:
            return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:tobbakko,项目名称:NIPAP,代码行数:11,代码来源:xhr.py

示例6: add

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

        # make sure we have a schema
        try:
            c.schema = Schema.get(int(request.params['schema']))
            c.pools = Pool.list(c.schema)
        except (KeyError, NipapNonExistentError), e:
            redirect(url(controller = 'schema', action = 'list'))
开发者ID:tobbakko,项目名称:NIPAP,代码行数:12,代码来源:prefix.py

示例7: list_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def list_pool(self):
        """ List pools and return JSON encoded result.
        """

        # fetch attributes from request.json
        attr = XhrController.extract_pool_attr(request.json)

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

示例8: list

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def list(self):
        """ Displays a list of pools.
        """

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

        c.pools = Pool.list(c.schema)

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

示例9: add_prefix

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
def add_prefix(arg, opts):
    """ Add prefix to NIPAP
    """

    s = get_schema()

    p = Prefix()
    p.schema = s
    p.prefix = opts.get('prefix')
    p.type = opts.get('type')
    p.description = opts.get('description')
    p.node = opts.get('node')
    p.country = opts.get('country')
    p.order_id = opts.get('order_id')
    p.vrf = opts.get('vrf')
    p.alarm_priority = opts.get('alarm_priority')
    p.comment = opts.get('comment')
    p.monitor = _str_to_bool(opts.get('monitor'))

    args = {}
    if 'from-pool' in opts:
        res = Pool.list(s, { 'name': opts['from-pool'] })
        if len(res) == 0:
            print >> sys.stderr, "No pool named %s found." % opts['from-pool']
            sys.exit(1)

        args['from-pool'] = res[0]

    if 'from-prefix' in opts:
        args['from-prefix'] = [ opts['from-prefix'], ]

    if 'prefix-length' in opts:
        args['prefix_length'] = int(opts['prefix-length'])

    if 'family' in opts:
        family = opts['family']
        if opts['family'] == 'ipv4':
            family = 4
        elif opts['family'] == 'ipv6':
            family = 6

        args['family'] = family


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

示例10: remove_pool

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

    s = get_schema()
    res = Pool.list(s, { 'name': arg })
    if len(res) < 1:
        print >> sys.stderr, "No pool with name %s found." % arg
        sys.exit(1)

    p = res[0]

    res = raw_input("Do you really want to remove the pool %s? [y/n]: " % p.name)

    if res == 'y':
        p.remove()
        print "Pool %s removed." % p.name
    else:
        print "Operation canceled."
开发者ID:tobbakko,项目名称:NIPAP,代码行数:21,代码来源:nipap_cli.py

示例11: view_pool

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

    s = get_schema(opts.get('schema'))

    res = Pool.list(s, { 'name': arg })

    if len(res) == 0:
        print "No pool named %s found." % arg
        return

    p = res[0]
    print  "-- Pool "
    print "  %-15s : %s" % ("Name", p.name)
    print "  %-15s : %s" % ("Description", p.description)
    print "  %-15s : %s" % ("Default type", p.default_type)
    print "  %-15s : %s / %s" % ("Preflen (v4/v6)", str(p.ipv4_default_prefix_length), str(p.ipv6_default_prefix_length))
    print "\n-- Prefixes in pool"

    res = Prefix.list(s, { 'pool': p.id})
    for pref in res:
        print "  %s" % pref.display_prefix
开发者ID:tobbakko,项目名称:NIPAP,代码行数:25,代码来源:nipap_cli.py

示例12: test_stats4

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def test_stats4(self):
        """ Check total stats are correct when modifying child prefixes in pool
        """
        th = TestHelper()

        # add a pool
        pool1 = th.add_pool('test', 'assignment', 31, 112)

        # add some members to the pool
        p1 = th.add_prefix('1.0.0.0/24', 'reservation', 'test', pool_id=pool1.id)
        p2 = th.add_prefix('2001:db8::/48', 'reservation', 'test', pool_id=pool1.id)

        # add child from pool
        pc1 = th.add_prefix_from_pool(pool1, 4, 'foo')
        pc2 = th.add_prefix_from_pool(pool1, 6, 'foo')

        # change child prefix and size and make sure stats are updated correctly
        pc1.prefix = '1.0.0.128/25'
        pc1.save()
        pc2.prefix = '2001:db8:0:1::/64'
        pc2.save()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(1, res[0].used_prefixes_v4)
        self.assertEqual(256, res[0].total_addresses_v4)
        self.assertEqual(128, res[0].used_addresses_v4)
        self.assertEqual(128, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(1, res[0].used_prefixes_v6)
        self.assertEqual(1208925819614629174706176, res[0].total_addresses_v6)
        self.assertEqual(18446744073709551616, res[0].used_addresses_v6)
        self.assertEqual(1208907372870555465154560, res[0].free_addresses_v6)
开发者ID:Cougar,项目名称:NIPAP,代码行数:38,代码来源:nipaptest.py

示例13: raw_input

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
                sys.stdout.write(".")
                sys.stdout.flush()
            print " done!"

    if args.clear_pools:
        remove_confirmed = args.force
        if not remove_confirmed:
            res = raw_input("Are you sure you want to remove all pools? [y/N]")
            if len(res) > 0 and res.lower()[0] == 'y':
                remove_confirmed = True
            else:
                print "Operation aborted."

        if remove_confirmed:
            print "Removing: ",
            for p in Pool.list():
                p.remove()
                sys.stdout.write(".")
                sys.stdout.flush()
            print " done!"

    if args.clear_prefixes:
        remove_confirmed = args.force
        if not remove_confirmed:
            res = raw_input("Are you sure you want to remove all prefixes? [y/N]")
            if len(res) > 0 and res.lower()[0] == 'y':
                remove_confirmed = True
            else:
                print "Aborted"

        if remove_confirmed:
开发者ID:Dhyrule,项目名称:NIPAP,代码行数:33,代码来源:remove-all.py

示例14: test_stats5

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def test_stats5(self):
        """ Check total stats are correct when adding and removing member prefix with childs from pool

            This is trickier as there is now a child in the pool that needs to
            be accounted for.
        """
        th = TestHelper()

        # add a pool
        pool1 = th.add_pool('test', 'assignment', 31, 112)

        # add some members to the pool
        p1 = th.add_prefix('1.0.0.0/24', 'reservation', 'test', pool_id=pool1.id)
        p2 = th.add_prefix('2.0.0.0/24', 'reservation', 'test', pool_id=pool1.id)
        p3 = th.add_prefix('2001:db8:1::/48', 'reservation', 'test', pool_id=pool1.id)
        p4 = th.add_prefix('2001:db8:2::/48', 'reservation', 'test', pool_id=pool1.id)

        # add child from pool
        pc1 = th.add_prefix_from_pool(pool1, 4, 'foo')
        pc2 = th.add_prefix_from_pool(pool1, 6, 'foo')

        # remove first member prefixes from pool
        p1.pool = None
        p1.save()
        p3.pool = None
        p3.save()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(256, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(256, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(1208925819614629174706176, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(1208925819614629174706176, res[0].free_addresses_v6)

        # readd prefixes to pool
        p1.pool = pool1
        p1.save()
        p3.pool = pool1
        p3.save()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(2, res[0].member_prefixes_v4)
        self.assertEqual(1, res[0].used_prefixes_v4)
        self.assertEqual(512, res[0].total_addresses_v4)
        self.assertEqual(2, res[0].used_addresses_v4)
        self.assertEqual(510, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(2, res[0].member_prefixes_v6)
        self.assertEqual(1, res[0].used_prefixes_v6)
        self.assertEqual(2417851639229258349412352, res[0].total_addresses_v6)
        self.assertEqual(65536, res[0].used_addresses_v6)
        self.assertEqual(2417851639229258349346816, res[0].free_addresses_v6)
开发者ID:Cougar,项目名称:NIPAP,代码行数:64,代码来源:nipaptest.py

示例15: test_stats1

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import list [as 别名]
    def test_stats1(self):
        """ Check total stats are correct when adding and removing member prefix
        """
        th = TestHelper()

        # add a pool
        pool1 = th.add_pool('test', 'assignment', 31, 112)

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(0, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(0, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(0, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(0, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(0, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(0, res[0].free_addresses_v6)

        # add some members to the pool
        p1 = th.add_prefix('1.0.0.0/24', 'assignment', 'test', pool_id=pool1.id)
        p2 = th.add_prefix('2.0.0.0/24', 'assignment', 'test', pool_id=pool1.id)
        p3 = th.add_prefix('2001:db8::/48', 'assignment', 'test', pool_id=pool1.id)
        p4 = th.add_prefix('2001:db8:1::/48', 'assignment', 'test', pool_id=pool1.id)

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(2, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(512, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(512, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(2, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(2417851639229258349412352, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(2417851639229258349412352, res[0].free_addresses_v6)

        # remove one IPv4 and one IPv6 member from the pool
        p1.remove()
        p3.remove()

        # check stats for pool1
        res = Pool.list({ 'id': pool1.id })
        # ipv4
        self.assertEqual(1, res[0].member_prefixes_v4)
        self.assertEqual(0, res[0].used_prefixes_v4)
        self.assertEqual(256, res[0].total_addresses_v4)
        self.assertEqual(0, res[0].used_addresses_v4)
        self.assertEqual(256, res[0].free_addresses_v4)
        # ipv6
        self.assertEqual(1, res[0].member_prefixes_v6)
        self.assertEqual(0, res[0].used_prefixes_v6)
        self.assertEqual(1208925819614629174706176, res[0].total_addresses_v6)
        self.assertEqual(0, res[0].used_addresses_v6)
        self.assertEqual(1208925819614629174706176, res[0].free_addresses_v6)
开发者ID:Cougar,项目名称:NIPAP,代码行数:64,代码来源:nipaptest.py


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