Init
commit
c098d3ceb3
@ -0,0 +1,29 @@
|
|||||||
|
- each computer should have its configuration
|
||||||
|
- QEMU
|
||||||
|
- systemd-networkd? (
|
||||||
|
- BIRD
|
||||||
|
- Also: bridges-up script to set up all the bridges.
|
||||||
|
- Network should have reasonable addressing scheme
|
||||||
|
- IP
|
||||||
|
- MAC
|
||||||
|
|
||||||
|
MAC:52:54:00:17:<mach>:<net>
|
||||||
|
IP: 172.23.<net>.<mach>
|
||||||
|
|
||||||
|
Rationale: mac is host-based, ip is net-based. This mimmics real networks. The
|
||||||
|
23 = 0x17 is just a number between 16 and 31 without meaning. MAC OUI is from
|
||||||
|
QEMU, could be something else (it _is_ locally administered), but this is
|
||||||
|
recognisable.
|
||||||
|
|
||||||
|
QEMU flags:
|
||||||
|
-enable-kvm
|
||||||
|
-m 200M # enough?
|
||||||
|
-drive ...
|
||||||
|
- networks (copy from Zr/arch)
|
||||||
|
-name
|
||||||
|
- Networks: just bridges with tap-s attached.
|
||||||
|
- OS: Alpine? (/etc/network/interfaces is configurable by mac)
|
||||||
|
- Clonined hdds? Single base hdd + overlay for bird.conf?
|
||||||
|
|
||||||
|
Impl: python with jinja. We want a templating engine, since most of the configs
|
||||||
|
are the same, and something to represent computers and networks.
|
@ -0,0 +1,70 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
|
||||||
|
import ipaddress
|
||||||
|
import jinja2
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
class Bridge:
|
||||||
|
def __init__(self, name, num):
|
||||||
|
self.name = name
|
||||||
|
self.num = num
|
||||||
|
self.computers = []
|
||||||
|
|
||||||
|
class Computer:
|
||||||
|
def __init__(self, name, num):
|
||||||
|
self.name = name
|
||||||
|
self.num = num
|
||||||
|
self.bridges = []
|
||||||
|
|
||||||
|
def add_to_bridge(self, bridge):
|
||||||
|
self.bridges.append(bridge)
|
||||||
|
bridge.computers.append(computer)
|
||||||
|
|
||||||
|
def gen_files(self):
|
||||||
|
files = [
|
||||||
|
'qemu.sh',
|
||||||
|
'interfaces',
|
||||||
|
'bird.conf',
|
||||||
|
]
|
||||||
|
context = {'c': self}
|
||||||
|
|
||||||
|
loader = jinja2.FileSystemLoader('templates/')
|
||||||
|
environment = jinja2.Environment(loader=loader, trim_blocks=True)
|
||||||
|
for f in files:
|
||||||
|
template = environment.get_template(f)
|
||||||
|
template.stream(context).dump(self.name + '/' + f)
|
||||||
|
|
||||||
|
# Computers:
|
||||||
|
comps = {}
|
||||||
|
for i, n in enumerate('ABCDEFGHIX'):
|
||||||
|
comps[n] = Computer(n, i)
|
||||||
|
|
||||||
|
# Bridges
|
||||||
|
bridges = {}
|
||||||
|
for i, n in [(x, 'net_'+str(x)) for x in range(1, 8)]:
|
||||||
|
bridges[n] = Bridge(n, i)
|
||||||
|
|
||||||
|
def dump_bridges(fn):
|
||||||
|
with open(fn, 'w+') as f:
|
||||||
|
for br in bridges:
|
||||||
|
f.write(br + '\n')
|
||||||
|
|
||||||
|
# Connections
|
||||||
|
# dict[ net_num -> [comp_names]
|
||||||
|
conns = {
|
||||||
|
1: 'IGH',
|
||||||
|
2: 'HCE',
|
||||||
|
3: 'GDF',
|
||||||
|
4: 'ACD',
|
||||||
|
5: 'BEF',
|
||||||
|
6: 'ABX',
|
||||||
|
7: 'X',
|
||||||
|
}
|
||||||
|
|
||||||
|
for net, cs in conns.items():
|
||||||
|
for c in cs:
|
||||||
|
comps[c].add_to_bridge(bridges[net])
|
||||||
|
|
||||||
|
dump_bridges('./bridges')
|
Loading…
Reference in New Issue