Bug 2514 - mettre à jour le plan de câblage alimentation des serveurs communs
amélioration: désormais le diagramme fait bien ressortir les câblages qui méritent de l'attention : - en rouge les cables en surcharge (dont l'ampérage max peut dépasser la capacité) - en noir les cables qui n'ont pas de charge Pour que le rouge soit réservé aux cables à problème, les conventions de couleurs pour les cables non surchargés ont été modifieés : c'est désormais en teintes de bleu.
This commit is contained in:
parent
889712b356
commit
9aaefd495f
|
@ -261,8 +261,49 @@ class PowerConfig(object):
|
||||||
s += str(c) + '\n'
|
s += str(c) + '\n'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
class CableColorer(object):
|
||||||
|
|
||||||
|
def get_cable_color(self, amperes, capacity):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
class SimpleColorer(CableColorer):
|
||||||
|
|
||||||
|
def get_cable_color(self, amperes, capacity):
|
||||||
|
saturation = amperes / capacity
|
||||||
|
if saturation > 1.0:
|
||||||
|
color = '/svg/red'
|
||||||
|
elif saturation > 0.75:
|
||||||
|
color = '/svg/orange'
|
||||||
|
elif saturation < 0.001:
|
||||||
|
color = '/svg/black' # probably an error
|
||||||
|
else:
|
||||||
|
color = '/svg/green'
|
||||||
|
return color
|
||||||
|
|
||||||
|
class RampColorer(CableColorer):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def hotness_to_hsv_color(hotness):
|
||||||
|
"""
|
||||||
|
:param float hotness: temperature of the wire ratio (0.0 : cold -> 1.0 : hot)
|
||||||
|
"""
|
||||||
|
clamped_hotness = max(min(hotness, 1.0), 0.0)
|
||||||
|
return "%f, 1.0, 0.8" % ((clamped_hotness) * 0.33 + 0.33)
|
||||||
|
|
||||||
|
def get_cable_color(self, amperes, capacity):
|
||||||
|
saturation = amperes / capacity
|
||||||
|
# color = RampColorer.hotness_to_hsv_color(pow(saturation, 4.0))
|
||||||
|
clamped_saturation = max(min(saturation, 1.0), 0.0)
|
||||||
|
color = '/ylgnbu9/%d' % (int(clamped_saturation * 5) + 4)
|
||||||
|
|
||||||
|
if saturation < 0.001:
|
||||||
|
color = '/svg/black' # probably an error
|
||||||
|
elif saturation > 1.0:
|
||||||
|
color = '/svg/red'
|
||||||
|
return color
|
||||||
|
|
||||||
def power_config_to_svg(power_config, svg_file_path):
|
def power_config_to_svg(power_config, svg_file_path):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
creates a svg diagram representing the input power configuration
|
creates a svg diagram representing the input power configuration
|
||||||
|
|
||||||
|
@ -280,12 +321,6 @@ def power_config_to_svg(power_config, svg_file_path):
|
||||||
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
||||||
graph.edge_attr['len'] = 1.5 # default : 1.0
|
graph.edge_attr['len'] = 1.5 # default : 1.0
|
||||||
|
|
||||||
def hotness_to_hsv_color(hotness):
|
|
||||||
"""
|
|
||||||
:param float hotness: temperature of the wire ratio (0.0 : cold -> 1.0 : hot)
|
|
||||||
"""
|
|
||||||
clamped_hotness = max(min(hotness, 1.0), 0.0)
|
|
||||||
return "%f, 1.0, 0.8" % ((1.0 - clamped_hotness) * 0.33)
|
|
||||||
|
|
||||||
# graph.add_node('a')
|
# graph.add_node('a')
|
||||||
# graph.add_node('b')
|
# graph.add_node('b')
|
||||||
|
@ -316,6 +351,8 @@ def power_config_to_svg(power_config, svg_file_path):
|
||||||
y += 1.0
|
y += 1.0
|
||||||
x += 1.0
|
x += 1.0
|
||||||
|
|
||||||
|
cable_colorer = RampColorer()
|
||||||
|
|
||||||
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
|
if not con.is_redundancy_cable(): # don't display redundancy cables, as they might overlap and hide the main one
|
||||||
|
@ -330,13 +367,7 @@ def power_config_to_svg(power_config, svg_file_path):
|
||||||
penwidth = 100.0 * penwidth_scaler # make the problem clearly visible
|
penwidth = 100.0 * penwidth_scaler # make the problem clearly visible
|
||||||
else:
|
else:
|
||||||
max_amp = str(capacity) + 'A'
|
max_amp = str(capacity) + 'A'
|
||||||
if amperes / capacity > 1.0:
|
color = cable_colorer.get_cable_color(amperes, capacity)
|
||||||
color = 'red'
|
|
||||||
elif amperes / capacity > 0.75:
|
|
||||||
color = 'orange'
|
|
||||||
else:
|
|
||||||
color = 'green'
|
|
||||||
color = hotness_to_hsv_color(pow(amperes / capacity, 4.0))
|
|
||||||
penwidth = capacity * penwidth_scaler
|
penwidth = capacity * penwidth_scaler
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue