sort hosts by pretty name, not by internal hostname

This commit is contained in:
Franzi 2021-04-11 08:05:49 +02:00
parent 6b95291821
commit a0a359d5dd
Signed by untrusted user: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -107,13 +107,15 @@ class StatusPage:
def render_service_details(self): def render_service_details(self):
# generate list of hosts by scanning services for unique host_name # generate list of hosts by scanning services for unique host_name
host_names = set() host_names = {}
for service in self.get_api_result(): for service in self.get_api_result():
host_names.add(service['attrs']['host_name']) host_names[service['joins']['host']['vars']['pretty_name']] = service['attrs']['host_name']
# render html for each host_name # render html for each host_name
html_output = [] html_output = []
for host in sorted(host_names): # Can't use .values() here, since we want to sort by prettyname
html_output.append(self.render_services_per_host(host)) for prettyname, hostname in sorted(host_names.items()):
html_output.append(self.render_services_per_host(hostname))
return ''.join(html_output) return ''.join(html_output)