@@ -425,12 +425,10 @@ def serveralias(name):
425425 match name .lower ():
426426 case "core-expo" :
427427 payload = [
428- "core-slave" ,
429428 "ntpexpo" ,
430429 ]
431430 case "core-conf" :
432431 payload = [
433- "core-master" ,
434432 "loghost" ,
435433 "monitoring" ,
436434 "ntpconf" ,
@@ -1020,22 +1018,170 @@ def generatezones(switches, routers, pis, aps, servers, outputdir):
10201018def generatewasgehtconfig (switches , routers , pis , aps , servers , outputdir ):
10211019 wasgehtconfig = {}
10221020 for switch in switches :
1023- wasgehtconfig [switch ["name" ]] = {"address" : switch ["ipv6" ]}
1021+ entry = {
1022+ "tags" : {
1023+ "type" : "switch" ,
1024+ "os" : "junos" ,
1025+ "num" : switch ["num" ],
1026+ ** (
1027+ {"aliases" : ", " .join (switch ["aliases" ])}
1028+ if switch ["aliases" ]
1029+ else {}
1030+ ),
1031+ },
1032+ "checks" : {
1033+ "ping" : {
1034+ "addresses" : [switch ["ipv6" ]],
1035+ },
1036+ },
1037+ }
1038+ wasgehtconfig [switch ["name" ]] = entry
10241039 for router in routers :
1025- wasgehtconfig [router ["name" ]] = {"address" : router ["ipv6" ]}
1040+ if router ["name" ] == "br-mdf-01" :
1041+ ping_addresses = [
1042+ "172.20.1.1" ,
1043+ "2001:470:f026:901::1" ,
1044+ "10.0.3.2" ,
1045+ "2001:470:f026:103::2" ,
1046+ "172.20.4.1" ,
1047+ "2001:470:f026:104::1" ,
1048+ ]
1049+ elif router ["name" ] == "ex-mdf-01" :
1050+ ping_addresses = [
1051+ "172.20.4.3" ,
1052+ "2001:470:f026:104::3" ,
1053+ "172.20.3.3" ,
1054+ "2001:470:f026:903::3" ,
1055+ "10.0.3.1" ,
1056+ "2001:470:f026:103::1" ,
1057+ ]
1058+ elif router ["name" ] == "cf-mdf-01" :
1059+ ping_addresses = [
1060+ "172.20.1.2" ,
1061+ "2001:470:f026:901::2" ,
1062+ "172.20.3.2" ,
1063+ "2001:470:f026:903::2" ,
1064+ "10.128.3.1" ,
1065+ "2001:470:f026:503::1" ,
1066+ ]
1067+ else :
1068+ ping_addresses = [router ["ipv6" ]]
1069+ wasgehtconfig [router ["name" ]] = {
1070+ "tags" : {
1071+ "type" : "router" ,
1072+ "os" : "nixos" ,
1073+ },
1074+ "checks" : {
1075+ "ping" : {
1076+ "addresses" : ping_addresses ,
1077+ },
1078+ },
1079+ }
10261080 for pi in pis :
1027- wasgehtconfig [pi ["name" ]] = {"address" : pi ["ipv6" ]}
1081+ wasgehtconfig [pi ["name" ]] = {
1082+ "tags" : {
1083+ "type" : "pi" ,
1084+ "os" : "nixos" ,
1085+ "role" : "registration" if pi ["name" ].startswith ("pi-reg" ) else "sign" ,
1086+ },
1087+ "checks" : {
1088+ "ping" : {
1089+ "addresses" : [pi ["ipv6" ]],
1090+ },
1091+ },
1092+ }
10281093 for ap in aps :
1029- wasgehtconfig [ap ["name" ]] = {"address" : ap ["ipv4" ]}
1094+ wasgehtconfig [ap ["name" ]] = {
1095+ "tags" : {
1096+ "type" : "ap" ,
1097+ "os" : "openwrt" ,
1098+ "channels" : f"{ ap ['wifi2' ]} / { ap ['wifi5' ]} " ,
1099+ "config" : ap ["configver" ],
1100+ ** ({"aliases" : ", " .join (ap ["aliases" ])} if ap ["aliases" ] else {}),
1101+ },
1102+ "checks" : {
1103+ "ping" : {
1104+ "addresses" : [ap ["ipv4" ]],
1105+ },
1106+ "wifi_stations" : {
1107+ "address" : ap ["ipv4" ],
1108+ "radios" : ["phy0-ap0" , "phy1-ap0" ],
1109+ },
1110+ },
1111+ }
10301112 for server in servers :
1031- wasgehtconfig [server ["name" ]] = {"address" : server ["ipv6" ]}
1032- wasgehtconfig ["google88v6" ] = {"address" : "2001:4860:4860::8888" }
1033- wasgehtconfig ["google88v4" ] = {"address" : "8.8.8.8" }
1034- wasgehtconfig ["google44v6" ] = {"address" : "2001:4860:4860::8844" }
1035- wasgehtconfig ["google44v4" ] = {"address" : "8.8.4.4" }
1036- wasgehtconfig ["localhost" ] = {"address" : "::1" }
1113+ wasgehtconfig [server ["name" ]] = {
1114+ "tags" : {
1115+ "type" : "server" ,
1116+ "os" : "nixos" ,
1117+ "role" : server ["role" ],
1118+ "building" : server ["building" ],
1119+ ** (
1120+ {"aliases" : ", " .join (server ["aliases" ])}
1121+ if server ["aliases" ]
1122+ else {}
1123+ ),
1124+ },
1125+ "checks" : {
1126+ "ping" : {
1127+ "addresses" : [server ["ipv6" ], server ["ipv4" ]],
1128+ },
1129+ ** (
1130+ {
1131+ "dns" : {
1132+ "server" : f"{ server ['ipv4' ]} :53" ,
1133+ "queries" : [
1134+ {
1135+ "name" : server ["fqdn" ],
1136+ "type" : "A" ,
1137+ "expect" : server ["ipv4" ],
1138+ },
1139+ {
1140+ "name" : server ["ipv4ptr" ],
1141+ "type" : "PTR" ,
1142+ "expect" : server ["fqdn" ],
1143+ },
1144+ {
1145+ "name" : server ["ipv6ptr" ],
1146+ "type" : "PTR" ,
1147+ "expect" : server ["fqdn" ],
1148+ },
1149+ {
1150+ "name" : server ["fqdn" ],
1151+ "type" : "AAAA" ,
1152+ "expect" : server ["ipv6" ],
1153+ },
1154+ {
1155+ "name" : "a.root-servers.net" ,
1156+ "type" : "AAAA" ,
1157+ "expect" : "2001:503:ba3e::2:30" ,
1158+ },
1159+ ],
1160+ }
1161+ }
1162+ if server ["role" ] == "core"
1163+ else {}
1164+ ),
1165+ ** (
1166+ {
1167+ "http" : {
1168+ "urls" : [
1169+ f"https://{ server ['fqdn' ]} /grafana/" ,
1170+ f"https://{ server ['fqdn' ]} /loki/" ,
1171+ f"https://{ server ['fqdn' ]} /mimir/" ,
1172+ f"https://{ server ['fqdn' ]} /tempo/" ,
1173+ f"http://{ server ['fqdn' ]} :1982" ,
1174+ ],
1175+ "skip_verify" : True ,
1176+ }
1177+ }
1178+ if server ["name" ] == "core-conf"
1179+ else {}
1180+ ),
1181+ },
1182+ }
10371183 with open (f"{ outputdir } /scale-wasgeht-config.json" , "w" ) as f :
1038- json .dump (wasgehtconfig , f )
1184+ json .dump (wasgehtconfig , f , indent = 2 )
10391185
10401186
10411187def generateallnetwork (switches , routers , outputdir ):
0 commit comments