本文整理汇总了Python中pynipap.Pool.name方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.name方法的具体用法?Python Pool.name怎么用?Python Pool.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Pool
的用法示例。
在下文中一共展示了Pool.name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_data
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def test_load_data(self):
"""
"""
th = TestHelper()
p1 = th.add_prefix('192.168.0.0/16', 'reservation', 'test')
p2 = th.add_prefix('192.168.0.0/20', 'reservation', 'test')
p3 = th.add_prefix('192.168.0.0/24', 'reservation', 'test')
p4 = th.add_prefix('192.168.1.0/24', 'reservation', 'test')
p5 = th.add_prefix('192.168.2.0/24', 'reservation', 'test')
p6 = th.add_prefix('192.168.32.0/20', 'reservation', 'test')
p7 = th.add_prefix('192.168.32.0/24', 'reservation', 'test')
ps1 = th.add_prefix('2001:db8:1::/48', 'reservation', 'test')
ps2 = th.add_prefix('2001:db8:1::/64', 'reservation', 'test')
ps3 = th.add_prefix('2001:db8:2::/48', 'reservation', 'test')
pool1 = Pool()
pool1.name = 'upgrade-test'
pool1.save()
p2.pool = pool1
p2.save()
ps1.pool = pool1
ps1.save()
pool2 = Pool()
pool2.name = 'upgrade-test2'
pool2.save()
vrf1 = VRF()
vrf1.name = 'foo'
vrf1.rt = '123:123'
vrf1.save()
示例2: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add_pool(self):
""" Add a pool.
"""
# extract attributes
p = Pool()
if 'name' in request.json:
p.name = validate_string(request.json, 'name')
if 'description' in request.json:
p.description = validate_string(request.json, 'description')
if 'default_type' in request.json:
p.default_type = validate_string(request.json, 'default_type')
# TODO: handle integers
if 'ipv4_default_prefix_length' in request.json:
p.ipv4_default_prefix_length = request.json['ipv4_default_prefix_length']
if 'ipv6_default_prefix_length' in request.json:
p.ipv6_default_prefix_length = request.json['ipv6_default_prefix_length']
if 'tags' in request.json:
p.tags = request.json['tags']
if 'avps' in request.json:
p.avps = request.json['avps']
try:
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例3: test_add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def test_add_pool(self):
""" We should NOT be able to execute add_pool as read-only user
"""
p = Pool()
p.name = 'test'
with self.assertRaises(NipapAuthorizationError):
p.save()
示例4: add
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add(self):
""" Add a pool.
"""
if 'schema' not in request.params:
redirect(url(controller = 'schema', action = 'list'))
c.schema = Schema.get(int(request.params['schema']))
# Adding to NIPAP
if request.method == 'POST':
p = Pool()
p.schema = c.schema
p.name = request.params.get('name')
p.description = request.params.get('description')
p.default_type = request.params.get('default_type')
if request.params['ipv4_default_prefix_length'].strip() != '':
p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
if request.params['ipv6_default_prefix_length'].strip() != '':
p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']
p.save()
redirect(url(controller = 'pool', action = 'list', schema = c.schema.id))
return render("/pool_add.html")
示例5: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add_pool(self, name, default_type, ipv4_default_prefix_length, ipv6_default_prefix_length):
pool = Pool()
pool.name = name
pool.default_type = default_type
pool.ipv4_default_prefix_length = ipv4_default_prefix_length
pool.ipv6_default_prefix_length = ipv6_default_prefix_length
pool.save()
return pool
示例6: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add_pool(arg, opts):
""" Add a pool.
"""
p = Pool()
p.schema = get_schema(opts.get('schema'))
p.name = opts.get('name')
p.description = opts.get('description')
p.default_type = opts.get('default-type')
p.ipv4_default_prefix_length = opts.get('ipv4_default_prefix_length')
p.ipv6_default_prefix_length = opts.get('ipv6_default_prefix_length')
try:
p.save()
except pynipap.NipapError, e:
print >> sys.stderr, "Could not add pool to NIPAP: %s" % e.message
sys.exit(1)
示例7: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add_pool(self):
""" Add a pool.
"""
# extract attributes
p = Pool()
p.name = request.params.get('name')
p.description = request.params.get('description')
p.default_type = request.params.get('default_type')
if 'ipv4_default_prefix_length' in request.params:
if request.params['ipv4_default_prefix_length'].strip() != '':
p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
if 'ipv6_default_prefix_length' in request.params:
if request.params['ipv6_default_prefix_length'].strip() != '':
p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']
try:
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例8: Pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
# set up pynipap
aopts = pynipap.AuthOptions({ 'authoritative_source': 'nipap' })
pynipap.xmlrpc_uri = nipapd_xmlrpc_uri
#
# Create pools
#
print "Creating pools... ",
sql = "SELECT * FROM ip_net_pool"
curs_pg_old.execute(sql)
pools = {}
for r in curs_pg_old:
p = Pool()
p.name = r['name']
p.description = r['description']
p.default_type = r['default_type']
p.ipv4_default_prefix_length = r['ipv4_default_prefix_length']
p.ipv6_default_prefix_length = r['ipv6_default_prefix_length']
try:
p.save()
except NipapError, e:
print "ERR: %s" % str(e)
pools[r['id']] = p
# remove new audit log entries
sql = "DELETE FROM ip_net_log WHERE pool_id = %s"
curs_pg_new.execute(sql, ( p.id, ))
# fetch old audit log entries
示例9: add_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import name [as 别名]
def add_pool(self):
""" Add a pool.
"""
try:
c.schema = Schema.get(int(request.params.get('schema')))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
# extract attributes
p = Pool()
p.schema = c.schema
p.name = request.params.get('name')
p.description = request.params.get('description')
p.default_type = request.params.get('default_type')
if 'ipv4_default_prefix_length' in request.params:
if request.params['ipv4_default_prefix_length'].strip() != '':
p.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
if 'ipv6_default_prefix_length' in request.params:
if request.params['ipv6_default_prefix_length'].strip() != '':
p.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']
try:
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
return json.dumps(p, cls=NipapJSONEncoder)