#! /usr/bin/env python3

from sys import path
path.append("lib")

import hosts
import json

inv = hosts.Inventory('site/site.conf',
  ipv6_global_network = "2a06:8782:ffbb:1337::/64",
  ipv6_uplink_network = "2a06:8782:ffbb::/64",
  icvpn_ipv4_network = "10.207.0.196/16",
  icvpn_ipv6_network = "fec0::a:cf:0:c4/96",
)

inv_v15 = hosts.Inventory('site/site.conf',
  ipv6_global_network = "2a06:8782:ffbb:42::/64",
  ipv6_uplink_network = "2a06:8782:ffbb::/64",
  icvpn_ipv4_network = "10.207.0.196/16",
  icvpn_ipv6_network = "fec0::a:cf:0:c4/96",
)

grp = inv.group("vpnservers_legacy",
  dhcp=True,
  icvpn=True,
  batman_gateway=True,
  firewall_enabled=True,
  is_legacy=True,
)
grp.host(1, "vpn01.bremen.freifunk.net", exit_ipv4="default", exit_ipv4_interface="eth0", exit_ipv6_remote=False, exit_ipv6_interface="eth0", max_mtu=1462)

grp = inv_v15.group("vpnservers",
  dhcp=True,
  icvpn=True,
  batman_gateway=True,
  firewall_enabled=True,
)
grp.host(7, "vpn07.bremen.freifunk.net", exit_ipv4="default", exit_ipv4_interface="enp1s0", exit_ipv6_remote=False, exit_ipv6_interface="enp1s0", max_mtu=1438)
grp.host(8, "vpn08.bremen.freifunk.net", exit_ipv4="default", exit_ipv4_interface="enp1s0", exit_ipv6_remote=False, exit_ipv6_interface="enp1s0", max_mtu=1438)
grp.host(9, "vpn09.bremen.freifunk.net", exit_ipv4="default", exit_ipv4_interface="enp1s0", exit_ipv6_remote=False, exit_ipv6_interface="enp1s0", max_mtu=1438)

grp = inv.group("eventsserver")
grp.host(0, "mgmt.bremen.freifunk.net")

grp = inv.group("webserver")
grp.host(0, "webserver.bremen.freifunk.net")

grp = inv_v15.group("downlinks", batman_gateway=True, firewall_enabled=True)
grp.host(13, "ipv6-downlink.bremen.freifunk.net", exit_ipv6_interface="enp1s0", max_mtu=1462)

grp = inv.group("dnsserver");
grp.host(0, "dns.bremen.freifunk.net");

grp = inv.group("vmhosts")
grp.host(0, "bre-1.bremen.freifunk.net")
grp.host(0, "bre-2.bremen.freifunk.net")

grp = inv.group("ffmapserver")
grp.host(0, "ffmap.bremen.freifunk.net")

grp = inv.group("monitoring")
grp.host(0, "monitoring.bremen.freifunk.net")

# vpnservers und downlinks zu backbone zusammenfassen
grp = inv.group("backbone_legacy", is_legacy=True)
grp.child("vpnservers_legacy")
grp.child("downlinks_legacy")

# non legacy backbone
grp = inv_v15.group("backbone")
grp.child("vpnservers")
grp.child("downlinks")

# alle Root-Server mit Standard-Config
grp = inv.group("standardserver")
grp.host(0, "bgp-plutex01.bremen.freifunk.net")
grp.host(0, "mail.bremen.freifunk.net")
grp.host(0, "jenkins.bremen.freifunk.net")
grp.host(0, "code.bremen.freifunk.net")
grp.host(0, "babel-gw-lwlcom.bremen.freifunk.net")
grp.host(0, "monitoring.bremen.freifunk.net")
grp.child("vmhosts")
grp.child("backbone")
grp.child("backbone_legacy")
grp.child("webserver")
grp.child("dnsserver")
grp.child("ffmapserver")

inv_dict = inv.data()
inv_dict.update(inv_v15.data())

print(json.dumps(inv_dict,indent=4))
