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


Python Pool.schema方法代码示例

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


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

示例1: add

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import schema [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

示例2: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import schema [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

示例3: add_pool

# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import schema [as 别名]
        return json.dumps(result, cls=NipapJSONEncoder)



    def add_pool(self):
        """ Add a pool.
        """

        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__})
开发者ID:tobbakko,项目名称:NIPAP,代码行数:32,代码来源:xhr.py


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