Skip to content

Commit

Permalink
Add visual representation for hostmeta
Browse files Browse the repository at this point in the history
  • Loading branch information
fliepeltje committed Feb 1, 2024
1 parent 0ea8f90 commit 411afb1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
56 changes: 56 additions & 0 deletions humitifier/dash/templates/infra_index_details_table.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,62 @@
</tr>
{% endif %}

{# WebDav #}
{% if host.facts.hostmeta.webdav %}
<tr>
<td>WebDav</td>
<td>
<a href="{{ host.facts.hostmeta.webdav }}">{{ host.facts.hostmeta.webdav }}</a>
</td>
</tr>
{% endif %}

{# VHosts #}
{% if host.facts.hostmeta.vhosts %}
<tr>
<td>VHosts</td>
<td>
{% for vhost in host.facts.hostmeta.vhosts %}
<code>{{vhost}}</code>
<br>
{% endfor %}
</td>
</tr>
{% endif %}

{# File Servers #}
{% if host.facts.hostmeta.fileservers %}
<tr>
<td>File Servers</td>
<td>
{% for fileserver in host.facts.hostmeta.fileservers %}
<ul>
<li><code>{{fileserver}}</code></li>
</ul>

{% endfor %}
</td>
</tr>
{% endif %}

{# Databases #}
{% if host.facts.hostmeta.databases %}
<tr>
<td>Databases</td>
<td>
{% for dbtype, dbs in host.facts.hostmeta.databases.items() %}
<ul>
<li><span class="badge info">{{dbtype}}</span>
<code>{{ ', '.join(dbs) }}</code>
</li>
</ul>
{% endfor %}
</td>
</tr>
{% endif %}



{# Uptime #}
{% if host.facts.uptime_days %}
<tr>
Expand Down
6 changes: 3 additions & 3 deletions humitifier/infra/models/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
15 changes: 14 additions & 1 deletion humitifier/infra/models/hostfacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)

0 comments on commit 411afb1

Please sign in to comment.