本文整理汇总了Python中pynipap.Pool.get方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.get方法的具体用法?Python Pool.get怎么用?Python Pool.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pynipap.Pool
的用法示例。
在下文中一共展示了Pool.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit_pool(self, id):
""" Edit a pool.
"""
# extract attributes
p = Pool.get(int(id))
if 'name' in request.params:
p.name = request.params.get('name')
if 'description' in request.params:
p.description = request.params.get('description')
if 'default_type' in request.params:
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']
else:
p.ipv4_default_prefix_length = None
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']
else:
p.ipv6_default_prefix_length = None
if 'tags' in request.params:
p.tags = json.loads(request.params['tags'])
if 'avps' in request.params:
p.avps = json.loads(request.params['avps'])
try:
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例2: edit_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit_pool(self, id):
""" Edit a pool.
"""
# extract attributes
p = Pool.get(int(id))
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: remove
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def remove(self, id):
""" Remove pool.
"""
p = Pool.get(int(id))
p.remove()
redirect(url(controller = 'pool', action = 'list'))
示例4: edit
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit(self, id):
""" Edit a pool.
"""
c.pool = Pool.get(int(id))
c.prefix_list = Prefix.list({ 'pool_id': c.pool.id })
c.prefix = ''
# save changes to NIPAP
if request.method == 'POST':
c.pool.name = request.params['name']
c.pool.description = request.params['description']
c.pool.default_type = request.params['default_type']
if request.params['ipv4_default_prefix_length'].strip() == '':
c.pool.ipv4_default_prefix_length = None
else:
c.pool.ipv4_default_prefix_length = request.params['ipv4_default_prefix_length']
if request.params['ipv6_default_prefix_length'].strip() == '':
c.pool.ipv6_default_prefix_length = None
else:
c.pool.ipv6_default_prefix_length = request.params['ipv6_default_prefix_length']
c.pool.save()
redirect(url(controller = 'pool', action = 'list'))
c.search_opt_parent = 'all'
c.search_opt_child = 'none'
return render("/pool_edit.html")
示例5: edit_prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit_prefix(self, id):
""" Edit a prefix.
"""
try:
p = Prefix.get(int(id))
# extract attributes
if 'prefix' in request.json:
p.prefix = validate_string(request.json, 'prefix')
if 'type' in request.json:
p.type = validate_string(request.json, 'type')
if 'description' in request.json:
p.description = validate_string(request.json, 'description')
if 'expires' in request.json:
p.expires = validate_string(request.json, 'expires')
if 'comment' in request.json:
p.comment = validate_string(request.json, 'comment')
if 'node' in request.json:
p.node = validate_string(request.json, 'node')
if 'status' in request.json:
p.status = validate_string(request.json, 'status')
if 'pool' in request.json:
if request.json['pool'] is None:
p.pool = None
else:
try:
p.pool = Pool.get(int(request.json['pool']))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
if 'alarm_priority' in request.json:
p.alarm_priority = validate_string(request.json, 'alarm_priority')
if 'monitor' in request.json:
if request.json['monitor'] == 'true':
p.monitor = True
else:
p.monitor = False
if 'country' in request.json:
p.country = validate_string(request.json, 'country')
if 'order_id' in request.json:
p.order_id = validate_string(request.json, 'order_id')
if 'customer_id' in request.json:
p.customer_id = validate_string(request.json, 'customer_id')
if 'vrf' in request.json:
try:
if request.json['vrf'] is None or len(unicode(request.json['vrf'])) == 0:
p.vrf = None
else:
p.vrf = VRF.get(int(request.json['vrf']))
except ValueError:
return json.dumps({'error': 1, 'message': "Invalid VRF ID '%s'" % request.json['vrf']})
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例6: remove_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def remove_pool(self, id):
""" Remove a pool.
"""
try:
pool = Pool.get(int(id))
pool.remove()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例7: remove
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def remove(self, id):
""" Remove pool.
"""
if 'schema' not in request.params:
redirect(url(controller = 'schema', action = 'list'))
schema = Schema.get(int(request.params['schema']))
p = Pool.get(schema, int(id))
p.remove()
redirect(url(controller = 'pool', action = 'list', schema = schema.id))
示例8: add_prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def add_prefix(self, prefix, type, description, tags=[], pool_id=None):
p = Prefix()
p.prefix = prefix
p.type = type
p.description = description
p.tags = tags
if pool_id:
pool = Pool.get(pool_id)
p.pool = pool
p.save()
return p
示例9: add_prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def add_prefix(self, id):
""" Add a prefix to pool 'id'
"""
if 'prefix' not in request.params:
abort(400, 'Missing prefix.')
pool = Pool.get(int(id))
prefix = Prefix.get(int(request.params['prefix']))
prefix.pool = pool
prefix.save()
redirect(url(controller = 'pool', action = 'edit', id = id))
示例10: validate_string
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
p.description = validate_string(request.json, 'description')
if 'expires' in request.json:
p.expires = validate_string(request.json, 'expires')
if 'comment' in request.json:
p.comment = validate_string(request.json, 'comment')
if 'node' in request.json:
p.node = validate_string(request.json, 'node')
if 'status' in request.json:
p.status = validate_string(request.json, 'status')
if 'type' in request.json:
p.type = validate_string(request.json, 'type')
if 'pool' in request.json:
if request.json['pool'] is not None:
try:
p.pool = Pool.get(int(request.json['pool']))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
if 'country' in request.json:
p.country = validate_string(request.json, 'country')
if 'order_id' in request.json:
p.order_id = validate_string(request.json, 'order_id')
if 'customer_id' in request.json:
p.customer_id = validate_string(request.json, 'customer_id')
if 'alarm_priority' in request.json:
p.alarm_priority = validate_string(request.json, 'alarm_priority')
if 'monitor' in request.json:
if request.json['monitor'] == 'true':
p.monitor = True
else:
示例11: edit_prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit_prefix(self, id):
""" Edit a prefix.
"""
try:
p = Prefix.get(int(id))
# extract attributes
if 'prefix' in request.params:
p.prefix = request.params['prefix']
if 'type' in request.params:
p.type = request.params['type'].strip()
if 'description' in request.params:
if request.params['description'].strip() == '':
p.description = None
else:
p.description = request.params['description'].strip()
if 'expires' in request.params:
if request.params['expires'].strip() == '':
p.expires = None
else:
p.expires = request.params['expires'].strip(' "')
if 'comment' in request.params:
if request.params['comment'].strip() == '':
p.comment = None
else:
p.comment = request.params['comment'].strip()
if 'node' in request.params:
if request.params['node'].strip() == '':
p.node = None
else:
p.node = request.params['node'].strip()
if 'status' in request.params:
p.status = request.params['status'].strip()
if 'pool' in request.params:
if request.params['pool'].strip() == '':
p.pool = None
else:
try:
p.pool = Pool.get(int(request.params['pool']))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
if 'alarm_priority' in request.params:
p.alarm_priority = request.params['alarm_priority'].strip()
if 'monitor' in request.params:
if request.params['monitor'] == 'true':
p.monitor = True
else:
p.monitor = False
if 'country' in request.params:
if request.params['country'].strip() == '':
p.country = None
else:
p.country = request.params['country'].strip()
if 'order_id' in request.params:
if request.params['order_id'].strip() == '':
p.order_id = None
else:
p.order_id = request.params['order_id'].strip()
if 'customer_id' in request.params:
if request.params['customer_id'].strip() == '':
p.customer_id = None
else:
p.customer_id = request.params['customer_id'].strip()
if 'vrf' in request.params:
try:
if request.params['vrf'] is None or len(request.params['vrf']) == 0:
p.vrf = None
else:
p.vrf = VRF.get(int(request.params['vrf']))
except ValueError:
return json.dumps({'error': 1, 'message': "Invalid VRF ID '%s'" % request.params['vrf']})
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例12: type
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
p.comment = request.params['comment'].strip()
if 'node' in request.params:
if request.params['node'].strip() != '':
p.node = request.params['node'].strip()
if 'status' in request.params:
p.status = request.params['status'].strip()
if 'type' in request.params:
p.type = request.params['type'].strip()
if 'pool' in request.params:
if request.params['pool'].strip() != '':
try:
p.pool = Pool.get(int(request.params['pool']))
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
if 'country' in request.params:
if request.params['country'].strip() != '':
p.country = request.params['country'].strip()
if 'order_id' in request.params:
if request.params['order_id'].strip() != '':
p.order_id = request.params['order_id'].strip()
if 'customer_id' in request.params:
if request.params['customer_id'].strip() != '':
p.customer_id = request.params['customer_id'].strip()
示例13: test_list_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def test_list_pool(self):
""" We should be able to execute list_pool as read-only user
"""
with self.assertRaises(NipapNonExistentError):
p = Pool.get(0)
示例14: edit_prefix
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
def edit_prefix(self, id):
""" Edit a prefix.
"""
try:
schema = Schema.get(int(request.params['schema']))
p = Prefix.get(schema, int(id))
# extract attributes
if 'prefix' in request.params:
p.prefix = request.params['prefix']
if 'description' in request.params:
p.description = request.params['description']
if 'comment' in request.params:
if request.params['comment'].strip() == '':
p.comment = None
else:
p.comment = request.params['comment']
if 'node' in request.params:
if request.params['node'].strip() == '':
p.node = None
else:
p.node = request.params['node']
if 'pool' in request.params:
if request.params['pool'].strip() == '':
p.pool = None
else:
p.pool = Pool.get(schema, int(request.params['pool']))
if 'alarm_priority' in request.params:
p.alarm_priority = request.params['alarm_priority']
if 'monitor' in request.params:
if request.params['monitor'] == 'true':
p.monitor = True
else:
p.monitor = False
if 'country' in request.params:
if request.params['country'].strip() == '':
p.country = None
else:
p.country = request.params['country']
if 'order_id' in request.params:
if request.params['order_id'].strip() == '':
p.order_id = None
else:
p.order_id = request.params['order_id']
if 'vrf' in request.params:
if request.params['vrf'].strip() == '':
p.vrf = None
else:
p.vrf = request.params['vrf']
p.save()
except NipapError, e:
return json.dumps({'error': 1, 'message': e.args, 'type': type(e).__name__})
示例15: edit_pool
# 需要导入模块: from pynipap import Pool [as 别名]
# 或者: from pynipap.Pool import get [as 别名]
return json.dumps(p, cls=NipapJSONEncoder)
def edit_pool(self, id):
""" Edit 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.get(c.schema, int(id))
if 'name' in request.params:
p.name = request.params.get('name')
if 'description' in request.params:
p.description = request.params.get('description')
if 'default_type' in request.params:
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']
else:
p.ipv4_default_prefix_length = None
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']
else: