This work (network_hosts inventory + infra_audit MCP tool, /api/cluster + Sacred Valley cluster card, topbar cluster-health pill + SW self-heal) was built in an earlier session and DEPLOYED to CT 311 as alpha.24–26, but was never committed to git — prod was running code absent from the repo. Commits it as-is (already prod-validated) so git matches the live state, and restores its alpha.24/25/26 CHANGELOG entries. Files are disjoint from the fold-in work; both now ship together under alpha.27. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
// public/views/cards/cluster.js — Proxmox cluster health + quorum across nodes.
|
|
import { el, mount } from '../../dom.js';
|
|
import { api } from '../../api.js';
|
|
|
|
let body, timer;
|
|
|
|
function nodeRow(n, master) {
|
|
const tags = [];
|
|
if (n.local) tags.push('local');
|
|
if (master === n.name) tags.push('master');
|
|
return el('div', { class: 'sv-row status-' + (n.online ? 'ok' : 'down') },
|
|
el('span', { class: 'k' }, el('span', { class: 'dot' }), n.name),
|
|
el('span', {}, (n.online ? 'online' : 'OFFLINE') + (tags.length ? ' · ' + tags.join(' · ') : '')));
|
|
}
|
|
|
|
async function load() {
|
|
if (!body) return;
|
|
try {
|
|
const c = await api.get('/api/cluster');
|
|
if (c.error) { mount(body, el('span', { class: 'muted' }, 'Cluster: ' + c.error)); return; }
|
|
const haIssues = c.ha?.services_error || 0;
|
|
const rows = el('div', { class: 'sv-cluster' },
|
|
el('div', { class: 'sv-row' },
|
|
el('span', { class: 'k' }, 'Quorum'),
|
|
el('span', { class: 'cl-badge ' + (c.quorate ? 'ok' : 'bad') }, c.quorate ? 'QUORATE' : 'NO QUORUM')),
|
|
el('div', { class: 'sv-row' },
|
|
el('span', { class: 'k' }, 'Nodes'),
|
|
el('span', { class: c.nodes_online < c.nodes_total ? 'warn' : '' }, `${c.nodes_online}/${c.nodes_total} online`)),
|
|
...(c.nodes || []).map(n => nodeRow(n, c.ha?.master)),
|
|
el('div', { class: 'sv-row' },
|
|
el('span', { class: 'k' }, 'HA services'),
|
|
el('span', { class: haIssues ? 'warn' : '' },
|
|
haIssues ? `${c.ha.services_total} · ${haIssues} ⚠` : `${c.ha?.services_total ?? 0} · ok`))
|
|
);
|
|
mount(body, rows);
|
|
} catch { mount(body, el('span', { class: 'muted' }, 'Cluster unavailable')); }
|
|
}
|
|
|
|
export default {
|
|
id: 'cluster', title: 'Cluster · HZ', size: 'm',
|
|
mount(e) { body = e; load(); },
|
|
start() { timer = setInterval(load, 30000); },
|
|
stop() { clearInterval(timer); body = null; }
|
|
};
|