Commit 38db8d86 authored by Joanne Hugé's avatar Joanne Hugé

Add global nodes and registries conf parser

All re6stnet configuration files are now stored in the same place
(re6stnet_global.conf), and same for re6st-registry configuration
files. The parser splits these files to create all the individual
configuration files
parent 43fb08d5
...@@ -104,6 +104,57 @@ if args.clone: ...@@ -104,6 +104,57 @@ if args.clone:
if soft in clone_conf: if soft in clone_conf:
clone_conf[soft][machine] = (object_type,git_object) clone_conf[soft][machine] = (object_type,git_object)
# Parse a global conf file
def parse_re6st_conf(conf_name):
with open('%s_global.conf' % conf_name, 'r') as nodes_conf_file:
# Get lines, remove \n and comments
lines = [l.lstrip()[:-1] for l in nodes_conf_file]
lines = list(filter(lambda x: x[0] not in ['#', '\n'], lines))
folder_list, confs, confs_remove = [], {}, {}
def parse_identifier(l):
return l[1:] if l[0] == '@' else ''
# Get list of folders in which we will write confs
folder_list = list(map(parse_identifier, lines))
folder_list = list(filter(lambda x: x and x != 'ALL', folder_list))
i = 0
while i < len(lines):
# Handle each block starting with an identifier
x = parse_identifier(lines[i])
if x:
# List of folder to which the identifier applies
folder_confs = folder_list if x == 'ALL' else [x]
while True:
i += 1
if i >= len(lines):
break
if parse_identifier(lines[i]):
i -= 1
break
for f in folder_confs:
# Add line to either confs dict or confs_remove if '-' is present
confs.setdefault(f, [])
confs_remove.setdefault(f, [])
l = lines[i].replace('%', f)
if l[0] == '-':
confs_remove[f].append(l[1:])
else:
confs[f].append(l + '\n')
i += 1
# Write all the confs in each folder by merging confs and confs_remove
for f in confs:
with open('%s/%s.conf' % (f, conf_name), 'w+') as conf_file:
for l in confs[f]:
if l[:-1] not in confs_remove[f]:
conf_file.write(l)
# Parse re6stnet and re6st-regitry global confs
parse_re6st_conf('re6stnet')
parse_re6st_conf('re6st-registry')
# create nodes # create nodes
for name in """internet=I registry=R for name in """internet=I registry=R
gateway1=g1 machine1=1 machine2=2 gateway1=g1 machine1=1 machine2=2
......
log m1/
run m1/run
state m1/
pp 1194 tcp
ca ca.crt
cert m1/cert.crt
key m1/cert.key
default
neighbour 6/16
log m10/
run m10/run
state m10/
ca ca2.crt
cert m10/cert.crt
key m10/cert.key
default
client-count 2
max-clients 2
log m2/
run m2/run
state m2/
pp 1194 tcp
ca ca.crt
cert m2/cert.crt
key m2/cert.key
default
log m3/
run m3/run
state m3/
pp 1194 tcp
ca ca.crt
cert m3/cert.crt
key m3/cert.key
log m4/
run m4/run
state m4/
pp 1194 tcp
ca ca.crt
cert m4/cert.crt
key m4/cert.key
default
log m5/
run m5/run
state m5/
ca ca.crt
cert m5/cert.crt
key m5/cert.key
default
client-count 0
max-clients 0
log m6/
run m6/run
state m6/
ip fc42:6::1
pp 1194 tcp
pp 1194 udp
pp 1195 udp6
ca ca.crt
cert m6/cert.crt
key m6/cert.key
disable-proto none
# TODO: Run a DHCPv4 client on machine9. Unfortunately, isc-dhcp-client 4.2.4
# fails with "Bind socket to interface: No such device"
daemon "exec dnsmasq -d8 - -i $re6stnet_iface -F 192.168.42.2,192.168.42.254,255.255.255.0,infinite -F ${re6stnet_subnet%/*},ra-only,${re6stnet_subnet#*/},1d -O option:router,192.168.42.1 -l m6/dnsmasq.leases"
log m7/
run m7/run
state m7/
pp 1194 tcp
pp 1194 udp
pp 1195 udp6
ca ca.crt
cert m7/cert.crt
key m7/cert.key
disable-proto none
log m8/
run m8/run
state m8/
ca ca.crt
cert m8/cert.crt
key m8/cert.key
disable-proto none
client fc42:6::1,1195,udp6;fc42:7::1,1195,udp6
@ALL
key %/ca.key
logfile %/%.log
run %/run
dh dh2048.pem
hello 4
client-count 2
tunnel-refresh 100
ipv4 10.42.0.0/16 8
@registry
ca ca.crt
@registry2
ca ca2.crt
@ALL
log %/
run %/run
state %/
ca ca.crt
cert %/cert.crt
key %/cert.key
ovpnlog
@m1
pp 1194 tcp
default
neighbour 6/16
@m2
pp 1194 tcp
default
@m3
pp 1194 tcp
@m4
pp 1194 tcp
default
@m5
default
client-count 0
max-clients 0
@m6
ip fc42:6::1
pp 1194 tcp
pp 1194 udp
pp 1195 udp6
disable-proto none
# TODO: Run a DHCPv4 client on machine9. Unfortunately, isc-dhcp-client 4.2.4
# fails with "Bind socket to interface: No such device"
daemon "exec dnsmasq -d8 - -i $re6stnet_iface -F 192.168.42.2,192.168.42.254,255.255.255.0,infinite -F ${re6stnet_subnet%/*},ra-only,${re6stnet_subnet#*/},1d -O option:router,192.168.42.1 -l m6/dnsmasq.leases"
@m7
pp 1194 tcp
pp 1194 udp
pp 1195 udp6
disable-proto none
@m8
disable-proto none
client fc42:6::1,1195,udp6;fc42:7::1,1195,udp6
@m10
-ca ca.crt
ca ca2.crt
default
client-count 2
max-clients 2
@registry
dh dh2048.pem
gateway
disable-proto none
@registry2
dh dh2048.pem
-ca ca.crt
ca ca2.crt
gateway
ca ca.crt
key registry/ca.key
dh dh2048.pem
logfile registry/registry.log
run registry/run
hello 4
client-count 2
tunnel-refresh 100
ipv4 10.42.0.0/16 8
log registry/
run registry/run
state registry/
dh dh2048.pem
ca ca.crt
cert registry/cert.crt
key registry/cert.key
gateway
disable-proto none
ca ca2.crt
key registry2/ca.key
dh dh2048.pem
logfile registry2/registry2.log
run registry2/run
hello 4
client-count 2
tunnel-refresh 100
ipv4 10.42.0.0/16 8
log registry2/
run registry2/run
state registry2/
dh dh2048.pem
ca ca2.crt
cert registry2/cert.crt
key registry2/cert.key
gateway
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment