Esempio n. 1
0
def delete(peer_id):
    """ Delete peer """
    peer = PeerController.get(peer_id)

    if not peer:
        return jsonify(error='Peer not found'), 500

    PeerController.delete(peer)

    return jsonify()
Esempio n. 2
0
def delete(peer_id):
    """ Delete peer """
    peer = PeerController.get(peer_id)

    if not peer:
        return jsonify(error='Peer not found'), 500

    PeerController.delete(peer)

    return jsonify()
Esempio n. 3
0
def get(peer_id):
    """ Get peer """
    peer = PeerController.get(peer_id)

    if not peer:
        return jsonify(error='Peer not found'), 500

    return jsonify(peer=serialize_sqla(peer))
Esempio n. 4
0
def create():
    """ Create new peer """
    if request.json['secret'] != app.config['CLIENT_HANDSHAKE']:
        return jsonify(), 401

    peer = PeerController.create(request.remote_addr)

    return jsonify(id=peer.id)
Esempio n. 5
0
def get(peer_id):
    """ Get peer """
    peer = PeerController.get(peer_id)

    if not peer:
        return jsonify(error='Peer not found'), 500

    return jsonify(peer=serialize_sqla(peer))
Esempio n. 6
0
def create():
    """ Create new peer """
    if request.json['secret'] != app.config['CLIENT_HANDSHAKE']:
        return jsonify(), 401

    peer = PeerController.create(request.remote_addr)

    return jsonify(id=peer.id)
Esempio n. 7
0
def get_all():
    """ Get all peers unfiltered """
    peers = PeerController.get_all()

    if not peers:
        return jsonify(error='No peers were found'), 500

    ser_peers = []
    for peer in peers:
        ser_peer = row2dict(peer)
        ser_peer['job'] = None
        if (peer.task):
            ser_peer['job'] = row2dict(peer.task.job)
        ser_peers.append(ser_peer)

    return jsonify(peers=ser_peers)
Esempio n. 8
0
def get_all():
    """ Get all peers unfiltered """
    peers = PeerController.get_all()

    if not peers:
        return jsonify(error='No peers were found'), 500

    ser_peers = []
    for peer in peers:
        ser_peer = row2dict(peer)
        ser_peer['job'] = None
        if(peer.task):
            ser_peer['job'] = row2dict(peer.task.job)
        ser_peers.append(ser_peer)

    return jsonify(peers=ser_peers)
Esempio n. 9
0
def ping(peer_id):
    """ Get ping from peer"""
    load = int(request.json['load'])
    if load > 0 and load <= 100 and peer_id:
        PeerController.ping(peer_id, load)
    return jsonify()
Esempio n. 10
0
def status():
    return render_template('status.htm',
                           data={'peers': PeerController.get_all()})
Esempio n. 11
0
def ping(peer_id):
    """ Get ping from peer"""
    load = int(request.json['load'])
    if load > 0 and load <= 100 and peer_id:
        PeerController.ping(peer_id, load)
    return jsonify()