当前位置: 首页>>代码示例>>Python>>正文


Python Server.get_servers方法代码示例

本文整理汇总了Python中pritunl.server.Server.get_servers方法的典型用法代码示例。如果您正苦于以下问题:Python Server.get_servers方法的具体用法?Python Server.get_servers怎么用?Python Server.get_servers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pritunl.server.Server的用法示例。


在下文中一共展示了Server.get_servers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run_wsgi

# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_servers [as 别名]
    def _run_wsgi(self):
        self._setup_server_cert()
        import cherrypy.wsgiserver
        import cherrypy.wsgiserver.ssl_builtin
        from log_entry import LogEntry
        logger.info('Starting server...')

        if self.auto_start_servers != False:
            from pritunl.server import Server
            for server in Server.get_servers():
                if server.get_orgs():
                    server.start()

        server = cherrypy.wsgiserver.CherryPyWSGIServer(
            (self.bind_addr, self.port), self.app)
        server.ssl_adapter = cherrypy.wsgiserver.ssl_builtin.BuiltinSSLAdapter(
            self._server_cert_path, self._server_key_path)
        try:
            server.start()
        except (KeyboardInterrupt, SystemExit), exc:
            signal.signal(signal.SIGINT, signal.SIG_IGN)
            LogEntry(message='Web server stopped.')
            self.interrupt = True
            logger.info('Stopping server...')
            server.stop()
            self._close_db()
开发者ID:cDoru,项目名称:pritunl,代码行数:28,代码来源:app_server.py

示例2: status_get

# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_servers [as 别名]
def status_get():
    orgs = Organization.get_orgs()
    orgs_count = len(orgs)

    servers_count = 0
    servers_online_count = 0
    clients_count = 0
    for server in Server.get_servers():
        servers_count += 1
        if server.status:
            servers_online_count += 1
        clients_count += len(server.get_clients())

    users_count = 0
    for org in orgs:
        for user in org.get_users():
            if user.type != CERT_CLIENT:
                continue
            users_count += 1

    if not app_server.public_ip:
        app_server.load_public_ip()

    return utils.jsonify({
        'orgs_available': orgs_count,
        'orgs_total': orgs_count,
        'users_online': clients_count,
        'users_total': users_count,
        'servers_online': servers_online_count,
        'servers_total': servers_count,
        'server_version': __version__,
        'public_ip': app_server.public_ip,
    })
开发者ID:CorbettBaker-Company,项目名称:pritunl,代码行数:35,代码来源:status.py

示例3: server_get

# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_servers [as 别名]
def server_get():
    servers = []
    servers_dict = {}
    servers_sort = []

    for server in Server.get_servers():
        server_orgs = server.get_orgs()
        users_count = 0
        for org in server_orgs:
            for user in org.get_users():
                if user.type != CERT_CLIENT:
                    continue
                users_count += 1

        name_id = '%s_%s' % (server.name, server.id)
        servers_sort.append(name_id)
        servers_dict[name_id] = {
            'id': server.id,
            'name': server.name,
            'status': 'online' if server.status else 'offline',
            'uptime': server.uptime,
            'users_online': len(server.get_clients()),
            'users_total': users_count,
            'network': server.network,
            'interface': server.interface,
            'port': server.port,
            'protocol': server.protocol,
            'local_network': server.local_network,
            'public_address': server.public_address,
            'otp_auth': True if server.otp_auth else False,
            'lzo_compression': server.lzo_compression,
            'debug': True if server.debug else False,
            'org_count': len(server_orgs),
        }

    for name_id in sorted(servers_sort):
        servers.append(servers_dict[name_id])

    return utils.jsonify(servers)
开发者ID:CorbettBaker-Company,项目名称:pritunl,代码行数:41,代码来源:server.py

示例4: server_put_post

# 需要导入模块: from pritunl.server import Server [as 别名]
# 或者: from pritunl.server.Server import get_servers [as 别名]

#.........这里部分代码省略.........
    except ValueError:
        return _interface_not_valid()

    if interface_num > 64:
        return _interface_not_valid()

    interface = interface[:3] + str(interface_num)

    # Port
    try:
        port = int(port)
    except ValueError:
        return _port_not_valid()

    if port < 1 or port > 65535:
        return _port_not_valid()

    # Protocol
    if protocol not in ['udp', 'tcp']:
        return utils.jsonify({
            'error': PROTOCOL_NOT_VALID,
            'error_msg': PROTOCOL_NOT_VALID_MSG,
        }, 400)

    # Local network
    if local_network:
        local_network_split = local_network.split('/')
        if len(local_network_split) != 2:
            return _local_network_not_valid()

        address = local_network_split[0].split('.')
        if len(address) != 4:
            return _local_network_not_valid()
        for i, value in enumerate(address):
            try:
                address[i] = int(value)
            except ValueError:
                return _local_network_not_valid()
        if address[0] > 255 or address[0] < 0 or \
                address[1] > 255 or address[1] < 0 or \
                address[2] > 255 or address[2] < 0 or \
                address[3] > 254 or address[3] < 0:
            return _local_network_not_valid()

        try:
            subnet = int(local_network_split[1])
        except ValueError:
            return _local_network_not_valid()

        if subnet < 8 or subnet > 30:
            return _local_network_not_valid()

    for server in Server.get_servers():
        if server.id == server_id:
            continue
        elif server.network == network:
            return utils.jsonify({
                'error': NETWORK_IN_USE,
                'error_msg': NETWORK_IN_USE_MSG,
            }, 400)
        elif server.interface == interface:
            return utils.jsonify({
                'error': INTERFACE_IN_USE,
                'error_msg': INTERFACE_IN_USE_MSG,
            }, 400)
        elif server.port == port and server.protocol == protocol:
            return utils.jsonify({
                'error': PORT_PROTOCOL_IN_USE,
                'error_msg': PORT_PROTOCOL_IN_USE_MSG,
            }, 400)

    if not server_id:
        server = Server(
            name=name,
            network=network,
            interface=interface,
            port=port,
            protocol=protocol,
            local_network=local_network,
            public_address=public_address,
            debug=debug,
        )
    else:
        server = Server(id=server_id)
        if server.status:
            return utils.jsonify({
                'error': SERVER_NOT_OFFLINE,
                'error_msg': SERVER_NOT_OFFLINE_MSG,
            }, 400)
        server.name = name
        server.network = network
        server.interface = interface
        server.port = port
        server.protocol = protocol
        server.local_network = local_network
        server.public_address = public_address
        server.debug = debug
        server.commit()

    return utils.jsonify({})
开发者ID:cDoru,项目名称:pritunl,代码行数:104,代码来源:server.py


注:本文中的pritunl.server.Server.get_servers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。