Beispiel #1
0
def oxauth_server():
    if request.method == "POST":
        hostname = request.form.get("hostname")
        gluu_server = request.form.get("gluu_server")

        if gluu_server == "true":
            gluu_server = True
        else:
            gluu_server = False

        if not hostname:
            return jsonify({
                "status": 400,
                "message": "Invalid data",
                "params": "hostname can't be empty",
            }), 400

        server = Server()
        server.hostname = hostname
        server.gluu_server = gluu_server
        db.session.add(server)
        db.session.commit()
        return jsonify({
            "id": server.id,
            "hostname": server.hostname,
            "gluu_server": server.gluu_server,
        }), 201

    servers = [{
        "id": srv.id,
        "hostname": srv.hostname,
        "gluu_server": srv.gluu_server,
    } for srv in Server.query]
    return jsonify(servers)
Beispiel #2
0
    def test_db_with_data_loads_dashboard(self):
        s1 = Server()
        s1.hostname = 'test.example.com'
        s1.gluu_server = True
        s1.ip = '0.0.0.0'
        with self.app.app_context():
            db.session.add(s1)
            db.session.commit()

        rv = self.client.get('/')
        self.assertIn('Dashboard', rv.data)
        self.assertIn('test.example.com', rv.data)
Beispiel #3
0
def index():
    """Route for URL /server/. GET returns ServerForm to add a server,
    POST accepts the ServerForm, validates and creates a new Server object
    """
    appconfig = AppConfiguration.query.first()
    if not appconfig:
        flash(
            "Kindly set default values for the application before adding"
            " servers.", "info")
        return redirect(url_for('index.app_configuration', next="/server/"))
    form = ServerForm()

    pr_server = get_primary_server_id()
    if pr_server:
        form.primary_server.render_kw = {'disabled': 'disabled'}

    if form.validate_on_submit():
        server = Server()
        server.gluu_server = form.gluu_server.data
        server.hostname = form.hostname.data
        server.ip = form.ip.data
        server.ldap_password = form.ldap_password.data
        server.mmr = False
        server.primary_server = form.primary_server.data
        db.session.add(server)
        db.session.commit()

        # start the background job to get system details
        collect_server_details.delay(server.id)
        return redirect(url_for('index.home'))

    flash(
        'Cluster Manager will connect to this server via SSH to perform its'
        ' tasks. Ensure the server running Cluster Manager has'
        '"Password-less" SSH access via shared keys to the server.', 'info')
    return render_template('new_server.html', form=form, header="New Server")