當前位置: 首頁>>代碼示例>>Python>>正文


Python Server.get_server方法代碼示例

本文整理匯總了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({})
開發者ID:bitland,項目名稱:pritunl,代碼行數:10,代碼來源:server.py

示例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({})
開發者ID:ogrishman,項目名稱:pritunl,代碼行數:11,代碼來源:server.py

示例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)
開發者ID:bitland,項目名稱:pritunl,代碼行數:12,代碼來源:server.py

示例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)
開發者ID:bitland,項目名稱:pritunl,代碼行數:14,代碼來源:server.py

示例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,
    })
開發者ID:ogrishman,項目名稱:pritunl,代碼行數:15,代碼來源:server.py

示例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({})
開發者ID:bitland,項目名稱:pritunl,代碼行數:16,代碼來源:server.py

示例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())
開發者ID:bitland,項目名稱:pritunl,代碼行數:17,代碼來源:server.py

示例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())
開發者ID:WrongChao,項目名稱:pritunl,代碼行數:18,代碼來源:server.py

示例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,
    })
開發者ID:bitland,項目名稱:pritunl,代碼行數:20,代碼來源:server.py

示例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({})
開發者ID:bitland,項目名稱:pritunl,代碼行數:6,代碼來源:server.py

示例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(),
    })
開發者ID:bitland,項目名稱:pritunl,代碼行數:8,代碼來源:server.py

示例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})
開發者ID:WrongChao,項目名稱:pritunl,代碼行數:8,代碼來源:server.py

示例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({})
開發者ID:ogrishman,項目名稱:pritunl,代碼行數:6,代碼來源:server.py

示例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())
開發者ID:WrongChao,項目名稱:pritunl,代碼行數:104,代碼來源:server.py

示例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()})
開發者ID:WrongChao,項目名稱:pritunl,代碼行數:5,代碼來源:server.py


注:本文中的pritunl.server.Server.get_server方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。