コード例 #1
0
ファイル: agents.py プロジェクト: guidow/pyfarm-master
def restart_multiple_agents():
    agent_ids = request.form.getlist("agent_id")

    agents = []
    for agent_id in agent_ids:
        agent = Agent.query.filter_by(id=agent_id).first()
        if not agent:
            return (render_template(
                        "pyfarm/error.html",
                        error="Agent %s not found" % agent_id),
                    NOT_FOUND)

        agent.restart_requested = True
        db.session.add(agent)
        agents.append(agent)

    db.session.commit()

    for agent in agents:
        restart_agent.delay(agent.id)

    flash("Selected agents will be restarted.")

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("agents_index_ui"), SEE_OTHER)
コード例 #2
0
ファイル: agents.py プロジェクト: guidow/pyfarm-master
def restart_single_agent(agent_id):
    agent = Agent.query.filter_by(id=agent_id).first()
    if not agent:
        return (render_template(
                    "pyfarm/error.html", error="Agent %s not found" % agent_id),
                NOT_FOUND)

    agent.restart_requested = True
    db.session.add(agent)
    db.session.commit()

    restart_agent.delay(agent.id)

    flash("Agent %s will be restarted" % agent.hostname)

    if "next" in request.args:
        return redirect(request.args.get("next"), SEE_OTHER)
    else:
        return redirect(url_for("agents_index_ui"), SEE_OTHER)