Changeset 11753 in genesis
- Timestamp:
- Feb 14, 2013, 10:52:07 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/make-network-graph.py
r10890 r11753 21 21 pass 22 22 23 def pass_filter(host): 24 for t in sys.argv: 25 if t in host: 26 return True 27 return False 28 29 nodes = {} 30 23 31 def make_graph(): 24 32 poel = {} … … 27 35 try: 28 36 for host in gformat.get_hostlist(): 37 if not pass_filter(host): 38 continue 29 39 print "## Processing host", host 30 40 datadump = gformat.get_yaml(host) 41 nodename = datadump['nodename'] 31 42 iface_keys = [elem for elem in datadump.keys() if (elem.startswith('iface_') and not "lo0" in elem)] 43 nodes[nodename] = datadump 32 44 for iface_key in iface_keys: 33 45 l = datadump[iface_key]['ip'] … … 41 53 mask = int(mask) 42 54 addr = addr & ~((1 << (32 - mask)) - 1) 55 nk = nodename + ':' + datadump[iface_key]['autogen_ifname'] 43 56 if poel.has_key(addr): 44 poel[addr] += [ host]57 poel[addr] += [nk] 45 58 else: 46 poel[addr] = [ host]59 poel[addr] = [nk] 47 60 # Assume all ns_ip to be 11a for a moment 48 61 if datadump[iface_key].has_key('ns_ip'): … … 53 66 link_data[addr] = 1 54 67 iface = datadump[iface_key]['autogen_ifname'] 55 nodename = datadump['nodename']56 68 print nodename, iface 57 69 INTERVAL = 60 * 10 … … 71 83 sys.exit(1) 72 84 73 #f = tempfile.NamedTemporaryFile(bufsize=0)74 85 f = open('/tmp/test.dot','w') 75 86 sys.stderr.write("# Building temponary graph file\n") 76 print >> f, " Graph WirelessLeidenNetwork {"87 print >> f, "digraph WirelessLeidenNetwork {" 77 88 print >> f ,""" 78 graph [ fontsize = 36,89 graph [ fontsize = 10, 79 90 overlap = scalexy, 80 91 splines = true, 92 rankdir = LR, 81 93 ] 94 node [ fontsize = 10, ] 95 edge [ fontsize = 10, ] 82 96 """ 97 for node, datadump in nodes.iteritems(): 98 lines = [node] 99 for ik in datadump['autogen_iface_keys']: 100 if 'alias' in ik or 'wlan' in datadump[ik]['autogen_ifname']: 101 continue 102 if datadump[ik].has_key('ns_mac'): 103 lines.append('<%(autogen_ifname)s> %(bridge_type)s at %(autogen_ifname)s - %(ns_mac)s\\n%(ssid)s\\n%(ns_ip)s' % datadump[ik]) 104 else: 105 lines.append('<%(autogen_ifname)s> %(autogen_ifname)s' % datadump[ik]) 106 print >> f,""" 107 "%s" [ 108 shape = "record" 109 label = "%s" 110 ]; 111 """ % (node, "|".join(lines)) 112 113 83 114 for addr,leden in poel.iteritems(): 84 115 if link_type[addr] == '11a': … … 95 126 for index,lid in enumerate(leden[:-1]): 96 127 for buur in leden[index + 1:]: 97 print >> f,' %s - - %s [label="%s", color="%s", weight="%s", style="setlinewidth(%s)"]' % (lid, buur, gformat.showaddr(addr), color, weight, width)128 print >> f,' %s -> %s [color="%s", weight="%s", style="setlinewidth(%s)"]' % (lid, buur, color, weight, width) 98 129 print >> f, "}" 99 130 f.flush()
Note:
See TracChangeset
for help on using the changeset viewer.