Changeset 8268 in genesis
- Timestamp:
- Aug 8, 2010, 3:24:13 PM (14 years ago)
- Location:
- nodes
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/generate-config.py
-
Property svn:keywords
set to
Id
r8230 r8268 34 34 # Configuratie gegenereerd met configurator versie %(version)s 35 35 # 36 $location="Locatie XXX, Straat XXX, XXXX XX, Leiden"; 37 $master_ip='%(master_ip)s';38 $nodetype='CNode'; 39 $nodename='%(nodename)s'; 40 $status='up'; 41 $release="8.0-RELEASE"; 42 $X='XXXXX'; 43 $Y='XXXXXX'; 44 $LON='4.XXX'; 45 $LAT='52.XXX'; 36 location : "Locatie XXX, Straat XXX, XXXX XX, Leiden" 37 master_ip: '%(master_ip)s' 38 nodetype: 'CNode' 39 nodename: '%(nodename)s' 40 status: 'up' 41 release: "8.0-RELEASE" 42 rndap_x: 'XXXXX' 43 rNdap_y: 'XXXXXX' 44 lon: '4.XXX' 45 lat: '52.XXX' 46 46 """ % variables 47 47 48 48 # Accesspoint 49 49 print """ 50 $config{'ath0'}=sprintf <<ATH0; # Access point Buurt 51 TYPE=wireless 52 IP=%(master_ip)s/26 53 DESC=AP 54 SDESC=ap 55 DHCP=10-60 56 MODE=master 57 ESSID=ap-WirelessLeiden-%(nodename)s 58 CHANNEL=8 59 ATH0 50 iface_ath0: 51 type: wireless 52 ip: %(master_ip)s/26 53 desc: ap 54 sdesc: ap 55 dhcp: 10-60 56 mode: master 57 essid: ap-WirelessLeiden-%(nodename)s 58 channel: 8 60 59 """ % variables 61 60 … … 63 62 for index, ifname in enumerate(interfaces): 64 63 print """ 65 $config{'%(ifname)s'}=sprintf <<%(ifname_caps)s; # Link naar XXX 66 TYPE=ethernet 67 EXTRA_TYPE=eth2wifibridge 68 IP=%(ip)s/29 69 DESC=Link naar XXX 70 SDESC=2xxx-%(ifname)s 71 #MODE=XXX 72 #ESSID=XX-XX.%(nodename_lower)s.wleiden.net 73 #CHANNEL=XX 74 #NSMAC= 75 #NS_IP=%(ns_ip)s/29 76 DHCP=no 77 %(ifname_caps)s 64 iface_%(ifname)s: 65 comment: Link naar XXX 66 type: ethernet 67 extra_type: eth2wifibridge 68 ip: %(ip)s/29 69 desc: Link naar XXX 70 sdesc: 2xxx-%(ifname)s 71 mode: XXX 72 essid: XX-XX.%(nodename_lower)s.wleiden.net 73 channel: XX 74 nsmac: 75 ns_ip: %(ns_ip)s/29 76 dhcp: no 78 77 """ % { 'nodename_lower' : nodename.lower(), 79 78 'ifname' : ifname, -
Property svn:keywords
set to
-
nodes/make-network-graph.py
-
Property svn:keywords
set to
Id
r8240 r8268 1 1 #!/usr/bin/env python 2 # zoek de eerste vrije (== niet in een wleiden.conf gedefinieerde) interlink 3 # range 4 # lodewijk@wirelessleiden.nl 2 # vim:ts=2:et:sw=2:ai 3 # 4 # Build topological network graph 5 # Rick van der Zwet <info@rickvanderzwet.nl> 5 6 import re 6 7 import sys 7 8 import glob 8 import getrange9 9 import tempfile 10 10 import subprocess 11 import gformat 11 12 12 13 OUTFILE = 'network.png' 13 14 14 15 def make_graph(): 15 substre = re.compile("^(\$[a-zA-Z][^ =]*) ?= ?'([^']*)';") 16 17 18 poel = {} 19 20 #XXX: Make parsing global, merge with getrange.get_ranges if possible 21 for fname in glob.glob("*/wleiden.conf"): 22 substs = {} 23 lineNr = 0 24 for l in open(fname): 25 lineNr += 1 26 l = l[:-1] 27 match = substre.match(l) 28 if match != None: 29 substs[match.group(1)] = match.group(2) 30 if l.startswith("IP="): 31 right = l[3:] 32 if '/' not in right: 33 addr = right 34 mask = 32 35 else: 36 addr, mask = right.split('/') 37 if addr in substs: 38 addr = substs[addr] 39 try: 40 addr = getrange.parseaddr(addr) 41 mask = int(mask) 42 addr = addr & ~((1 << (32 - mask)) - 1) 43 cname = fname.split('/')[0] 44 if poel.has_key(addr): 45 poel[addr] += [cname] 46 else: 47 poel[addr] = [cname] 48 except ValueError, e: 49 print "[FOUT] in bestand '%s' regel '%i': %s" % (fname, lineNr, l) 16 poel = {} 17 link_type = {} 18 try: 19 for host in gformat.get_proxylist() + gformat.get_nodelist(): 20 print "## Processing host", host 21 datadump = gformat.get_yaml(host) 22 iface_keys = [elem for elem in datadump.keys() if (elem.startswith('iface_') and not "lo0" in elem)] 23 for iface_key in iface_keys: 24 l = datadump[iface_key]['ip'] 25 addr, mask = l.split('/') 50 26 51 f = tempfile.NamedTemporaryFile(bufsize=0) 52 sys.stderr.write("# Building temponary graph file\n") 53 print >> f, "Graph WirelessLeidenNetwork {" 54 print >> f ,""" 27 addr = gformat.parseaddr(addr) 28 mask = int(mask) 29 addr = addr & ~((1 << (32 - mask)) - 1) 30 if poel.has_key(addr): 31 poel[addr] += [host] 32 else: 33 poel[addr] = [host] 34 # Assume all eth2wifibridge to be 11a for a moment 35 if datadump[iface_key].has_key('eth2wifibridge'): 36 link_type[addr] = '11a' 37 else: 38 link_type[addr] = datadump[iface_key]['type'] 39 print "### %s [%s] is of type %s" % (gformat.showaddr(addr), iface_key, link_type[addr]) 40 except (KeyError, ValueError), e: 41 print "[FOUT] in '%s' interface '%s'" % (host,iface_key) 42 print e 43 sys.exit(1) 44 45 f = tempfile.NamedTemporaryFile(bufsize=0) 46 sys.stderr.write("# Building temponary graph file\n") 47 print >> f, "Graph WirelessLeidenNetwork {" 48 print >> f ,""" 55 49 graph [ fontsize = 36, 56 50 overlap = scalexy, … … 58 52 ] 59 53 """ 60 for addr,leden in poel.iteritems(): 61 leden = sorted(set(leden)) 62 for index,lid in enumerate(leden[:-1]): 63 for buur in leden[index + 1:]: 64 print >> f,' %s -- %s [label="%s"]' % (lid, buur, getrange.showaddr(addr)) 65 print >> f, "}" 66 sys.stderr.write("# Plotting temponary graph file using graphviz\n") 67 retval = subprocess.call(["neato","-Tpng",f.name, "-o", OUTFILE]) 68 if retval != 0: 69 sys.stderr.write("# FAILED [%i]\n" % retval) 70 subprocess.call(["cat",f.name]) 71 exit(1) 72 sys.stderr.write("# COMPLETED find your output in %s\n" % OUTFILE) 54 for addr,leden in poel.iteritems(): 55 if link_type[addr] == '11a': 56 color = 'red' 57 weight = 4 58 elif link_type[addr] == 'eth': 59 color = 'blue' 60 weight = 8 61 else: 62 color = 'black' 63 weight = 1 64 leden = sorted(set(leden)) 65 for index,lid in enumerate(leden[:-1]): 66 for buur in leden[index + 1:]: 67 print >> f,' %s -- %s [label="%s", color="%s", weight="%s"]' % (lid, buur, gformat.showaddr(addr), color, weight) 68 print >> f, "}" 69 sys.stderr.write("# Plotting temponary graph file using graphviz\n") 70 retval = subprocess.call(["neato","-Tpng",f.name, "-o", OUTFILE]) 71 if retval != 0: 72 sys.stderr.write("# FAILED [%i]\n" % retval) 73 subprocess.call(["cat",f.name]) 74 exit(1) 75 sys.stderr.write("# COMPLETED find your output in %s\n" % OUTFILE) 73 76 74 77 75 78 if __name__ == "__main__": 76 79 make_graph() 77 80 -
Property svn:keywords
set to
Note:
See TracChangeset
for help on using the changeset viewer.