Skip to content

Commit ed68fb3

Browse files
feat(print-phonehome): application FQDNs
- Add the list of FQDN to the application facts. FQDNs are obtained from Traefik instances, by looking at the name_module_map fact. - Traefik knows an application name from set_route() and set_certificate() calls.
1 parent 78cb530 commit ed68fb3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/imageroot/var/lib/nethserver/cluster/bin/print-phonehome

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def modules_facts(rdb):
6161
ret = []
6262
module_domains_relation = rdb.hgetall('cluster/module_domains') or {}
6363
instance_list = get_installed_modules(rdb)
64+
fqdn_cache = {}
6465

6566
# Collect facts from modules:
6667
for module in instance_list:
@@ -72,6 +73,7 @@ def modules_facts(rdb):
7273
"certification_level": module["certification_level"],
7374
"update_available": module["update_available"],
7475
"user_domains": [],
76+
"fqdns": [],
7577
}
7678
for v in set(module_domains_relation.get(module.get('id'), '').split()):
7779
minfo["user_domains"].append(agent.facts.pseudo_domain(v))
@@ -110,7 +112,18 @@ def modules_facts(rdb):
110112

111113
decorate_with_ui_name(minfo, rdb, 'module/' + module.get('id'))
112114
ret.append(minfo)
113-
115+
# Extract FQDNs used by applications from Traefik facts:
116+
if minfo["name"] == "traefik" and "name_module_map" in minfo:
117+
for fqdn, mkey in minfo["name_module_map"].items():
118+
if mkey in fqdn_cache:
119+
fqdn_cache[mkey].add(fqdn)
120+
else:
121+
fqdn_cache[mkey] = {fqdn}
122+
123+
# Decorate apps with list of FQDNs extracted from Traefik facts:
124+
for minfo in ret:
125+
if minfo["id"] in fqdn_cache:
126+
minfo["fqdns"] = list(fqdn_cache[minfo["id"]])
114127
return ret
115128

116129
def get_core_update_available_map(rdb):

0 commit comments

Comments
 (0)