本文整理汇总了Python中pynipap.Pool.search方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.search方法的具体用法?Python Pool.search怎么用?Python Pool.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Pool
的用法示例。
在下文中一共展示了Pool.search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import search [as 别名]
def list_pool(arg, opts):
""" List pools matching a search criteria
"""
s = get_schema()
query = _expand_list_query(opts)
res = Pool.search(s, query)
if len(res['result']) > 0:
print "%-19s %-39s %-14s %-8s" % (
"Name", "Description", "Default type", "4 / 6"
)
print "-----------------------------------------------------------------------------------"
else:
print "No matching pools found"
for p in res['result']:
if len(p.description) > 38:
desc = p.description[0:34] + "..."
else:
desc = p.description
print "%-19s %-39s %-14s %-2s / %-3s" % (
p.name, desc, p.default_type,
str(p.ipv4_default_prefix_length),
str(p.ipv6_default_prefix_length)
)
示例2: complete_pool_name
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import search [as 别名]
def complete_pool_name(arg):
""" Returns list of matching pool names
"""
s = get_schema()
search_string = '^'
if arg is not None:
search_string += arg
res = Pool.search(s, {
'operator': 'regex_match',
'val1': 'name',
'val2': search_string
})
ret = []
for p in res['result']:
ret.append(p.name)
return ret
示例3: test_search_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import search [as 别名]
def test_search_pool(self):
""" We should be able to execute search_pool as read-only user
"""
p = Pool.search({ 'val1': 'id',
'operator': 'equals',
'val2': 0 })