From fe4852d8179d6abcdf9763c68afbef2eb340dc46 Mon Sep 17 00:00:00 2001 From: William Brown Date: Jan 09 2017 23:08:46 +0000 Subject: Updates to use new lib389 apis Fix Description: Update parts of the rest code to work with the new lib389 apis. Author: wibrown --- diff --git a/rest389-debugserver.py b/rest389-debugserver.py index f1c7d65..c9056b2 100644 --- a/rest389-debugserver.py +++ b/rest389-debugserver.py @@ -5,4 +5,4 @@ from rest389 import rest389app as app if __name__ == '__main__': # THIS IS REALLY DANGEROUS, AND ALLOWS RCE. ONLY USE IN DEVELOPMENT - app.run(debug=True, host='0.0.0.0') + app.run(debug=True, host='0.0.0.0', port=8000) diff --git a/rest389/MonitorResource.py b/rest389/MonitorResource.py index 1fdc723..7003773 100644 --- a/rest389/MonitorResource.py +++ b/rest389/MonitorResource.py @@ -29,9 +29,27 @@ def monitor(ds): return jsonResponse("", 200, request.url) elif request.method == 'GET': - status = ds.monitor.server() + status = ds.monitor.status_json() return jsonResponse(status, 200, request.url) +@monitor_api.route('/v1/monitor/ldbm', methods=['GET', 'HEAD', 'OPTIONS']) +@authenticateConnection +def monitor_ldbm(ds): + + if request.method == 'OPTIONS': + msg = {} + msg['allow'] = 'GET OPTIONS HEAD' + return jsonify(msg) + + elif request.method == 'HEAD': + # Probably should be checking if it exists here ... + return jsonResponse("", 200, request.url) + + elif request.method == 'GET': + status = ds.monitorldbm.status_json() + return jsonResponse(status, 200, request.url) + + # We might make a suffix monitor later, so we leave the namespace clean. @monitor_api.route('/v1/monitor/backend', methods=['GET', 'HEAD', 'OPTIONS']) @@ -49,7 +67,12 @@ def monitor_backends(ds): return jsonResponse("", 200, request.url) elif request.method == 'GET': - status = ds.monitor.backends() + # Get all the backends + bes = ds.backends.list() + # for each, show the monitor? + status = {} + for be in bes: + status[be.rdn] = be.get_monitor().status_json() print(status) return jsonResponse(status, 200, request.url) @@ -69,7 +92,8 @@ def monitor_backend(ds, backend): return jsonResponse("", 200, request.url) elif request.method == 'GET': - status = ds.monitor.backend(backend) + be = ds.backends.get(backend) + status = be.get_monitor().status_json() print(status) return jsonResponse(status, 200, request.url) diff --git a/rest389/templates/perfmon.html b/rest389/templates/perfmon.html index 18585a0..1114381 100644 --- a/rest389/templates/perfmon.html +++ b/rest389/templates/perfmon.html @@ -53,43 +53,41 @@