Commit 870caced authored by Nicolas Herbaut's avatar Nicolas Herbaut
Browse files

color for graph are random and based on the hostname

parent bb907258
......@@ -50,7 +50,7 @@ def get_containers_data():
with open(args.pillar) as f:
pillar = yaml.load(f.read())
for name, conf in pillar["placement"].items():
for i in conf.get("instances",[]):
for i in conf.get("instances", []):
res.append((i["name"], name))
res = "\n".join(["%s\t%s" % item for item in res])
......@@ -61,9 +61,11 @@ def get_containers_data():
@app.route("/api/flows")
def get_containers_flow():
matrix = get_flow_matrix(args.influxdb_host, args.influxdb_port)
values = [(a.split("_")[1], b.split("_")[1], matrix[a][b]) for a in matrix.keys() for b in matrix.keys()]
res = Template("""{% for s in settings %}{{s}}\n{% endfor %}""").render(
settings=["%s\t%s\t%s" % v for v in values if v[0] != v[1]])
res = []
for a in matrix.keys():
for b in matrix.keys():
res.append("%s\t%s\t%s\n" % (a.split("_")[1], b.split("_")[1], matrix[a][b]))
return Response(res, mimetype='text/yaml')
......
......@@ -118,17 +118,8 @@ def get_svg(d):
return black.get_web(), 1
def type_to_col(name_full):
name = name_full.split("_")[-1]
if name == "cass":
return "green"
elif name == "zoo":
return "gray"
elif name == "kafka":
return "blue"
elif name == "spark":
return "red"
else:
return "red"
name = name_full.split("_")[0]
return Color(rgb=(hash("r" + name) % 256 / 255, hash("g" + name) % 256 / 255, hash("b" + name) % 256 / 255))
# Todo adapt for FULL page
upper = d.where(~np.tril(np.ones(d.shape)).astype(np.bool))
......@@ -146,7 +137,7 @@ def get_svg(d):
if not pd.isnull(array[column]):
g.add_edge(row, column, length=array[column], type=row)
values = [type_to_col(node) for node in g.nodes()]
values = [type_to_col(node).hex for node in g.nodes()]
node_labels = {node: node for node in g.nodes()}
values_edge_color = [sizeof_get_color(e[2]["length"], mmean, mstd)[0] for e in g.edges(data=True)]
values_edge_width = [2 * sizeof_get_color(e[2]["length"], mmean, mstd)[1] for e in g.edges(data=True)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment