diff --git a/tools/fleet.py b/tools/fleet.py index 6ab44f1..b0b3fd6 100644 --- a/tools/fleet.py +++ b/tools/fleet.py @@ -44,10 +44,13 @@ def slug(s): def config(): with urllib.request.urlopen(HUB + "/api/fleet", timeout=10) as r: machines = json.load(r)["machines"] + # The locations' wired networks first (10.1 NA, 10.2 WS, 10.3 AB, 10.4 NW, 10.5 SC); NA Ingest also has a + # 10.66 address the laptop cannot reach (2026-10-21), and 10.6 is staff Wi-Fi. + site = lambda ip: re.match(r"10\.[1-5]\.", ip) is not None wired = lambda ip: not ip.startswith(("10.6.", "169.254.", "127.")) lines, used = ["# Written by tools/fleet.py from %s/api/fleet - every machine that took this laptop's key." % HUB], set() for m in sorted(machines, key=lambda m: m["name"].lower()): - ip = next((i for i in m["ips"] if wired(i)), m["ips"][0] if m["ips"] else None) + ip = next((i for i in m["ips"] if site(i)), next((i for i in m["ips"] if wired(i)), m["ips"][0] if m["ips"] else None)) if not ip: continue alias = slug(m["name"])