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