本文整理汇总了Python中pynipap.VRF.name方法的典型用法代码示例。如果您正苦于以下问题:Python VRF.name方法的具体用法?Python VRF.name怎么用?Python VRF.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.VRF
的用法示例。
在下文中一共展示了VRF.name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_load_data
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF 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: test_add_vrf
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import name [as 别名]
def test_add_vrf(self):
""" We should NOT be able to execute add_vrf as read-only user
"""
v = VRF()
v.rt = '123:456'
v.name = 'test'
with self.assertRaises(NipapAuthorizationError):
v.save()
示例3: add_vrf
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import name [as 别名]
def add_vrf(self):
""" Add a new VRF to NIPAP and return its data.
"""
v = VRF()
if 'rt' in request.params:
if request.params['rt'].strip() != '':
v.rt = request.params['rt'].strip()
if 'name' in request.params:
if request.params['name'].strip() != '':
v.name = request.params['name'].strip()
if 'description' in request.params:
v.description = request.params['description']
try:
v.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例4: add
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import name [as 别名]
def add(self):
""" Add a new VRF.
"""
c.action = "add"
if "action" in request.params:
if request.params["action"] == "add":
v = VRF()
if request.params["rt"].strip() != "":
v.rt = request.params["rt"]
if request.params["name"].strip() != "":
v.name = request.params["name"]
v.description = request.params["description"]
v.save()
redirect(url(controller="vrf", action="list"))
return render("/vrf_add.html")
示例5: add_vrf
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import name [as 别名]
def add_vrf(self):
""" Add a new VRF to NIPAP and return its data.
"""
v = VRF()
if 'rt' in request.json:
v.rt = validate_string(request.json, 'rt')
if 'name' in request.json:
v.name = validate_string(request.json, 'name')
if 'description' in request.json:
v.description = validate_string(request.json, 'description')
if 'tags' in request.json:
v.tags = request.json['tags']
if 'avps' in request.json:
v.avps = request.json['avps']
try:
v.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例6: VRF
# 需要导入模块: from pynipap import VRF [as 别名]
# 或者: from pynipap.VRF import name [as 别名]
print "done"
# Create VRFs from Schemas
print "Creating VRFs from Schemas... ",
sql = "SELECT * FROM ip_net_schema"
curs_pg_old.execute(sql)
vrfs = {}
s_vrfs = {}
for r in curs_pg_old:
if r['vrf'] is None:
continue
if re.match('\d+:\d+', r['vrf'].strip()):
v = VRF()
v.rt = r['vrf'].strip()
v.name = r['name'].strip()
try:
v.save()
except NipapError, e:
print "ERR: %s" % str(e)
vrfs[v.rt] = v
s_vrfs[r['id']] = v
print "done"
# Create VRFs from prefixes
print "Creating VRFs from Prefixes... ",
sql = "SELECT DISTINCT(vrf) FROM ip_net_plan WHERE vrf IS NOT NULL"
curs_pg_old.execute(sql)
for r in curs_pg_old:
if re.match('^\d+:\d+$', r['vrf'].strip()):