summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 0a65c17..5be8647 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -237,6 +237,27 @@ def get_server_from_ip_port(str_ip_port):
raise Exception('Server with address ' + str_ip_port + 'is not configured')
+def get_scopes_from_server(server):
+ r = server.get('/scopes')
+ server_scope = {}
+ server_scope['name'] = server.name
+ server_scope['type'] = "server"
+ server_scope['server_ip_port'] = (server.ip + ":" + str(server.port))
+ server_scope.update(r.json())
+ list_scopes = []
+ list_scopes.append(server_scope)
+ scopes = {'scope': list_scopes}
+ if current_user.scopes:
+ allowed_scopes = []
+ get_allowed_scopes(scopes, allowed_scopes)
+ scopes = {'scope': allowed_scopes}
+ r = server.get('/clients')
+ clients = r.json()
+ add_state_and_ips(scopes, clients['clients'], set())
+
+ return scopes
+
+
def get_scopes(ips=set()):
list_scopes = []
responses = multi_request('get', '/scopes')
@@ -410,11 +431,28 @@ def get_client_mac():
return jsonify(pretty_mac)
+@app.route('/ogservers', methods=['GET'])
+@login_required
+def get_ogservers():
+ servers_list = [s.ip + ':' + str(s.port) for s in servers]
+ resp = jsonify(servers_list)
+ return resp
+
+
+@app.route('/scopes-tree', methods=['GET'])
+@login_required
+def scopes_tree():
+ params = request.args.to_dict()
+ server = get_server_from_ip_port(params['server'])
+ scopes = get_scopes_from_server(server)
+ return render_template('tree.html', scopes=scopes)
+
+
@app.route('/scopes/')
@login_required
def scopes():
- scopes, clients = get_scopes()
- return render_template('scopes.html', scopes=scopes, clients=clients)
+ return render_template('scopes.html')
+
@app.route('/action/poweroff', methods=['GET', 'POST'])
@login_required