exporters.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:ansibilo 作者: Polyconseil 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号