From 411afb151948a031782511cf608c1930669db7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donatas=20Rasiukevi=C4=8Dius?= Date: Thu, 1 Feb 2024 10:22:20 +0100 Subject: [PATCH] Add visual representation for hostmeta --- .../infra_index_details_table.jinja2 | 56 +++++++++++++++++++ humitifier/infra/models/host.py | 6 +- humitifier/infra/models/hostfacts.py | 15 ++++- 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/humitifier/dash/templates/infra_index_details_table.jinja2 b/humitifier/dash/templates/infra_index_details_table.jinja2 index bbe4ebe..b78c1f8 100644 --- a/humitifier/dash/templates/infra_index_details_table.jinja2 +++ b/humitifier/dash/templates/infra_index_details_table.jinja2 @@ -47,6 +47,62 @@ {% endif %} + {# WebDav #} + {% if host.facts.hostmeta.webdav %} + + WebDav + + {{ host.facts.hostmeta.webdav }} + + + {% endif %} + + {# VHosts #} + {% if host.facts.hostmeta.vhosts %} + + VHosts + + {% for vhost in host.facts.hostmeta.vhosts %} + {{vhost}} +
+ {% endfor %} + + + {% endif %} + + {# File Servers #} + {% if host.facts.hostmeta.fileservers %} + + File Servers + + {% for fileserver in host.facts.hostmeta.fileservers %} + + + {% endfor %} + + + {% endif %} + + {# Databases #} + {% if host.facts.hostmeta.databases %} + + Databases + + {% for dbtype, dbs in host.facts.hostmeta.databases.items() %} + + {% endfor %} + + + {% endif %} + + + {# Uptime #} {% if host.facts.uptime_days %} diff --git a/humitifier/infra/models/host.py b/humitifier/infra/models/host.py index 4ae8141..6475681 100644 --- a/humitifier/infra/models/host.py +++ b/humitifier/infra/models/host.py @@ -54,12 +54,12 @@ def alert_severity(self) -> str: @property def department(self) -> str | None: - return self.metadata.get("department") + return self.facts.hostmeta.department @property def contact(self) -> str | None: - if contact := self.metadata.get("contact"): - return contact.get("name"), contact.get("email") + if contact := self.hostmeta.contact: + return contact, contact @property def package_names(self) -> list[str]: diff --git a/humitifier/infra/models/hostfacts.py b/humitifier/infra/models/hostfacts.py index 29de07f..edf1a22 100644 --- a/humitifier/infra/models/hostfacts.py +++ b/humitifier/infra/models/hostfacts.py @@ -3,7 +3,16 @@ import json from pssh.output import HostOutput from datetime import datetime -from humitifier.infra.facts import FACT_TABLE, DIVIDER, element_to_fact, HostnameCtl, Memory, Uptime, PackageList +from humitifier.infra.facts import ( + FACT_TABLE, + DIVIDER, + element_to_fact, + HostnameCtl, + Memory, + Uptime, + PackageList, + HostMeta, +) from dataclasses import dataclass @@ -94,3 +103,7 @@ def uptime_days(self) -> int | None: @property def packages(self) -> PackageList | None: return self.facts.get(PackageList.alias) + + @property + def hostmeta(self) -> HostMeta | None: + return self.facts.get(HostMeta.alias)