Exemplo n.º 1
0
def deployConfig():  #
    """Deploy a given configuration (using db id) to a tsn controller running on same system.
    :return: redirect to deployment overview
    """
    id = request.args.get("id")
    db = get_db()
    data = db.execute("SELECT configuration FROM configurations WHERE id=%s" %
                      (id)).fetchone()
    jsonData = json.loads(data["configuration"])
    for entry in jsonData:
        uuid = entry["uuid"]
        print(uuid)
        switchData = db.execute("SELECT * FROM switches WHERE uuid='%s'" %
                                (uuid)).fetchone()
        ovsData = dict()
        ovsData["dpid"] = switchData["dpid"]
        fpgaData = dict()
        fpgaData["host"] = switchData["ip"]
        fpgaData["port"] = int(switchData["port"])
        fpgaData["username"] = switchData["username"]
        fpgaData["password"] = switchData["password"]
        fpgaData["sw_type"] = "trustnodev1"
        entry["fpga_sw_data"] = fpgaData
        entry["ovs_sw_data"] = ovsData
    print(jsonData)
    requests.post("http://localhost:9090/setConfiguration", json=jsonData)
    return redirect("/controlling/deployment")
Exemplo n.º 2
0
def getConfiguration():
    id = request.args.get("id")
    db = get_db()
    data = db.execute(
        "SELECT id, name, description, configuration FROM configurations WHERE id="
        + str(id)).fetchone()
    print(data["name"])
    return render_template("/engineering/config/editConfig.html", data=data)
Exemplo n.º 3
0
def storeFPGAFlowControlRule():
    name = request.form["template-name"]
    configuration = request.form["dataset"]
    db = get_db()
    cmd = "INSERT INTO fpga_templates (name, template) VALUES (?,?);"
    db.execute(cmd, (name, configuration))
    db.commit()
    return "200 - OK!"
Exemplo n.º 4
0
def deployment_start_page():
    """Show overview of deployable configurations.
    :return: rendered html page
    """
    db = get_db()
    data = db.execute(
        "SELECT id, name, description FROM configurations").fetchall()
    return render_template("controller/deployment/configurationsToDeploy.html",
                           data=data)
Exemplo n.º 5
0
def storeConfig():
    name = request.form["config-name"]
    configuration = request.form["dataset"]
    description = request.form["config-desc"]
    db = get_db()
    cmd = "INSERT INTO configurations (name, description, configuration) VALUES (?,?,?);"
    print(cmd)
    db.execute(cmd, (name, description, configuration))
    db.commit()
    return "200 - OK!"
Exemplo n.º 6
0
def updateConfig():
    name = request.form["config-name"]
    configuration = request.form["dataset"]
    description = request.form["config-desc"]
    id = request.form["config-id"]
    db = get_db()
    cmd = "UPDATE configurations SET name=?, description=?, configuration=? WHERE id=?;"
    print(cmd)
    db.execute(cmd, (name, description, configuration, id))
    db.commit()
    return "200 - OK!"
def insertNewSwitch():
    name = request.form['name']
    ip = request.form['ip']
    uuid = request.form['uuid']
    username = request.form['username']
    password = request.form['password']
    port = request.form['port']
    devicetype = request.form['devicetype']
    dpid = request.form["dpid"]
    db = get_db()
    if request.args.get("id") == "":
        cmd = "INSERT INTO switches (name, uuid, ip, port, username, password, dpid, devicetype) VALUES (?,?,?,?,?,?,?, ?);"
        print(cmd)
        db.execute(
            cmd, (name, uuid, ip, port, username, password, dpid, devicetype))
        db.commit()
    else:
        cmd = "UPDATE switches SET name=?,  uuid=?, ip=?, port=?, username=?, password=?, devicetype=?, dpid=? WHERE id=?;"
        db.execute(cmd,
                   (name, uuid, ip, port, username, password, devicetype, dpid,
                    request.args.get("id")))
        db.commit()
    return redirect("/controlling/router")
def editSwitch():
    id = request.args.get("id")
    db = get_db()
    data = db.execute('SELECT * FROM switches WHERE id=%s' % id).fetchone()
    print(data)
    return render_template("controller/switch/addNewSwitch.html", data=data)
def routerOverview():
    db = get_db()
    switches = db.execute('SELECT * FROM switches').fetchall()
    return render_template("controller/switch/switches.html",
                           switches=switches)
Exemplo n.º 10
0
def getFilterRecipe():
    db = get_db()

    return render_template("/engineering/config/filtering.html")
Exemplo n.º 11
0
def addNewConfiguration():
    db = get_db()
    fpgaTemplates = db.execute("SELECT * FROM fpga_templates").fetchall()
    return render_template("engineering/config/createNewConfig.html",
                           fpgaTemplates=fpgaTemplates)
Exemplo n.º 12
0
def config_start_page():
    db = get_db()
    data = db.execute(
        "SELECT id, name, description FROM configurations").fetchall()
    print(data)
    return render_template("engineering/index.html", data=data)