def export_to_dot(host_groups, data_center_prefix='dc-'):
dc_colors = _colors('white', '#238b45')
host_colors = _colors('black', '#66c2a4')
role_colors = _colors('black', '#b2e2e2')
graph = graphviz.Graph()
graph.attr('graph', overlap='false', layout='neato', comment=ANSIBLE_INVENTORY_TAG)
for fqdn, labels in host_groups.items():
host = fqdn.split('.')[0]
graph.node(host, **host_colors)
for label in labels:
if label.startswith(data_center_prefix):
graph.node(label, **dc_colors)
graph.edge(label, host, **dc_colors)
else:
graph.node(label, **role_colors)
graph.edge(host, label, **role_colors)
return graph
评论列表
文章目录