Skip to content
Snippets Groups Projects
Commit 48f6a59b authored by Thomas Bock's avatar Thomas Bock :speech_balloon:
Browse files

.

parent c012fe91
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -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
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment