本文整理汇总了Python中pynipap.VRF.search方法的典型用法代码示例。如果您正苦于以下问题:Python VRF.search方法的具体用法?Python VRF.search怎么用?Python VRF.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.VRF
的用法示例。
在下文中一共展示了VRF.search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search_vrf
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import search [as 别名]
def test_search_vrf(self):
""" We should be able to execute search_vrf as read-only user
"""
v = VRF.search({ 'val1': 'id',
'operator': 'equals',
'val2': 0 })
self.assertEqual(v['result'][0].id, 0)
示例2: get_current_vrfs
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import search [as 别名]
def get_current_vrfs(self):
""" Return VRF filter list from session variable
Before returning list, make a search for all VRFs currently in the
list to verify that they still exist.
"""
# Verify that all currently selected VRFs still exists
cur_vrfs = session.get('current_vrfs', {}).items()
if len(cur_vrfs) > 0:
q = {
'operator': 'equals',
'val1': 'id',
'val2': cur_vrfs[0][0]
}
if len(cur_vrfs) > 1:
for vrf_id, vrf in cur_vrfs[1:]:
q = {
'operator': 'or',
'val1': q,
'val2': {
'operator': 'equals',
'val1': 'id',
'val2': vrf_id
}
}
res = VRF.search(q)
session['current_vrfs'] = {}
for vrf in res['result']:
session['current_vrfs'][vrf.id] = { 'id': vrf.id, 'rt': vrf.rt,
'name': vrf.name, 'description': vrf.description }
session.save()
return json.dumps(session.get('current_vrfs', {}))