Code cleanup
This commit is contained in:
parent
74997fbe68
commit
58bde04833
1 changed files with 11 additions and 7 deletions
|
@ -65,27 +65,31 @@ def generate_graph(verbose: bool, file: str):
|
||||||
gateway = None
|
gateway = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subnet = net['IPAM']['Config'][0]['Subnet']
|
if net['Internal']:
|
||||||
|
internal = "| Internal"
|
||||||
|
else:
|
||||||
|
internal = ""
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
subnet = None
|
internal = ""
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Network: %s %s gw:%s" % (net_name, subnet, gateway))
|
print("Network: %s %s gw:%s" % (net_name, internal, gateway))
|
||||||
|
|
||||||
net_node_id = "net_%s" % (net_name,)
|
net_node_id = "net_%s" % (net_name,)
|
||||||
|
|
||||||
net_label_html = '<br/>'.join([s for s in ['<font color="#777777"><i>network</i></font>', net_name, subnet, gateway] if s is not None])
|
label = "{<gw_iface> %s | %s %s}" % (gateway, net_name, internal)
|
||||||
|
|
||||||
g.node(net_node_id,
|
g.node(net_node_id,
|
||||||
shape='record',
|
shape='record',
|
||||||
label="{<gw_iface> %s| %s }" % (gateway, net_name),
|
label=label,
|
||||||
fillcolor=color,
|
fillcolor=color,
|
||||||
style='filled')
|
style='filled'
|
||||||
|
)
|
||||||
|
|
||||||
for container_id, container in sorted(net['Containers'].items()):
|
for container_id, container in sorted(net['Containers'].items()):
|
||||||
if verbose:
|
if verbose:
|
||||||
dump_json(container)
|
dump_json(container)
|
||||||
if verbose:
|
|
||||||
print(" * ", container['Name'], container['IPv4Address'], container['IPv6Address'])
|
print(" * ", container['Name'], container['IPv4Address'], container['IPv6Address'])
|
||||||
|
|
||||||
container_node_id = 'container_%s' % container_id
|
container_node_id = 'container_%s' % container_id
|
||||||
|
|
Loading…
Reference in a new issue