now powermap draws redundant cables as dash lines.

fixes - Bug 4250 - incohérence des consommations affichées par powermap
This commit is contained in:
Guillaume Raffy 2025-12-11 14:23:07 +01:00
parent 8a2c46c377
commit a8b477978d
1 changed files with 23 additions and 18 deletions

View File

@ -501,7 +501,6 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca
for con in power_config.connections: for con in power_config.connections:
# print(con.from_plug.machine.name, con.to_plug.machine.name) # print(con.from_plug.machine.name, con.to_plug.machine.name)
if not con.is_redundancy_cable(): # don't display redundancy cables, as they might overlap and hide the main one
power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario) power_consumption = con.get_power_consumption(worst_case_scenario=worst_case_scenario)
amperes = power_consumption / 220.0 amperes = power_consumption / 220.0
color = '/svg/green' color = '/svg/green'
@ -518,8 +517,13 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca
label = "%.1f/%s" % (amperes, max_amp) label = "%.1f/%s" % (amperes, max_amp)
# color='//%d' % int(9.0-amperes/capacity*8) # color='//%d' % int(9.0-amperes/capacity*8)
if con.is_redundancy_cable():
edge_style = 'dashed'
else:
edge_style = 'solid'
# graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth)) # graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color="%s:%s" % (color, wsc_color), label=label, penwidth="%s:%s" % (penwidth, penwidth))
graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth) graph.add_edge(con.from_plug.machine.name, con.to_plug.machine.name, color=color, label=label, penwidth=penwidth, style=edge_style)
for rack_id, rack in racks.items(): for rack_id, rack in racks.items():
# sub = graph.add_subgraph(rack, name='cluster_%s' % rack_id, rank='same') # sub = graph.add_subgraph(rack, name='cluster_%s' % rack_id, rank='same')
@ -534,3 +538,4 @@ def power_config_to_svg(power_config: PowerConfig, svg_file_path: Path, worst_ca
graph.layout(prog='dot') graph.layout(prog='dot')
graph.draw(svg_file_path) graph.draw(svg_file_path)