本文整理汇总了Python中pritunl.server.Server.get_server方法的典型用法代码示例。如果您正苦于以下问题:Python Server.get_server方法的具体用法?Python Server.get_server怎么用?Python Server.get_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pritunl.server.Server
的用法示例。
在下文中一共展示了Server.get_server方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: server_delete
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_delete(server_id):
server = Server.get_server(id=server_id)
server.remove()
LogEntry(message='Deleted 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({})
示例2: server_org_delete
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_delete(server_id, org_id):
server = Server.get_server(id=server_id)
if server.status:
return utils.jsonify({
'error': SERVER_NOT_OFFLINE,
'error_msg': SERVER_NOT_OFFLINE_DETACH_ORG_MSG,
}, 400)
server.remove_org(org_id)
return utils.jsonify({})
示例3: server_org_get
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_get(server_id):
orgs = []
server = Server.get_server(id=server_id)
for org in server.iter_orgs():
orgs.append({
'id': org.id,
'server': server.id,
'name': org.name,
})
return utils.jsonify(orgs)
示例4: server_get
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_get(server_id=None):
if server_id:
return utils.jsonify(Server.get_server(server_id).dict())
else:
servers = []
servers_dict = {}
servers_sort = []
for server in Server.iter_servers():
servers.append(server.dict())
return utils.jsonify(servers)
示例5: server_org_put
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_put(server_id, org_id):
server = Server.get_server(id=server_id)
if server.status:
return utils.jsonify({
'error': SERVER_NOT_OFFLINE,
'error_msg': SERVER_NOT_OFFLINE_ATTACH_ORG_MSG,
}, 400)
org = server.add_org(org_id)
return utils.jsonify({
'id': org.id,
'server': server.id,
'name': org.name,
})
示例6: server_org_delete
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_delete(server_id, org_id):
server = Server.get_server(id=server_id)
org = Organization.get_org(id=org_id)
if server.status:
return utils.jsonify({
'error': SERVER_NOT_OFFLINE,
'error_msg': SERVER_NOT_OFFLINE_DETACH_ORG_MSG,
}, 400)
server.remove_org(org)
server.commit()
Event(type=SERVERS_UPDATED)
Event(type=SERVER_ORGS_UPDATED, resource_id=server.id)
Event(type=USERS_UPDATED, resource_id=org.id)
return utils.jsonify({})
示例7: server_operation_put
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_operation_put(server_id, operation):
server = Server.get_server(id=server_id)
if operation == START:
server.start()
LogEntry(message='Started server "%s".' % server.name)
if operation == STOP:
server.stop()
LogEntry(message='Stopped server "%s".' % server.name)
elif operation == RESTART:
server.restart()
LogEntry(message='Restarted server "%s".' % server.name)
Event(type=SERVERS_UPDATED)
return utils.jsonify(server.dict())
示例8: server_operation_put
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_operation_put(server_id, operation):
server = Server.get_server(id=server_id)
try:
if operation == START:
server.start()
if operation == STOP:
server.stop()
elif operation == RESTART:
server.restart()
except NodeConnectionError:
return utils.jsonify({"error": NODE_CONNECTION_ERROR, "error_msg": NODE_CONNECTION_ERROR_MSG}, 400)
except InvalidNodeAPIKey:
return utils.jsonify({"error": NODE_API_KEY_INVLID, "error_msg": NODE_API_KEY_INVLID_MSG}, 400)
return utils.jsonify(server.dict())
示例9: server_org_put
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_put(server_id, org_id):
server = Server.get_server(id=server_id)
org = Organization.get_org(id=org_id)
if server.status:
return utils.jsonify({
'error': SERVER_NOT_OFFLINE,
'error_msg': SERVER_NOT_OFFLINE_ATTACH_ORG_MSG,
}, 400)
server.add_org(org)
server.commit()
Event(type=SERVERS_UPDATED)
Event(type=SERVER_ORGS_UPDATED, resource_id=server.id)
Event(type=USERS_UPDATED, resource_id=org.id)
return utils.jsonify({
'id': org.id,
'server': server.id,
'name': org.name,
})
示例10: server_output_delete
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_output_delete(server_id):
server = Server.get_server(id=server_id)
server.clear_output()
return utils.jsonify({})
示例11: server_output_get
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_output_get(server_id):
server = Server.get_server(id=server_id)
return utils.jsonify({
'id': server.id,
'output': server.get_output(),
})
示例12: server_org_put
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_org_put(server_id, org_id):
server = Server.get_server(id=server_id)
if server.status:
return utils.jsonify({"error": SERVER_NOT_OFFLINE, "error_msg": SERVER_NOT_OFFLINE_ATTACH_ORG_MSG}, 400)
org = server.add_org(org_id)
return utils.jsonify({"id": org.id, "server": server.id, "name": org.name})
示例13: server_delete
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_delete(server_id):
server = Server.get_server(id=server_id)
server.remove()
return utils.jsonify({})
示例14: server_put_post
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
#.........这里部分代码省略.........
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:
if type == NODE_SERVER:
server = NodeServer(
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,
public_address=public_address,
otp_auth=otp_auth,
lzo_compression=lzo_compression,
debug=debug,
node_host=node_host,
node_port=node_port,
node_key=node_key,
)
else:
server = 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,
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:
server.dh_param_bits = dh_param_bits
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 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
if server.type == NODE_SERVER:
if node_host_def:
server.node_host = node_host
if node_port_def:
server.node_port = node_port
if node_key_def:
server.node_key = node_key
server.commit()
for org in server.iter_orgs():
Event(type=USERS_UPDATED, resource_id=org.id)
return utils.jsonify(server.dict())
示例15: server_output_get
# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_server [as 别名]
def server_output_get(server_id):
server = Server.get_server(id=server_id)
return utils.jsonify({"id": server.id, "output": server.get_output()})