本文整理汇总了Python中pynipap.Pool.prefix方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.prefix方法的具体用法?Python Pool.prefix怎么用?Python Pool.prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Pool
的用法示例。
在下文中一共展示了Pool.prefix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import prefix [as 别名]
print "Creating prefixes... "
sql = "SELECT * FROM ip_net_plan order by schema, prefix"
curs_pg_old.execute(sql)
i = 0
t = time.time()
for r in curs_pg_old:
p = Prefix()
# find VRF
if r['vrf'] is not None:
p.vrf = vrfs[r['vrf'].strip()]
elif r['schema'] in s_vrfs:
p.vrf = s_vrfs[r['schema']]
# the rest of the prefix attributes...
p.prefix = r['prefix']
p.description = r['description']
p.comment = r['comment']
p.node = r['node']
if r['pool'] is not None:
p.pool = pools[r['pool']]
p.type = r['type']
p.country = r['country']
p.order_id = r['order_id']
p.customer_id = r['customer_id']
p.external_key = r['external_key']
p.alarm_priority = r['alarm_priority']
p.monitor = r['monitor']
try:
p.save()
示例2: int
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import prefix [as 别名]
if 'from_prefix[]' in request.params:
args['from-prefix'] = request.params.getall('from_prefix[]')
if 'from_pool' in request.params:
try:
args['from-pool'] = Pool.get(p.schema, int(request.params['from_pool']))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
if 'family' in request.params:
args['family'] = int(request.params['family'])
if 'prefix_length' in request.params:
args['prefix_length'] = int(request.params['prefix_length'])
# manual allocation?
if args == {}:
if 'prefix' in request.params:
p.prefix = request.params['prefix']
try:
p.save(args)
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
return json.dumps(p, cls=NipapJSONEncoder)
def edit_prefix(self, id):
""" Edit a prefix.
"""
try: