[8230] | 1 | #!/usr/bin/env python
|
---|
| 2 | #
|
---|
| 3 | # Bouw een template Wireless Leiden wleiden.conf voor een nieuwe node
|
---|
| 4 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
| 5 | import getrange
|
---|
| 6 | import sys
|
---|
| 7 |
|
---|
| 8 | __version__ = '$Id: generate-config.py 8615 2010-10-31 19:59:34Z rick $'
|
---|
| 9 |
|
---|
| 10 | if len(sys.argv) <> 2:
|
---|
| 11 | print "Gebruik %s <nodeNaam>" % sys.argv[0]
|
---|
| 12 | print "Configurator versie: %s" % __version__
|
---|
| 13 | exit(1)
|
---|
| 14 |
|
---|
| 15 | nodename = sys.argv[1]
|
---|
| 16 | # ALIX/IRIS Boord standaard interfaces
|
---|
| 17 | interfaces = "vr0 vr1 vr2 ue0 ue1".split(' ')
|
---|
| 18 |
|
---|
| 19 | # Initieele IP interface, aannemend dat alles master is
|
---|
| 20 | master_ip = getrange.get_ranges(False, 24, 1)[0] + 1
|
---|
| 21 | interlinks = getrange.get_ranges(True, 29, len(interfaces))
|
---|
| 22 |
|
---|
| 23 | # Maak de boel een beetje standaard
|
---|
| 24 | variables = {
|
---|
| 25 | 'nodename' : nodename[0].upper() + nodename[1:],
|
---|
| 26 | 'nodename_lower' : nodename.lower(),
|
---|
| 27 | 'master_ip' : getrange.showaddr(master_ip),
|
---|
| 28 | 'version' : __version__ }
|
---|
| 29 |
|
---|
| 30 | # Header
|
---|
| 31 | print """
|
---|
| 32 | #
|
---|
| 33 | # Configuratie voor CNode%(nodename)s
|
---|
| 34 | # Configuratie gegenereerd met configurator versie %(version)s
|
---|
| 35 | #
|
---|
[8268] | 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'
|
---|
[8230] | 46 | """ % variables
|
---|
| 47 |
|
---|
| 48 | # Accesspoint
|
---|
| 49 | print """
|
---|
[8268] | 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
|
---|
[8230] | 59 | """ % variables
|
---|
| 60 |
|
---|
| 61 | # Alle interfaces
|
---|
| 62 | for index, ifname in enumerate(interfaces):
|
---|
| 63 | print """
|
---|
[8268] | 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
|
---|
[8230] | 77 | """ % { 'nodename_lower' : nodename.lower(),
|
---|
| 78 | 'ifname' : ifname,
|
---|
| 79 | 'ifname_caps' : ifname.upper(),
|
---|
| 80 | 'ip' : getrange.showaddr(interlinks[index] + 1),
|
---|
| 81 | 'ns_ip' : getrange.showaddr(interlinks[index] + 2) }
|
---|
| 82 |
|
---|