本文整理汇总了Python中pynipap.Prefix.comment方法的典型用法代码示例。如果您正苦于以下问题:Python Prefix.comment方法的具体用法?Python Prefix.comment怎么用?Python Prefix.comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Prefix
的用法示例。
在下文中一共展示了Prefix.comment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_prefix
# 需要导入模块: from pynipap import Prefix [as 别名]
# 或者: from pynipap.Prefix import comment [as 别名]
def add_prefix(arg, opts):
""" Add prefix to NIPAP
"""
s = get_schema()
p = Prefix()
p.schema = s
p.prefix = opts.get('prefix')
p.type = opts.get('type')
p.description = opts.get('description')
p.node = opts.get('node')
p.country = opts.get('country')
p.order_id = opts.get('order_id')
p.vrf = opts.get('vrf')
p.alarm_priority = opts.get('alarm_priority')
p.comment = opts.get('comment')
p.monitor = _str_to_bool(opts.get('monitor'))
args = {}
if 'from-pool' in opts:
res = Pool.list(s, { 'name': opts['from-pool'] })
if len(res) == 0:
print >> sys.stderr, "No pool named %s found." % opts['from-pool']
sys.exit(1)
args['from-pool'] = res[0]
if 'from-prefix' in opts:
args['from-prefix'] = [ opts['from-prefix'], ]
if 'prefix-length' in opts:
args['prefix_length'] = int(opts['prefix-length'])
if 'family' in opts:
family = opts['family']
if opts['family'] == 'ipv4':
family = 4
elif opts['family'] == 'ipv6':
family = 6
args['family'] = family
try:
p.save(args)
except NipapError, e:
print >> sys.stderr, "Could not add prefix to NIPAP: %s" % e.message
sys.exit(1)