本文整理匯總了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())