diff --git a/repl/__pycache__/utils.cpython-37.pyc b/repl/__pycache__/utils.cpython-37.pyc index 3145f2889d090e0a27fb4ae130fc2127170635ad..5b917dcda2026b7cae198c5f8f6a690f89204b12 100644 Binary files a/repl/__pycache__/utils.cpython-37.pyc and b/repl/__pycache__/utils.cpython-37.pyc differ diff --git a/repl/utils.py b/repl/utils.py index cb6c027c5af5baab4c394f004187ecac1207778a..9e6e432626db2244bbec6fc8ad7fa3038287c425 100644 --- a/repl/utils.py +++ b/repl/utils.py @@ -37,28 +37,28 @@ def gen_count(): yield i i = i + 1 -def get_info(url): +def get_info(url, srv): p = urlparse(url) db = p.path.replace("/","") - host = p.hostname.split(".")[0] + host = p.hostname + host = host.replace("localhost", srv) + host = host.split(".")[0] return db, host def gen_ext_name(d, h): return "{}@{}".format(d, h) -def get_nodes_and_edges(jobs, gen, hosts, dbs): - nodes = [] - edges = [] - +def get_nodes_and_edges(jobs, gen, hosts, dbs, nodes, edges, srv): + for job in jobs: s = job.get("source") t = job.get("target") if s and t: - s_db, s_host = get_info(s) - t_db, t_host = get_info(t) + s_db, s_host = get_info(s, srv) + t_db, t_host = get_info(t, srv) s_db_name = gen_ext_name(s_db, s_host) t_db_name = gen_ext_name(t_db, t_host) @@ -82,4 +82,4 @@ def get_nodes_and_edges(jobs, gen, hosts, dbs): edges.append({"from": hosts[s_host] , "to":dbs[s_db_name], "arrow_type":"box"}) edges.append({"from": hosts[t_host] , "to":dbs[t_db_name], "arrow_type":"box"}) - return nodes, edges \ No newline at end of file + return nodes, edges diff --git a/server.py b/server.py index 17f6ce349ff195c552ca4a51854a5f237066e7ae..ca165875d88c113b36a55fabc81ad216f158d67c 100644 --- a/server.py +++ b/server.py @@ -12,9 +12,16 @@ CORS(app) @app.route('/repl/all.html', methods=['GET']) def repl_all(): - jobs = utils.get_jobs(config["db"]["host"], config["db"]["port"]) gen = utils.gen_count() - nodes, edges = utils.get_nodes_and_edges(jobs, gen, {}, {}) + hosts = {} + dbs = {} + nodes = [] + edges = [] + + for srv in ("a73434","a73435", "i75422", "i75464", "e75455", "i75415"): + jobs = utils.get_jobs(srv, 5984) + nodes, edges = utils.get_nodes_and_edges(jobs, gen, hosts, dbs, nodes, edges, srv) + template = utils.path_file(path=config['templates']['html'], file='all.html') return render_template(template, nodes=nodes, edges=edges)