7 def fetch_instances(domain: str):
8 print("DEBUG: Fetching instances for domain:", domain)
9 peerlist = fba.get_peers(domain)
11 if (peerlist is None):
12 print("ERROR: Cannot fetch peers:", domain)
15 "SELECT domain FROM instances WHERE domain = ? LIMIT 1", (domain,)
18 if fba.c.fetchone() == None:
19 # NOISY-DEBUG: print("DEBUG: Adding new domain:", domain)
20 fba.add_instance(domain)
25 for instance in peerlist:
26 instance = instance.lower()
27 if instance.find("@") > 0:
28 print("WARNING: Bad instance name,domain:", instance, domain)
32 for peer in fba.blacklist:
37 # NOISY-DEBUG: print("DEBUG: domain is blacklisted:", domain)
40 # NOISY-DEBUG: print("DEBUG: Handling instance:", instance)
43 "SELECT domain FROM instances WHERE domain = ? LIMIT 1", (instance,)
46 if fba.c.fetchone() == None:
47 # NOISY-DEBUG: print("DEBUG: Adding new instance:", instance)
48 fba.add_instance(instance)
52 except Exception as e:
53 print("ERROR:", e, instance)
56 instance = sys.argv[1]
59 fetch_instances(instance)
61 # Loop through some instances
63 "SELECT domain FROM instances WHERE software IS NOT NULL AND (last_nodeinfo IS NULL OR last_nodeinfo < ?) ORDER BY rowid DESC", [time.time() - fba.config["recheck_instance"]]
66 for instance in fba.c.fetchall():
68 for domain in fba.blacklist:
69 if domain in instance[0]:
73 # NOISY-DEBUG: print("DEBUG: domain is blacklisted:", instance)
76 print("DEBUG: Fetching instances for instance:", instance[0])
77 fetch_instances(instance[0])