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


Python Organization.get_servers方法代碼示例

本文整理匯總了Python中pritunl.organization.Organization.get_servers方法的典型用法代碼示例。如果您正苦於以下問題:Python Organization.get_servers方法的具體用法?Python Organization.get_servers怎麽用?Python Organization.get_servers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pritunl.organization.Organization的用法示例。


在下文中一共展示了Organization.get_servers方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: user_get

# 需要導入模塊: from pritunl.organization import Organization [as 別名]
# 或者: from pritunl.organization.Organization import get_servers [as 別名]
def user_get(org_id):
    org = Organization(org_id)
    org_servers = org.get_servers()
    users = []
    users_dict = {}
    users_sort = []
    clients = {}

    for server in org_servers:
        server_clients = server.get_clients()
        for client_id in server_clients:
            client = server_clients[client_id]
            if client_id not in clients:
                clients[client_id] = []
            clients[client_id].append(client['virt_address'])

    for user in org.get_users():
        name_id = '%s_%s' % (user.name, user.id)
        users_sort.append(name_id)
        users_dict[name_id] = {
            'id': user.id,
            'organization': org.id,
            'name': user.name,
            'type': user.type,
            'status': True if user.id in clients else False,
            'virt_addresses': clients[user.id] if user.id in clients else [],
        }

    for name_id in sorted(users_sort):
        users.append(users_dict[name_id])

    return utils.jsonify(users)
開發者ID:cDoru,項目名稱:pritunl,代碼行數:34,代碼來源:user.py

示例2: user_delete

# 需要導入模塊: from pritunl.organization import Organization [as 別名]
# 或者: from pritunl.organization.Organization import get_servers [as 別名]
def user_delete(org_id, user_id):
    org = Organization(org_id)
    user = org.get_user(user_id)
    user_id = user.id
    user.remove()
    for server in org.get_servers():
        server_clients = server.get_clients()
        if user_id in server_clients:
            server.restart()
    return utils.jsonify({})
開發者ID:CorbettBaker-Company,項目名稱:pritunl,代碼行數:12,代碼來源:user.py

示例3: user_get

# 需要導入模塊: from pritunl.organization import Organization [as 別名]
# 或者: from pritunl.organization.Organization import get_servers [as 別名]
def user_get(org_id):
    org = Organization(org_id)
    otp_auth = False
    users = []
    users_dict = {}
    users_sort = []
    clients = {}

    for server in org.get_servers():
        if server.otp_auth:
            otp_auth = True
        server_clients = server.get_clients()
        for client_id in server_clients:
            client = server_clients[client_id]
            if client_id not in clients:
                clients[client_id] = {}
            clients[client_id][server.id] = client

    for user in org.get_users():
        name_id = '%s_%s' % (user.name, user.id)
        users_sort.append(name_id)
        users_dict[name_id] = {
            'id': user.id,
            'organization': org.id,
            'name': user.name,
            'type': user.type,
            'status': True if user.id in clients else False,
            'otp_auth': otp_auth,
            'otp_secret': user.otp_secret,
            'servers': clients[user.id] if user.id in clients else {},
        }

    for name_id in sorted(users_sort):
        users.append(users_dict[name_id])

    return utils.jsonify(users)
開發者ID:gourneau,項目名稱:pritunl,代碼行數:38,代碼來源:user.py


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