本文整理汇总了Python中pritunl.server.Server.new_server方法的典型用法代码示例。如果您正苦于以下问题:Python Server.new_server方法的具体用法?Python Server.new_server怎么用?Python Server.new_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pritunl.server.Server
的用法示例。
在下文中一共展示了Server.new_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: server_put_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import new_server [as 别名]
#.........这里部分代码省略.........
if not port:
return utils.jsonify({
'error': PORT_PROTOCOL_IN_USE,
'error_msg': PORT_PROTOCOL_IN_USE_MSG,
}, 400)
if not dh_param_bits_def:
dh_param_bits_def = True
dh_param_bits = DEFAULT_DH_PARAM_BITS
if not mode_def:
mode_def = True
if local_networks_def and local_networks:
mode = LOCAL_TRAFFIC
else:
mode = ALL_TRAFFIC
if not public_address_def:
public_address_def = True
public_address = app_server.public_ip
if network_def:
if network in network_used:
return utils.jsonify({
'error': NETWORK_IN_USE,
'error_msg': NETWORK_IN_USE_MSG,
}, 400)
if interface_def:
if interface in interface_used:
return utils.jsonify({
'error': INTERFACE_IN_USE,
'error_msg': INTERFACE_IN_USE_MSG,
}, 400)
if port_def:
if '%s%s' % (port, protocol) in port_used:
return utils.jsonify({
'error': PORT_PROTOCOL_IN_USE,
'error_msg': PORT_PROTOCOL_IN_USE_MSG,
}, 400)
if not server_id:
server = Server.new_server(
name=name,
network=network,
interface=interface,
port=port,
protocol=protocol,
dh_param_bits=dh_param_bits,
mode=mode,
local_networks=local_networks,
dns_servers=dns_servers,
search_domain=search_domain,
public_address=public_address,
otp_auth=otp_auth,
lzo_compression=lzo_compression,
debug=debug,
)
else:
server = Server.get_server(id=server_id)
if server.status:
return utils.jsonify({
'error': SERVER_NOT_OFFLINE,
'error_msg': SERVER_NOT_OFFLINE_SETTINGS_MSG,
}, 400)
if name_def:
server.name = name
if network_def:
server.network = network
if interface_def:
server.interface = interface
if port_def:
server.port = port
if protocol_def:
server.protocol = protocol
if dh_param_bits_def and server.dh_param_bits != dh_param_bits:
server.dh_param_bits = dh_param_bits
server.generate_dh_param()
if mode_def:
server.mode = mode
if local_networks_def:
server.local_networks = local_networks
if dns_servers_def:
server.dns_servers = dns_servers
if search_domain_def:
server.search_domain = search_domain
if public_address_def:
server.public_address = public_address
if otp_auth_def:
server.otp_auth = otp_auth
if lzo_compression_def:
server.lzo_compression = lzo_compression
if debug_def:
server.debug = debug
server.commit()
LogEntry(message='Created server "%s".' % server.name)
Event(type=SERVERS_UPDATED)
for org in server.iter_orgs():
Event(type=USERS_UPDATED, resource_id=org.id)
return utils.jsonify(server.dict())