예제 #1
0
def get_users():
    start, count = paginate()
    users = OpenVPNUser.get_all(start, count)
    total = OpenVPNUser.get_total_nums()
    total_page = math.ceil(total / count)
    page = get_page_from_query()
    return json_res(count=count, page=page, total=total, total_page=total_page, items=users)
예제 #2
0
def delete_openvpnuser():
    form = CreateUserForm().validate_for_api()
    result = OpenVPNUser.delete_user(form)
    if result is True:
        command = ["/usr/local/bin/vpnuser", "del", form.username.data]
        command = ' '.join(str(d) for d in command)
        remote_server.onetime_shell(command)
        return Success(msg='注销成功')
예제 #3
0
def get_user(vid):
    user = OpenVPNUser.get_detail(vid)
    return jsonify(user)
예제 #4
0
def get_totalusers():
    totalusers = OpenVPNUser.get_total_nums()
    return jsonify(totalusers)