本文整理汇总了Python中pynipap.Pool.tags方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.tags方法的具体用法?Python Pool.tags怎么用?Python Pool.tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Pool
的用法示例。
在下文中一共展示了Pool.tags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import tags [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__})
示例2: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import tags [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']
if 'tags' in request.params:
p.tags = json.loads(request.params['tags'])
try:
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})