Пример #1
0
def add():
    if request.method == "GET":
        overlays = enumerate(sorted(os.listdir(app.config["OVERLAY_DIR"])))
        nodes = get_nodes(None)
        freeNodes = [
            node for node in nodes
            if (node.reachable == True and node.available == True)
        ]
        return render_template("experiment/add.html",
                               freeNodes=freeNodes,
                               overlays=overlays)
    elif request.method == "POST":
        try:
            try:
                name = request.form["name"]

                if not name:
                    raise Exception("Invalid name")
            except KeyError:
                raise Exception("Name not specified")

            try:
                overlay = request.form["overlay"]
            except KeyError:
                raise Exception("Overlay not selected")

            overlayFile = None

            if overlay == "NEW":
                try:
                    overlayFile = request.files["overlay_file"]
                    overlay = secure_filename(overlayFile.filename)
                    overlayFile.save(
                        os.path.join(app.config["OVERLAY_DIR"], overlay))
                except KeyError:
                    raise Exception("Invalid overlay uploaded")

            try:
                nodes = Node.query.filter(
                    Node.id.in_(request.form.getlist("nodeIds"))).all()

                if not nodes:
                    raise KeyError
            except KeyError:
                raise Exception("Can't setup an experiment with no nodes")

            experiment = Experiment(name, overlay, nodes)
            db.session.add(experiment)
            db.session.commit()
            flash("Experiment '%s' added successfully" % name)
            return redirect(url_for(".show", id=experiment.id))
        except Exception as e:
            db.session.rollback()
            flash("Failed to add experiment: %s" % str(e))
            return redirect(url_for(".add"))
Пример #2
0
def index():
    commands = Command.query.filter(Command.experimentId == None).all()

    # Example how to use get_nodes
    #availNodes = get_nodes("Node.available == True")
    # Show available nodes and also those in error state so you can run
    # commands to them
    tempNodes = get_nodes(None)
    nodes = [node for node in tempNodes if (node.available == True or node.status.name == "ERROR")]
    return render_template("admin/index.html", commands=commands,\
			nodes=nodes)
Пример #3
0
def add():
    if request.method == "GET":
        overlays = enumerate(sorted(os.listdir(app.config["OVERLAY_DIR"])))
	nodes = get_nodes(None)
	freeNodes = [node for node in nodes if (node.reachable == True and node.available == True)]
        return render_template("experiment/add.html", freeNodes=freeNodes, 
                overlays=overlays)
    elif request.method == "POST":
        try:
            try:
                name = request.form["name"]

                if not name:
                    raise Exception("Invalid name")
            except KeyError:
                raise Exception("Name not specified")

            try:
                overlay = request.form["overlay"]
            except KeyError:
                raise Exception("Overlay not selected")

            overlayFile = None

            if overlay == "NEW":
                try:
                    overlayFile = request.files["overlay_file"]
                    overlay = secure_filename(overlayFile.filename)
                    overlayFile.save(os.path.join(app.config["OVERLAY_DIR"], 
                        overlay))
                except KeyError:
                    raise Exception("Invalid overlay uploaded")

            try:
                nodes = Node.query.filter(Node.id.in_(request.form.getlist("nodeIds"))).all()

                if not nodes:
                    raise KeyError
            except KeyError:
                raise Exception("Can't setup an experiment with no nodes")

            experiment = Experiment(name, overlay, nodes)
            db.session.add(experiment)
            db.session.commit()
            flash("Experiment '%s' added successfully" % name)
            return redirect(url_for(".show", id=experiment.id))
        except Exception as e:
            db.session.rollback()
            flash("Failed to add experiment: %s" % str(e))
            return redirect(url_for(".add"))
Пример #4
0
def index():
    commands = Command.query.filter(Command.experimentId == None).all()

    # Example how to use get_nodes
    #availNodes = get_nodes("Node.available == True")
    # Show available nodes and also those in error state so you can run
    # commands to them
    tempNodes = get_nodes(None)
    nodes = [
        node for node in tempNodes if (node.reachable == True and (
            node.available == True or node.status.name == "ERROR"))
    ]
    return render_template("admin/index.html", commands=commands,\
   nodes=nodes)
Пример #5
0
def list():
    return render_template("node/list.html", nodes=get_nodes(None))
Пример #6
0
def list():
    return render_template("node/list.html", nodes=get_nodes(None))