source: genesis/nodes/generate-config.py@ 8268

Last change on this file since 8268 was 8268, checked in by rick, 14 years ago

Whole bunch of tools around the YAML config files for easy editing, formatting and syntax checking

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
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>
5import getrange
6import sys
7
8__version__ = '$Id: generate-config.py 8268 2010-08-08 15:24:13Z rick $'
9
10if len(sys.argv) <> 2:
11 print "Gebruik %s <nodeNaam>" % sys.argv[0]
12 print "Configurator versie: %s" % __version__
13 exit(1)
14
15nodename = sys.argv[1]
16# ALIX/IRIS Boord standaard interfaces
17interfaces = "vr0 vr1 vr2 ue0 ue1".split(' ')
18
19# Initieele IP interface, aannemend dat alles master is
20master_ip = getrange.get_ranges(False, 24, 1)[0] + 1
21interlinks = getrange.get_ranges(True, 29, len(interfaces))
22
23# Maak de boel een beetje standaard
24variables = {
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
31print """
32#
33# Configuratie voor CNode%(nodename)s
34# Configuratie gegenereerd met configurator versie %(version)s
35#
36location : "Locatie XXX, Straat XXX, XXXX XX, Leiden"
37master_ip: '%(master_ip)s'
38nodetype: 'CNode'
39nodename: '%(nodename)s'
40status: 'up'
41release: "8.0-RELEASE"
42rndap_x: 'XXXXX'
43rNdap_y: 'XXXXXX'
44lon: '4.XXX'
45lat: '52.XXX'
46""" % variables
47
48# Accesspoint
49print """
50iface_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
59""" % variables
60
61# Alle interfaces
62for index, ifname in enumerate(interfaces):
63 print """
64iface_%(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
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
Note: See TracBrowser for help on using the repository browser.