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


Python Prefix.get方法代码示例

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


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

示例1: edit_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def edit_prefix(self, id):
        """ Edit a prefix.
        """

        try:
            p = Prefix.get(int(id))

            # extract attributes
            if 'prefix' in request.json:
                p.prefix = validate_string(request.json, 'prefix')
            if 'type' in request.json:
                p.type = validate_string(request.json, 'type')
            if 'description' in request.json:
                p.description = validate_string(request.json, 'description')
            if 'expires' in request.json:
                p.expires = validate_string(request.json, 'expires')
            if 'comment' in request.json:
                p.comment = validate_string(request.json, 'comment')
            if 'node' in request.json:
                p.node = validate_string(request.json, 'node')
            if 'status' in request.json:
                p.status = validate_string(request.json, 'status')

            if 'pool' in request.json:
                if request.json['pool'] is None:
                    p.pool = None
                else:
                    try:
                        p.pool = Pool.get(int(request.json['pool']))
                    except NipapError, e:
                        return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

            if 'alarm_priority' in request.json:
                p.alarm_priority = validate_string(request.json, 'alarm_priority')
            if 'monitor' in request.json:
                if request.json['monitor'] == 'true':
                    p.monitor = True
                else:
                    p.monitor = False

            if 'country' in request.json:
                p.country = validate_string(request.json, 'country')
            if 'order_id' in request.json:
                p.order_id = validate_string(request.json, 'order_id')
            if 'customer_id' in request.json:
                p.customer_id = validate_string(request.json, 'customer_id')

            if 'vrf' in request.json:

                try:
                    if request.json['vrf'] is None or len(unicode(request.json['vrf'])) == 0:
                        p.vrf = None
                    else:
                        p.vrf = VRF.get(int(request.json['vrf']))
                except ValueError:
                    return json.dumps({'error': 1, 'message': "Invalid VRF ID '%s'" % request.json['vrf']})
                except NipapError, e:
                    return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:fredsod,项目名称:NIPAP,代码行数:60,代码来源:xhr.py

示例2: remove_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def remove_prefix(self, id):
        """ Remove a prefix.
        """

        try:
            p = Prefix.get(int(id))
            p.remove()

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

示例3: edit

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def edit(self, id):
        """ Edit a prefix.
        """

        # find prefix
        c.prefix = Prefix.get(int(id))

        # we got a HTTP POST - edit object
        if request.method == 'POST':
            c.prefix.prefix = request.params['prefix_prefix']
            c.prefix.description = request.params['prefix_description']

            if request.params['prefix_node'].strip() == '':
                c.prefix.node = None
            else:
                c.prefix.node = request.params['prefix_node']

            if request.params['prefix_country'].strip() == '':
                c.prefix.country = None
            else:
                c.prefix.country = request.params['prefix_country']

            if request.params['prefix_comment'].strip() == '':
                c.prefix.comment = None
            else:
                c.prefix.comment = request.params['prefix_comment']

            if request.params['prefix_order_id'].strip() == '':
                c.prefix.order_id = None
            else:
                c.prefix.order_id = request.params['prefix_order_id']

            if request.params['prefix_customer_id'].strip() == '':
                c.prefix.customer_id = None
            else:
                c.prefix.customer_id = request.params['prefix_customer_id']

            if request.params['prefix_vrf'].strip() == '':
                c.prefix.vrf = None
            else:
                # TODO: handle non-existent VRF...
                c.prefix.vrf = VRF.list({ 'rt': request.params['prefix_vrf'] })[0]

            if request.params.get('prefix_monitor') is not None:
                c.prefix.monitor = True
            else:
                c.prefix.monitor = False

            c.prefix.alarm_priority = request.params['prefix_alarm_priority']
            c.prefix.save()
            redirect(url(controller='prefix', action='list'))


        return render('/prefix_edit.html')
开发者ID:Dhyrule,项目名称:NIPAP,代码行数:56,代码来源:prefix.py

示例4: remove_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def remove_prefix(self, id):
        """ Remove a prefix from pool 'id'.
        """

        if 'prefix' not in request.params:
            abort(400, 'Missing prefix.')
        prefix = Prefix.get(int(request.params['prefix']))
        prefix.pool = None
        prefix.save()

        redirect(url(controller = 'pool', action = 'edit', id = id))
开发者ID:CrackerJackMack,项目名称:NIPAP,代码行数:13,代码来源:pool.py

示例5: remove_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def remove_prefix(self):
        """ Remove a prefix.
        """

        try:
            schema = Schema.get(int(request.params['schema']))
            p = Prefix.get(schema, int(request.params['id']))
            p.remove()

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

示例6: remove

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def remove(self, id):
        """ Remove a prefix.
        """

        # find prefix
        c.prefix = Prefix.get(int(id))

        if 'confirmed' not in request.params:
            return render('/prefix_remove_confirm.html')

        c.prefix.remove()
        redirect(url(controller='prefix', action='list'))
开发者ID:Dhyrule,项目名称:NIPAP,代码行数:14,代码来源:prefix.py

示例7: add_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def add_prefix(self, id):
        """ Add a prefix to pool 'id'
        """

        if 'prefix' not in request.params:
            abort(400, 'Missing prefix.')

        pool = Pool.get(int(id))

        prefix = Prefix.get(int(request.params['prefix']))
        prefix.pool = pool
        prefix.save()

        redirect(url(controller = 'pool', action = 'edit', id = id))
开发者ID:CrackerJackMack,项目名称:NIPAP,代码行数:16,代码来源:pool.py

示例8: edit_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def edit_prefix(self, id):
        """ Edit a prefix.
        """

        try:
            p = Prefix.get(int(id))

            # extract attributes
            if 'prefix' in request.params:
                p.prefix = request.params['prefix']

            if 'type' in request.params:
                p.type = request.params['type'].strip()

            if 'description' in request.params:
                if request.params['description'].strip() == '':
                    p.description = None
                else:
                    p.description = request.params['description'].strip()

            if 'expires' in request.params:
                if request.params['expires'].strip() == '':
                    p.expires = None
                else:
                    p.expires = request.params['expires'].strip(' "')

            if 'comment' in request.params:
                if request.params['comment'].strip() == '':
                    p.comment = None
                else:
                    p.comment = request.params['comment'].strip()

            if 'node' in request.params:
                if request.params['node'].strip() == '':
                    p.node = None
                else:
                    p.node = request.params['node'].strip()

            if 'status' in request.params:
                p.status = request.params['status'].strip()

            if 'pool' in request.params:
                if request.params['pool'].strip() == '':
                    p.pool = None
                else:
                    try:
                        p.pool = Pool.get(int(request.params['pool']))
                    except NipapError, e:
                        return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})

            if 'alarm_priority' in request.params:
                p.alarm_priority = request.params['alarm_priority'].strip()

            if 'monitor' in request.params:
                if request.params['monitor'] == 'true':
                    p.monitor = True
                else:
                    p.monitor = False

            if 'country' in request.params:
                if request.params['country'].strip() == '':
                    p.country = None
                else:
                    p.country = request.params['country'].strip()

            if 'order_id' in request.params:
                if request.params['order_id'].strip() == '':
                    p.order_id = None
                else:
                    p.order_id = request.params['order_id'].strip()

            if 'customer_id' in request.params:
                if request.params['customer_id'].strip() == '':
                    p.customer_id = None
                else:
                    p.customer_id = request.params['customer_id'].strip()

            if 'vrf' in request.params:

                try:
                    if request.params['vrf'] is None or len(request.params['vrf']) == 0:
                        p.vrf = None
                    else:
                        p.vrf = VRF.get(int(request.params['vrf']))
                except ValueError:
                    return json.dumps({'error': 1, 'message': "Invalid VRF ID '%s'" % request.params['vrf']})
                except NipapError, e:
                    return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
开发者ID:AlfredArouna,项目名称:NIPAP,代码行数:90,代码来源:xhr.py

示例9: test_list_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
 def test_list_prefix(self):
     """ We should be able to execute list_prefix as read-only user
     """
     with self.assertRaises(NipapNonExistentError):
         p = Prefix.get(0)
开发者ID:AlfredArouna,项目名称:NIPAP,代码行数:7,代码来源:nipap-ro.py

示例10: edit_prefix

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
    def edit_prefix(self, id):
        """ Edit a prefix.
        """

        try:
            schema = Schema.get(int(request.params['schema']))

            p = Prefix.get(schema, int(id))

            # extract attributes
            if 'prefix' in request.params:
                p.prefix = request.params['prefix']

            if 'description' in request.params:
                p.description = request.params['description']

            if 'comment' in request.params:
                if request.params['comment'].strip() == '':
                    p.comment = None
                else:
                    p.comment = request.params['comment']

            if 'node' in request.params:
                if request.params['node'].strip() == '':
                    p.node = None
                else:
                    p.node = request.params['node']

            if 'pool' in request.params:
                if request.params['pool'].strip() == '':
                    p.pool = None
                else:
                    p.pool = Pool.get(schema, int(request.params['pool']))

            if 'alarm_priority' in request.params:
                p.alarm_priority = request.params['alarm_priority']

            if 'monitor' in request.params:
                if request.params['monitor'] == 'true':
                    p.monitor = True
                else:
                    p.monitor = False

            if 'country' in request.params:
                if request.params['country'].strip() == '':
                    p.country = None
                else:
                    p.country = request.params['country']

            if 'order_id' in request.params:
                if request.params['order_id'].strip() == '':
                    p.order_id = None
                else:
                    p.order_id = request.params['order_id']

            if 'vrf' in request.params:
                if request.params['vrf'].strip() == '':
                    p.vrf = None
                else:
                    p.vrf = request.params['vrf']

            p.save()

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

示例11: render

# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import get [as 别名]
        return render('/prefix_add.html')



    def edit(self, id):
        """ Edit a prefix.
        """

        # make sure we have a schema
        try:
            c.schema = Schema.get(int(request.params['schema']))
        except (KeyError, NipapNonExistentError), e:
            redirect(url(controller = 'schema', action = 'list'))

        # find prefix
        c.prefix = Prefix.get(c.schema, int(id))

        # we got a HTTP POST - edit object
        if request.method == 'POST':
            c.prefix.prefix = request.params['prefix_prefix']
            c.prefix.description = request.params['prefix_description']

            if request.params['prefix_node'].strip() == '':
                c.prefix.node = None
            else:
                c.prefix.node = request.params['prefix_node']

            if request.params['prefix_country'].strip() == '':
                c.prefix.country = None
            else:
                c.prefix.country = request.params['prefix_country']
开发者ID:tobbakko,项目名称:NIPAP,代码行数:33,代码来源:prefix.py


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