Compare commits

..
Author SHA1 Message Date
jared 2f4cb05f67 Merge pull request 'docs: replace the old "Large1" port-label examples' (#50) from docs/large1-leftovers into main
Lint / JS (eslint) (push) Successful in 9s
Lint / Python (flake8) (push) Successful in 54s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m3s
Test / Python Tests (pytest) (push) Successful in 1m43s
Lint / Deploy (push) Successful in 5s
2026-11-18 16:18:30 -05:00
jaredandClaude Opus 5.5 fa108b2a1e docs: remove large1 leftovers; no node names for HA guests
Lint / JS (eslint) (push) Successful in 10s
Lint / Python (flake8) (push) Successful in 43s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m44s
Test / Python Tests (pytest) (push) Successful in 1m27s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / Python (flake8) (pull_request) Successful in 1m9s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m9s
Test / Python Tests (pytest) (pull_request) Successful in 1m12s
large1 was renamed to compute-storage-02 on 2026-11-18. Updates text that still
named large1. HA guests no longer carry a fixed node (they move between nodes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:15:31 -05:00
jared ff425dbaee Merge pull request 'Rename large1 to compute-storage-02 (README, placeholders, docstring)' (#49) from rename/large1-to-compute-storage-02 into main
Lint / JS (eslint) (push) Successful in 11s
Lint / Python (flake8) (push) Successful in 1m4s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Successful in 16s
Security / Python Security (bandit) (push) Successful in 1m11s
Test / Python Tests (pytest) (push) Successful in 1m31s
2026-11-18 15:41:08 -05:00
jaredandClaude Opus 5.5 99dee62098 Rename large1 to compute-storage-02 (README, placeholders, docstring)
Lint / Python (flake8) (push) Successful in 1m24s
Lint / JS (eslint) (push) Successful in 13s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m25s
Test / Python Tests (pytest) (push) Successful in 1m35s
Lint / JS (eslint) (pull_request) Successful in 9s
Lint / Python (flake8) (pull_request) Successful in 59s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m14s
Test / Python Tests (pytest) (pull_request) Successful in 1m8s
Text only. Prod config.json and DB history are updated during the window.
Test fixtures keep large1 on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 14:30:56 -05:00
jared 4ad331ddfe Merge pull request 'Polish: phone alert cards, quieter badges, footer, small layout fixes' (#48) from polish into main
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m2s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m17s
Lint / Deploy (push) Successful in 12s
Test / Python Tests (pytest) (push) Successful in 1m28s
2026-11-18 01:49:34 -05:00
jaredandClaude Opus 5.5 7da4cc26e2 Polish: phone alert cards, quieter badges, footer, small layout fixes
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 1m17s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / Python (flake8) (pull_request) Successful in 57s
Security / Python Security (bandit) (push) Successful in 1m0s
Test / Python Tests (pytest) (push) Successful in 1m56s
Security / Python Security (bandit) (pull_request) Successful in 1m52s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Test / Python Tests (pytest) (pull_request) Successful in 1m25s
- Active alerts on the dashboard become one card per alert on phones
  instead of a table squeezed to a letter per line.
- Section count badges are neutral; red is kept for active alerts and
  tickets to follow up, so "History 0" no longer looks like a problem.
- Host cards only tag the data source when it isn't node_exporter
  (a ping-only host), instead of "prometheus" on every card.
- WAN / Fiber: the BGW320 doesn't report uptime here, so show the last
  restart instead of a permanent "Uptime -".
- Footer: CFG and HELP read like the hints beside them rather than grey
  browser buttons, and the footer sits at the bottom of short pages.
- Wider alert filter and suppression name fields so their hints fit.
- "just now" instead of a negative age when a clock runs a little ahead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 01:36:20 -05:00
11 changed files with 97 additions and 45 deletions

No files matched your search

+5 -5
View File
@@ -92,7 +92,7 @@ Two processes share a MariaDB database:
| Host | Prometheus Instance |
|---|---|
| large1 | 10.10.10.2:9100 |
| compute-storage-02 | 10.10.10.2:9100 |
| compute-storage-01 | 10.10.10.4:9100 |
| monitor-01 | 10.10.10.8:9100 |
| monitor-02 | 10.10.10.9:9100 |
@@ -118,7 +118,7 @@ Ping-only (no node_exporter): **pbs** (10.10.10.3)
Served by `GET /api/attention` (`attention.py`) and refreshed with the rest of the page.
- Device search (see Device pages below)
- Active alerts table with severity, target, consecutive failures, ticket link
- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart, a 24 hour internet health strip from UniFi, 7-day Rx trend, recent WAN outages
- WAN / Fiber panel: WAN and PON state, Rx/Tx power, optics temperature, throughput, errors, gateway uptime and last restart (just the last restart when the gateway doesn't report uptime), a 24 hour internet health strip from UniFi, 7-day Rx trend, recent WAN outages
- Hosts with per-NIC link state; NICs marked unused fold into a "+N unused" line
- UniFi devices as a compact list (name and model; offline ones turn red with a suppress button)
- Recently resolved alerts, folded until opened
@@ -136,7 +136,7 @@ holds every page and Start maintenance.
Every alert Gandalf raised in the last 24 hours to 90 days, including ones that cleared before anyone
saw them: when each started, how long it lasted, failed checks, and its ticket.
- Filter by device (name, port or interface), alert type, severity, and open or cleared. Filters are
kept in the URL, so `/events?target=large1&range=90d` is a shareable link; device pages and tickets
kept in the URL, so `/events?target=compute-storage-02&range=90d` is a shareable link; device pages and tickets
link to their own history this way.
- **Recurring** lists the same alert on the same target more than once in the range, worst first, since
a flapping cable or optic shows up here before anyone notices the tickets.
@@ -227,7 +227,7 @@ servers along the bottom. Power gear (PDU, UPS, power strip) sits in a rail on t
named "Patch panel port 1" (the device beyond the panel is unknown); a stub that already has a name
keeps it and adds "via Patch panel port 2". The cable details show where the cutsheet cable goes.
- **Port names**: a ⚠ marks a port named after one device with a different one plugged in (a port
called "Large1 Management" with the AP on it). Generic names ("Port 4", "SFP+ 2", "Uplink") and
called "compute-storage-02 Management" with the AP on it). Generic names ("Port 4", "SFP+ 2", "Uplink") and
"Downlink to X" with X on the other end never flag.
- **Alerts**: a device with active alerts (not suppressed) gets a ring and a count in its worst
severity colour, and the NIC it is about is marked.
@@ -588,7 +588,7 @@ Shared by both processes. Located in the working directory (`/var/www/html/prod/
"trusted_proxies": ["10.10.10.27"]
},
"hosts": [
{ "name": "large1", "prometheus_instance": "10.10.10.2:9100" },
{ "name": "compute-storage-02", "prometheus_instance": "10.10.10.2:9100" },
{ "name": "compute-storage-01", "prometheus_instance": "10.10.10.4:9100" },
{ "name": "monitor-01", "prometheus_instance": "10.10.10.8:9100" },
{ "name": "monitor-02", "prometheus_instance": "10.10.10.9:9100" },
+1 -1
View File
@@ -914,7 +914,7 @@ class LinkStatsCollector:
"""
Collect full link stats for all Prometheus-monitored hosts.
*instance_map*: ``{'10.10.10.2:9100': 'large1', ...}``
*instance_map*: ``{'10.10.10.2:9100': 'compute-storage-02', ...}``
Returns a dict suitable for ``db.set_state('link_stats', ...)``.
"""
+22 -12
View File
@@ -363,6 +363,16 @@ function _modemLastRestart(history) {
return `restarted ${_modemWhen(last.at)}${last.by ? ` by ${last.by}` : ''}`;
}
function _modemUptimeStat(data) {
if (data.uptime_s !== null && data.uptime_s !== undefined) {
return _modemStat('Uptime', _modemUptime(data.uptime_s), '', _modemLastRestart(data.wan_history));
}
const restarts = (data.wan_history && data.wan_history.restarts) || [];
if (!restarts.length) return '';
const last = restarts[restarts.length - 1];
return _modemStat('Last restart', _modemWhen(last.at), '', last.by ? `by ${last.by}` : '');
}
function _modemDuration(seconds) {
if (seconds < 60) return `${Math.round(seconds)}s`;
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${Math.round(seconds % 60)}s`;
@@ -467,7 +477,7 @@ function updateModem(data) {
${_modemOptic('Optics temp', optics.temperature, status.temperature, '°C')}
${_modemStat('Throughput', `↓ ${_modemRate(rates.rx_bytes)}`, '', `↑ ${_modemRate(rates.tx_bytes)}`)}
${_modemStat('Errors / drops', `${errs} / ${drops}`, errs ? 'lt-text-amber' : '', 'since modem reboot')}
${_modemStat('Uptime', _modemUptime(data.uptime_s), '', _modemLastRestart(data.wan_history))}
${_modemUptimeStat(data)}
</div>
${_modemQuality(data.wan_quality)}
${_modemChart(data.history)}
@@ -526,16 +536,16 @@ function updateEventsTable(events, totalActive) {
: '';
return `
<tr class="row-${e.severity}${e.is_suppressed ? ' row-suppressed' : ''}">
<td><span class="lt-badge badge-${e.severity}">${e.severity}</span>${supBadge}${staleBadge}${closedBadge}</td>
<td>${lt.escHtml(e.event_type.replace(/_/g,' '))}</td>
<td><strong>${lt.escHtml(e.target_name)}</strong></td>
<td>${lt.escHtml(e.target_detail || '-')}</td>
<td class="desc-cell" title="${lt.escHtml(e.description || '')}">${lt.escHtml((e.description||'').substring(0,60))}${(e.description||'').length>60?'…':''}</td>
<td class="ts-cell" title="${lt.escHtml(e.first_seen||'')}">${lt.time.ago(_toIso(e.first_seen))}</td>
<td class="ts-cell" title="${lt.escHtml(e.last_seen||'')}">${lt.time.ago(_toIso(e.last_seen))}</td>
<td>${e.consecutive_failures}</td>
<td>${ticket}</td>
<td>
<td data-label="Sev"><span class="lt-badge badge-${e.severity}">${e.severity}</span>${supBadge}${staleBadge}${closedBadge}</td>
<td data-label="Type">${lt.escHtml(e.event_type.replace(/_/g,' '))}</td>
<td data-label="Target"><strong>${lt.escHtml(e.target_name)}</strong></td>
<td data-label="Detail">${lt.escHtml(e.target_detail || '-')}</td>
<td data-label="Description" class="desc-cell" title="${lt.escHtml(e.description || '')}">${lt.escHtml((e.description||'').substring(0,60))}${(e.description||'').length>60?'…':''}</td>
<td data-label="First seen" class="ts-cell" title="${lt.escHtml(e.first_seen||'')}">${lt.time.ago(_toIso(e.first_seen))}</td>
<td data-label="Last seen" class="ts-cell" title="${lt.escHtml(e.last_seen||'')}">${lt.time.ago(_toIso(e.last_seen))}</td>
<td data-label="Failures">${e.consecutive_failures}</td>
<td data-label="Ticket">${ticket}</td>
<td data-label="Actions">
<button class="lt-btn lt-btn-ghost lt-btn-sm btn-suppress"
data-sup-type="${lt.escHtml(supType)}"
data-sup-name="${lt.escHtml(e.target_name)}"
@@ -548,7 +558,7 @@ function updateEventsTable(events, totalActive) {
wrap.innerHTML = `
${countNotice}
<div class="lt-table-wrap">
<table class="lt-table" id="events-table">
<table class="lt-table lt-table-responsive" id="events-table">
<caption class="lt-sr-only">Active network alerts</caption>
<thead>
<tr>
+1
View File
@@ -488,6 +488,7 @@
const date = value instanceof Date ? value : new Date(value);
if (isNaN(date)) return '-';
const diff = Math.floor((Date.now() - date.getTime()) / 1000);
if (diff < 5) return 'just now'; // also a clock a little ahead of this browser's
if (diff < 60) return diff + 's ago';
if (diff < 3600) return Math.floor(diff / 60) + 'm ago';
if (diff < 86400) return Math.floor(diff / 3600) + 'h ago';
+30 -8
View File
@@ -177,13 +177,18 @@
text-transform: uppercase;
letter-spacing: .08em;
}
/* A count. Neutral by default; red only where it counts problems (active alerts, follow-ups). */
.g-section-badge {
font-size: .72em;
font-weight: bold;
color: var(--accent-red);
border: 1px solid var(--accent-red);
color: var(--text-muted);
border: 1px solid var(--border-color);
padding: 1px 7px;
}
.g-section-badge-alert {
color: var(--accent-red);
border-color: var(--accent-red);
}
.g-section-badge-resolved {
font-size: .68em;
color: var(--text-muted);
@@ -330,7 +335,6 @@
letter-spacing: .04em;
font-weight: bold;
}
.source-prometheus { color: var(--orange); border-color: var(--orange-dim); }
.source-ping { color: var(--cyan); border-color: var(--cyan-dim); }
.iface-list { border-top: 1px solid var(--border-color); padding-top: 6px; margin-bottom: 8px; }
.iface-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
@@ -345,8 +349,9 @@
/* ── Form layout helpers (used in suppressions.html form grids) ───── */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.form-row-align { align-items: flex-end; }
.form-row > .lt-form-group { flex: 1 1 220px; }
.form-group-wide { flex: 3; }
.form-group-submit { flex: 0 0 auto; min-width: unset; }
.form-group-submit, .form-row > .form-group-submit { flex: 0 0 auto; min-width: unset; }
.required { color: var(--red); }
/* ── Duration pills ───────────────────────────────────────────────── */
@@ -914,10 +919,6 @@ a.device-link:hover { color: var(--text-accent); border-bottom-color: current
.device-table th, .device-table td { padding-left: 6px; padding-right: 6px; }
}
.device-search-row.is-active { box-shadow: inset 3px 0 0 var(--terminal-cyan, #0ff); }
@media (max-width: 700px) {
/* Scroll inside the wrapper rather than squeezing every column to a few letters */
#events-table { min-width: 760px; }
}
/* ── Port inspector on the device page ────────────────────────────── */
.device-inspector { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 16px; align-items: start; }
@@ -1827,3 +1828,24 @@ body.fp-marks-off .fp-svg .fp-mark { display: none; }
.lt-header-user, .lt-cmd-hint-btn, .lt-header-right [data-action="start-maintenance"] { display: none; }
}
.g-drawer-action { background: none; border: 0; width: 100%; text-align: left; font: inherit; cursor: pointer; }
/* ── Footer: the CFG and HELP buttons read like the keyboard hints beside them ── */
button.lt-footer-hint {
background: none; border: 0; padding: 0; margin: 0;
font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
}
button.lt-footer-hint:hover, button.lt-footer-hint:focus-visible { color: var(--accent-cyan, var(--cyan)); }
/* ── Footer at the bottom of the window on short pages, not halfway up ── */
body { display: flex; flex-direction: column; }
body > .lt-main { flex: 1 0 auto; width: 100%; }
body > .lt-footer { flex-shrink: 0; }
/* ── Active alerts: room for the filter's hint; full-width cards on phones ── */
#events-search { min-width: 300px; }
@media (max-width: 767px) {
#events-search { min-width: 0; }
#events-table, #events-table tbody { display: block; width: 100%; }
#events-table td { max-width: none; }
#events-table td.desc-cell { white-space: normal; text-align: right; }
}
+1 -1
View File
@@ -290,7 +290,7 @@
</div>
<div class="lt-form-group" id="sup-name-group">
<label class="lt-label" for="sup-name">Target Name</label>
<input type="text" class="lt-input" id="sup-name" name="target_name" placeholder="e.g. large1">
<input type="text" class="lt-input" id="sup-name" name="target_name" placeholder="e.g. compute-storage-02">
</div>
<div class="lt-form-group" id="sup-detail-group" style="display:none">
<label class="lt-label" for="sup-detail">Interface <span class="lt-field-hint">(interface type only)</span></label>
+14 -14
View File
@@ -53,7 +53,7 @@
<section class="g-section">
<div class="g-section-header">
<h2 class="g-section-title">Active Alerts</h2>
<span class="g-section-badge" id="alert-count-badge"
<span class="g-section-badge g-section-badge-alert" id="alert-count-badge"
{% if not summary.critical and not summary.warning %}style="display:none"{% endif %}>{{ (summary.critical or 0) + (summary.warning or 0) }}</span>
</div>
<div class="lt-toolbar">
@@ -80,7 +80,7 @@
<div class="pagination-notice">Showing {{ events|length }} of {{ total_active }} active alerts. Use the search box to filter, or <a href="/api/events?limit=1000" target="_blank" rel="noopener">export all as JSON</a></div>
{% endif %}
<div class="lt-table-wrap">
<table class="lt-table" id="events-table">
<table class="lt-table lt-table-responsive" id="events-table">
<caption class="lt-sr-only">Active network alerts</caption>
<thead>
<tr>
@@ -100,30 +100,30 @@
{% for e in events %}
{% if e.severity != 'info' %}
<tr class="row-{{ e.severity }}{% if e.is_suppressed %} row-suppressed{% endif %}">
<td>
<td data-label="Sev">
<span class="lt-badge badge-{{ e.severity }}">{{ e.severity }}</span>
{% if e.is_suppressed %}<span class="lt-badge badge-suppressed" title="Alert suppressed">🔕 sup</span>{% endif %}
{% if e.stale_days is not none %}<span class="lt-badge badge-stale" title="Active for {{ e.stale_days }} days with no fix yet">⏳ {{ e.stale_days }}d</span>{% endif %}
{% if e.ticket_closed %}<span class="lt-badge badge-ticket-closed" title="Ticket #{{ e.ticket_id }} was closed in Tinker, but this alert is still active">ticket closed</span>{% endif %}
</td>
<td>{{ e.event_type | replace('_', ' ') }}</td>
<td><strong>{{ e.target_name }}</strong></td>
<td>{{ e.target_detail or '-' }}</td>
<td class="desc-cell" title="{{ e.description | e }}">{{ e.description | truncate(60) }}</td>
<td class="ts-cell" title="{{ e.first_seen }}">
<td data-label="Type">{{ e.event_type | replace('_', ' ') }}</td>
<td data-label="Target"><strong>{{ e.target_name }}</strong></td>
<td data-label="Detail">{{ e.target_detail or '-' }}</td>
<td data-label="Description" class="desc-cell" title="{{ e.description | e }}">{{ e.description | truncate(60) }}</td>
<td data-label="First seen" class="ts-cell" title="{{ e.first_seen }}">
<span class="event-age" data-ts="{{ e.first_seen }}">{{ e.first_seen }}</span>
</td>
<td class="ts-cell" title="{{ e.last_seen }}">
<td data-label="Last seen" class="ts-cell" title="{{ e.last_seen }}">
<span class="event-age" data-ts="{{ e.last_seen }}">{{ e.last_seen }}</span>
</td>
<td>{{ e.consecutive_failures }}</td>
<td>
<td data-label="Failures">{{ e.consecutive_failures }}</td>
<td data-label="Ticket">
{% if e.ticket_id %}
<a href="{{ config.ticket_api.web_url }}{{ e.ticket_id }}" target="_blank"
class="ticket-link">#{{ e.ticket_id }}</a>
{% else %}-{% endif %}
</td>
<td>
<td data-label="Actions">
<button class="lt-btn lt-btn-ghost lt-btn-sm btn-suppress"
data-sup-type="{{ 'unifi_device' if e.event_type == 'unifi_device_offline' else 'interface' if e.event_type == 'interface_down' else 'host' }}"
data-sup-name="{{ e.target_name }}"
@@ -157,7 +157,7 @@
<section class="g-section" id="followup"{% if not stale_tickets %} hidden{% endif %}>
<div class="g-section-header">
<h2 class="g-section-title">Needs Follow-up</h2>
<span class="g-section-badge" id="followup-badge">{{ stale_tickets | length }}</span>
<span class="g-section-badge g-section-badge-alert" id="followup-badge">{{ stale_tickets | length }}</span>
</div>
<p class="followup-intro">These tickets are still open in Tinker, but their alert cleared over a day ago. Close them if the problem is fixed.</p>
<div class="lt-frame">
@@ -212,7 +212,7 @@
</div>
<div class="host-meta">
<span class="host-ip">{{ host.ip }}</span>
<span class="host-source source-{{ host.source }}">{{ host.source }}</span>
{% if host.source != 'prometheus' %}<span class="host-source source-{{ host.source }}">{{ host.source }}</span>{% endif %}
</div>
</div>
+1 -1
View File
@@ -50,7 +50,7 @@
<div class="lt-form-group form-group-wide">
<label class="lt-label" for="s-reason">Reason <span class="required">*</span></label>
<input type="text" class="lt-input" id="s-reason" name="reason"
placeholder="e.g. Planned switch maintenance, replacing SFP on large1/enp43s0"
placeholder="e.g. Planned switch maintenance, replacing SFP on compute-storage-02/enp43s0"
required aria-required="true">
</div>
</div>
+19
View File
@@ -850,6 +850,25 @@ class TestCalmDashboard:
assert '>eth0<' in html and '>eth1<' not in html
assert '+2 unused' in html
def test_source_tag_only_for_hosts_without_node_exporter(self, client):
snap = json.dumps({'hosts': {
'large1': {'ip': '10.0.0.2', 'status': 'up', 'source': 'prometheus', 'interfaces': {'eth0': 'up'}},
'pbs': {'ip': '10.0.0.3', 'status': 'up', 'source': 'ping', 'interfaces': {}}}, 'unifi': []})
state = dict(STATE, network_snapshot=snap)
with patch.object(gandalf.db, 'get_state', side_effect=lambda k, d=None: state.get(k, d)):
html = client.get('/', headers=AUTH).get_data(as_text=True)
assert 'source-prometheus' not in html
assert '<span class="host-source source-ping">ping</span>' in html
def test_alert_table_turns_into_cards_on_phones(self, client):
ev = {'id': 1, 'event_type': 'host_down', 'severity': 'critical', 'target_name': 'pbs',
'target_detail': '', 'description': 'pbs is down', 'consecutive_failures': 3,
'first_seen': '2026-11-15 01:00:00', 'last_seen': '2026-11-15 02:00:00'}
with patch.object(gandalf.db, 'get_active_events', return_value=[ev]):
html = client.get('/', headers=AUTH).get_data(as_text=True)
assert 'class="lt-table lt-table-responsive" id="events-table"' in html
assert 'data-label="Target"><strong>pbs</strong>' in html
def test_resolved_alerts_are_folded(self, client):
ev = {'target_name': 'large1', 'target_detail': '', 'severity': 'warning', 'event_type': 'host_down',
'first_seen': '2026-11-15 01:00:00 UTC', 'resolved_at': '2026-11-15 02:00:00 UTC'}
+1 -1
View File
@@ -62,7 +62,7 @@ def link(text: str, url: str) -> str:
def port_text(switch: str, port_name: str, port: dict) -> str:
"""'8SFP-AGG port 7 "Large1": up at 10 Gbps, DAC'"""
"""'8SFP-AGG port 7 "compute-storage-02": up at 10 Gbps, DAC'"""
idx = port.get('port_idx')
text = f'{switch} port {idx}' if idx is not None else f'{switch} {port_name}'
if port_name and idx is not None and port_name != f'Port {idx}':
+2 -2
View File
@@ -25,7 +25,7 @@ _TOKEN_RE = re.compile(r'[a-z0-9]+')
def _norm(name: str) -> str:
"""A name with case, spaces, dashes and underscores ignored: "Large1" == "large-1"."""
"""A name with case, spaces, dashes and underscores ignored: "Storage-01" == "storage_01"."""
return ''.join(_TOKEN_RE.findall((name or '').lower()))
@@ -114,7 +114,7 @@ def name_mismatch(port_name: str, neighbour: str, own: str, known: Dict[str, str
"""A port named after a different device than the one plugged into it.
known: {normalised name: display name} of every device. Runs of up to four words of
the port name are compared with them, so "Large1 Management" names large1 and
the port name are compared with them, so "Storage-01 Management" names storage-01 and
"Downlink to 24RJ45-POE" names 24RJ45-POE. Ports named only "Port 4" never match.
"""
if not port_name or _is_generic_port_name(port_name):